VLCMediaPlayer.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /*****************************************************************************
  2. * VLCMediaPlayer.h: VLCKit.framework VLCMediaPlayer header
  3. *****************************************************************************
  4. * Copyright (C) 2007-2009 Pierre d'Herbemont
  5. * Copyright (C) 2007-2014 VLC authors and VideoLAN
  6. * Copyright (C) 2009-2014 Felix Paul Kühne
  7. * $Id$
  8. *
  9. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  10. * Felix Paul Kühne <fkuehne # videolan.org>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU Lesser General Public License as published by
  14. * the Free Software Foundation; either version 2.1 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public License
  23. * along with this program; if not, write to the Free Software Foundation,
  24. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  25. *****************************************************************************/
  26. #import <Foundation/Foundation.h>
  27. #if TARGET_OS_IPHONE
  28. # import <CoreGraphics/CoreGraphics.h>
  29. #endif
  30. #import "VLCMedia.h"
  31. #import "VLCTime.h"
  32. #import "VLCAudio.h"
  33. #if !TARGET_OS_IPHONE
  34. @class VLCVideoView;
  35. @class VLCVideoLayer;
  36. #endif
  37. @class VLCLibrary;
  38. /* Notification Messages */
  39. extern NSString *const VLCMediaPlayerTimeChanged;
  40. extern NSString *const VLCMediaPlayerStateChanged;
  41. /**
  42. * VLCMediaPlayerState describes the state of the media player.
  43. */
  44. typedef NS_ENUM(NSInteger, VLCMediaPlayerState)
  45. {
  46. VLCMediaPlayerStateStopped, //< Player has stopped
  47. VLCMediaPlayerStateOpening, //< Stream is opening
  48. VLCMediaPlayerStateBuffering, //< Stream is buffering
  49. VLCMediaPlayerStateEnded, //< Stream has ended
  50. VLCMediaPlayerStateError, //< Player has generated an error
  51. VLCMediaPlayerStatePlaying, //< Stream is playing
  52. VLCMediaPlayerStatePaused //< Stream is paused
  53. };
  54. /**
  55. * Returns the name of the player state as a string.
  56. * \param state The player state.
  57. * \return A string containing the name of state. If state is not a valid state, returns nil.
  58. */
  59. extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
  60. /**
  61. * Formal protocol declaration for playback delegates. Allows playback messages
  62. * to be trapped by delegated objects.
  63. */
  64. @protocol VLCMediaPlayerDelegate
  65. @optional
  66. /**
  67. * Sent by the default notification center whenever the player's state has changed.
  68. * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
  69. * the VLCMediaPlayer object in question by sending object to aNotification.
  70. */
  71. - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
  72. /**
  73. * Sent by the default notification center whenever the player's time has changed.
  74. * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
  75. * the VLCMediaPlayer object in question by sending object to aNotification.
  76. */
  77. - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
  78. @end
  79. // TODO: Should we use medialist_player or our own flavor of media player?
  80. @interface VLCMediaPlayer : NSObject
  81. @property (nonatomic, readonly) VLCLibrary *libraryInstance;
  82. @property (weak) id<VLCMediaPlayerDelegate> delegate;
  83. #if !TARGET_OS_IPHONE
  84. /* Initializers */
  85. - (instancetype)initWithVideoView:(VLCVideoView *)aVideoView;
  86. - (instancetype)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
  87. #endif
  88. - (instancetype)initWithOptions:(NSArray *)options;
  89. /* Video View Options */
  90. // TODO: Should be it's own object?
  91. #pragma mark -
  92. #pragma mark video functionality
  93. #if !TARGET_OS_IPHONE
  94. - (void)setVideoView:(VLCVideoView *)aVideoView;
  95. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  96. #endif
  97. @property (strong) id drawable; /* The videoView or videoLayer */
  98. /**
  99. * Set/Get current video aspect ratio.
  100. *
  101. * \param psz_aspect new video aspect-ratio or NULL to reset to default
  102. * \note Invalid aspect ratios are ignored.
  103. * \return the video aspect ratio or NULL if unspecified
  104. * (the result must be released with free()).
  105. */
  106. @property (NS_NONATOMIC_IOSONLY) char *videoAspectRatio;
  107. /**
  108. * Set/Get current crop filter geometry.
  109. *
  110. * \param psz_geometry new crop filter geometry (NULL to unset)
  111. * \return the crop filter geometry or NULL if unset
  112. */
  113. @property (NS_NONATOMIC_IOSONLY) char *videoCropGeometry;
  114. /**
  115. * Set/Get the current video scaling factor.
  116. * That is the ratio of the number of pixels on
  117. * screen to the number of pixels in the original decoded video in each
  118. * dimension. Zero is a special value; it will adjust the video to the output
  119. * window/drawable (in windowed mode) or the entire screen.
  120. *
  121. * \param relative scale factor as float
  122. */
  123. @property (nonatomic) float scaleFactor;
  124. /**
  125. * Take a snapshot of the current video.
  126. *
  127. * If width AND height is 0, original size is used.
  128. * If width OR height is 0, original aspect-ratio is preserved.
  129. *
  130. * \param path the path where to save the screenshot to
  131. * \param width the snapshot's width
  132. * \param height the snapshot's height
  133. */
  134. - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(int)width andHeight:(int)height;
  135. /**
  136. * Enable or disable deinterlace filter
  137. *
  138. * \param name of deinterlace filter to use (availability depends on underlying VLC version), NULL to disable.
  139. */
  140. - (void)setDeinterlaceFilter: (NSString *)name;
  141. /**
  142. * Enable or disable adjust video filter (contrast, brightness, hue, saturation, gamma)
  143. *
  144. * \param bool value
  145. */
  146. @property (nonatomic) BOOL adjustFilterEnabled;
  147. /**
  148. * Set/Get the adjust filter's contrast value
  149. *
  150. * \param float value (range: 0-2, default: 1.0)
  151. */
  152. @property (nonatomic) float contrast;
  153. /**
  154. * Set/Get the adjust filter's brightness value
  155. *
  156. * \param float value (range: 0-2, default: 1.0)
  157. */
  158. @property (nonatomic) float brightness;
  159. /**
  160. * Set/Get the adjust filter's hue value
  161. *
  162. * \param integer value (range: 0-360, default: 0)
  163. */
  164. @property (nonatomic) int hue;
  165. /**
  166. * Set/Get the adjust filter's saturation value
  167. *
  168. * \param float value (range: 0-3, default: 1.0)
  169. */
  170. @property (nonatomic) float saturation;
  171. /**
  172. * Set/Get the adjust filter's gamma value
  173. *
  174. * \param float value (range: 0-10, default: 1.0)
  175. */
  176. @property (nonatomic) float gamma;
  177. /**
  178. * Get the requested movie play rate.
  179. * @warning Depending on the underlying media, the requested rate may be
  180. * different from the real playback rate. Due to limitations of some protocols
  181. * this option may not be taken into account at all, if set.
  182. * \param rate movie play rate to set
  183. *
  184. * \return movie play rate
  185. */
  186. @property (nonatomic) float rate;
  187. @property (nonatomic, readonly, weak) VLCAudio * audio;
  188. /* Video Information */
  189. /**
  190. * Get the current video size
  191. * \return video size as CGSize
  192. */
  193. @property (NS_NONATOMIC_IOSONLY, readonly) CGSize videoSize;
  194. /**
  195. * Does the current media have a video output?
  196. * \note a false return value doesn't mean that the video doesn't have any video
  197. * \note tracks. Those might just be disabled.
  198. * \return current video output status
  199. */
  200. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL hasVideoOut;
  201. /**
  202. * Frames per second
  203. * \return current media's frames per second value
  204. */
  205. @property (NS_NONATOMIC_IOSONLY, readonly) float framesPerSecond;
  206. #pragma mark -
  207. #pragma mark time
  208. /**
  209. * Sets the current position (or time) of the feed.
  210. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  211. */
  212. /**
  213. * Returns the current position (or time) of the feed.
  214. * \return VLCTIme object with current time.
  215. */
  216. @property (NS_NONATOMIC_IOSONLY, strong) VLCTime *time;
  217. @property (nonatomic, readonly, weak) VLCTime *remainingTime;
  218. /**
  219. * Frames per second
  220. * \note this property is deprecated. use (float)fps instead.
  221. * \return current media's frames per second value
  222. */
  223. @property (readonly) NSUInteger fps __attribute__((deprecated));
  224. #pragma mark -
  225. #pragma mark ES track handling
  226. /**
  227. * Return the current video track index
  228. * Note that the handled values do not match the videoTracks array indexes
  229. * but refer to videoSubTitlesIndexes.
  230. * \return 0 if none is set.
  231. *
  232. * Pass -1 to disable.
  233. */
  234. @property (readwrite) NSUInteger currentVideoTrackIndex;
  235. /**
  236. * Returns the video track names, usually a language name or a description
  237. * It includes the "Disabled" fake track at index 0.
  238. */
  239. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackNames;
  240. /**
  241. * Returns the video track IDs
  242. * those are needed to set the video index
  243. */
  244. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackIndexes;
  245. /**
  246. * Return the video tracks
  247. *
  248. * It includes the disabled fake track at index 0.
  249. */
  250. - (NSArray *)videoTracks __attribute__((deprecated));
  251. /**
  252. * Return the current video subtitle index
  253. * Note that the handled values do not match the videoSubTitles array indexes
  254. * but refer to videoSubTitlesIndexes
  255. * \return 0 if none is set.
  256. *
  257. * Pass -1 to disable.
  258. */
  259. @property (readwrite) NSUInteger currentVideoSubTitleIndex;
  260. /**
  261. * Returns the video subtitle track names, usually a language name or a description
  262. * It includes the "Disabled" fake track at index 0.
  263. */
  264. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesNames;
  265. /**
  266. * Returns the video subtitle track IDs
  267. * those are needed to set the video subtitle index
  268. */
  269. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesIndexes;
  270. /**
  271. * Return the video subtitle tracks
  272. * \note this property is deprecated. use (NSArray *)videoSubtitleNames instead.
  273. * It includes the disabled fake track at index 0.
  274. */
  275. - (NSArray *)videoSubTitles __attribute__((deprecated));
  276. /**
  277. * Load and set a specific video subtitle, from a file.
  278. * \param path to a file
  279. * \return if the call succeed..
  280. */
  281. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  282. /**
  283. * Get the current subtitle delay. Positive values means subtitles are being
  284. * displayed later, negative values earlier.
  285. *
  286. * \return time (in microseconds) the display of subtitles is being delayed
  287. */
  288. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  289. /**
  290. * Chapter selection and enumeration, it is bound
  291. * to a title option.
  292. */
  293. /**
  294. * Return the current video subtitle index, or
  295. * \return NSNotFound if none is set.
  296. *
  297. * To disable subtitle pass NSNotFound.
  298. */
  299. @property (readwrite) int currentChapterIndex;
  300. - (void)previousChapter;
  301. - (void)nextChapter;
  302. - (NSArray *)chaptersForTitleIndex:(int)titleIndex;
  303. /**
  304. * Title selection and enumeration
  305. * \return NSNotFound if none is set.
  306. */
  307. @property (readwrite) NSUInteger currentTitleIndex;
  308. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titles;
  309. /* Audio Options */
  310. /**
  311. * Return the current audio track index
  312. * Note that the handled values do not match the audioTracks array indexes
  313. * but refer to audioTrackIndexes.
  314. * \return 0 if none is set.
  315. *
  316. * Pass -1 to disable.
  317. */
  318. @property (readwrite) NSUInteger currentAudioTrackIndex;
  319. /**
  320. * Returns the audio track names, usually a language name or a description
  321. * It includes the "Disabled" fake track at index 0.
  322. */
  323. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackNames;
  324. /**
  325. * Returns the audio track IDs
  326. * those are needed to set the video index
  327. */
  328. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackIndexes;
  329. /**
  330. * Return the audio tracks
  331. *
  332. * It includes the "Disable" fake track at index 0.
  333. */
  334. - (NSArray *)audioTracks __attribute__((deprecated));
  335. #pragma mark -
  336. #pragma mark audio functionality
  337. @property (NS_NONATOMIC_IOSONLY) int audioChannel;
  338. /**
  339. * Get the current audio delay. Positive values means audio is delayed further,
  340. * negative values less.
  341. *
  342. * \return time (in microseconds) the audio playback is being delayed
  343. */
  344. @property (readwrite) NSInteger currentAudioPlaybackDelay;
  345. #pragma mark -
  346. #pragma mark equalizer
  347. /**
  348. * Get a list of available equalizer profiles
  349. * \Note Current versions do not allow the addition of further profiles
  350. * so you need to handle this in your app.
  351. *
  352. * \return array of equalizer profiles
  353. */
  354. @property (weak, readonly) NSArray *equalizerProfiles;
  355. /**
  356. * Re-set the equalizer to a profile retrieved from the list
  357. * \Note This doesn't enable the Equalizer automagically
  358. */
  359. - (void)resetEqualizerFromProfile:(unsigned)profile;
  360. /**
  361. * Toggle equalizer state
  362. * \param bool value to enable/disable the equalizer
  363. * \return current state */
  364. @property (readwrite) BOOL equalizerEnabled;
  365. /**
  366. * Set amplification level
  367. * \param The supplied amplification value will be clamped to the -20.0 to +20.0 range.
  368. * \note this will create and enabled an Equalizer instance if not present
  369. * \return current amplification level */
  370. @property (readwrite) CGFloat preAmplification;
  371. /**
  372. * Number of equalizer bands
  373. * \return the number of equalizer bands available in the current release */
  374. @property (readonly) unsigned numberOfBands;
  375. /**
  376. * frequency of equalizer band
  377. * \return frequency of the requested equalizer band */
  378. - (CGFloat)frequencyOfBandAtIndex:(unsigned)index;
  379. /**
  380. * set amplification for band
  381. * \param amplification value (clamped to the -20.0 to +20.0 range)
  382. * \param index of the respective band */
  383. - (void)setAmplification:(CGFloat)amplification forBand:(unsigned)index;
  384. /**
  385. * amplification of band
  386. * \param index of the band
  387. * \return current amplification value (clamped to the -20.0 to +20.0 range) */
  388. - (CGFloat)amplificationOfBand:(unsigned)index;
  389. #pragma mark -
  390. #pragma mark media handling
  391. /* Media Options */
  392. @property (NS_NONATOMIC_IOSONLY, strong) VLCMedia *media;
  393. #pragma mark -
  394. #pragma mark playback operations
  395. /**
  396. * Plays a media resource using the currently selected media controller (or
  397. * default controller. If feed was paused then the feed resumes at the position
  398. * it was paused in.
  399. * \return A Boolean determining whether the stream was played or not.
  400. */
  401. -(BOOL)play;
  402. /**
  403. * Toggle's the pause state of the feed.
  404. */
  405. - (void)pause;
  406. /**
  407. * Stop the playing.
  408. */
  409. - (void)stop;
  410. /**
  411. * Advance one frame.
  412. */
  413. - (void)gotoNextFrame;
  414. /**
  415. * Fast forwards through the feed at the standard 1x rate.
  416. */
  417. - (void)fastForward;
  418. /**
  419. * Fast forwards through the feed at the rate specified.
  420. * \param rate Rate at which the feed should be fast forwarded.
  421. */
  422. - (void)fastForwardAtRate:(float)rate;
  423. /**
  424. * Rewinds through the feed at the standard 1x rate.
  425. */
  426. - (void)rewind;
  427. /**
  428. * Rewinds through the feed at the rate specified.
  429. * \param rate Rate at which the feed should be fast rewound.
  430. */
  431. - (void)rewindAtRate:(float)rate;
  432. /**
  433. * Jumps shortly backward in current stream if seeking is supported.
  434. * \param interval to skip, in sec.
  435. */
  436. - (void)jumpBackward:(int)interval;
  437. /**
  438. * Jumps shortly forward in current stream if seeking is supported.
  439. * \param interval to skip, in sec.
  440. */
  441. - (void)jumpForward:(int)interval;
  442. /**
  443. * Jumps shortly backward in current stream if seeking is supported.
  444. */
  445. - (void)extraShortJumpBackward;
  446. /**
  447. * Jumps shortly forward in current stream if seeking is supported.
  448. */
  449. - (void)extraShortJumpForward;
  450. /**
  451. * Jumps shortly backward in current stream if seeking is supported.
  452. */
  453. - (void)shortJumpBackward;
  454. /**
  455. * Jumps shortly forward in current stream if seeking is supported.
  456. */
  457. - (void)shortJumpForward;
  458. /**
  459. * Jumps shortly backward in current stream if seeking is supported.
  460. */
  461. - (void)mediumJumpBackward;
  462. /**
  463. * Jumps shortly forward in current stream if seeking is supported.
  464. */
  465. - (void)mediumJumpForward;
  466. /**
  467. * Jumps shortly backward in current stream if seeking is supported.
  468. */
  469. - (void)longJumpBackward;
  470. /**
  471. * Jumps shortly forward in current stream if seeking is supported.
  472. */
  473. - (void)longJumpForward;
  474. #pragma mark -
  475. #pragma mark playback information
  476. /**
  477. * Playback state flag identifying that the stream is currently playing.
  478. * \return TRUE if the feed is playing, FALSE if otherwise.
  479. */
  480. @property (NS_NONATOMIC_IOSONLY, getter=isPlaying, readonly) BOOL playing;
  481. /**
  482. * Playback state flag identifying wheather the stream will play.
  483. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  484. */
  485. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL willPlay;
  486. /**
  487. * Playback's current state.
  488. * \see VLCMediaState
  489. */
  490. @property (NS_NONATOMIC_IOSONLY, readonly) VLCMediaPlayerState state;
  491. /**
  492. * Returns the receiver's position in the reading.
  493. * \return movie position as percentage between 0.0 and 1.0.
  494. */
  495. @property (NS_NONATOMIC_IOSONLY) float position;
  496. /**
  497. * Set movie position. This has no effect if playback is not enabled.
  498. * \param movie position as percentage between 0.0 and 1.0.
  499. */
  500. @property (NS_NONATOMIC_IOSONLY, getter=isSeekable, readonly) BOOL seekable;
  501. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL canPause;
  502. @end