VLCMediaPlayer.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*****************************************************************************
  2. * VLCMediaPlayer.h: VLCKit.framework VLCMediaPlayer header
  3. *****************************************************************************
  4. * Copyright (C) 2007-2009 Pierre d'Herbemont
  5. * Copyright (C) 2007-2015 VLC authors and VideoLAN
  6. * Copyright (C) 2009-2015 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) int 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. * returns the number of video tracks available in the current media
  247. * \return number of tracks
  248. */
  249. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfVideoTracks;
  250. /**
  251. * Return the video tracks
  252. *
  253. * It includes the disabled fake track at index 0.
  254. */
  255. - (NSArray *)videoTracks __attribute__((deprecated));
  256. /**
  257. * Return the current video subtitle index
  258. * Note that the handled values do not match the videoSubTitles array indexes
  259. * but refer to videoSubTitlesIndexes
  260. * \return 0 if none is set.
  261. *
  262. * Pass -1 to disable.
  263. */
  264. @property (readwrite) int currentVideoSubTitleIndex;
  265. /**
  266. * Returns the video subtitle track names, usually a language name or a description
  267. * It includes the "Disabled" fake track at index 0.
  268. */
  269. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesNames;
  270. /**
  271. * Returns the video subtitle track IDs
  272. * those are needed to set the video subtitle index
  273. */
  274. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesIndexes;
  275. /**
  276. * returns the number of SPU tracks available in the current media
  277. * \return number of tracks
  278. */
  279. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfSubtitlesTracks;
  280. /**
  281. * Return the video subtitle tracks
  282. * \note this property is deprecated. use (NSArray *)videoSubtitleNames instead.
  283. * It includes the disabled fake track at index 0.
  284. */
  285. - (NSArray *)videoSubTitles __attribute__((deprecated));
  286. /**
  287. * Load and set a specific video subtitle, from a file.
  288. * \param path to a file
  289. * \return if the call succeed..
  290. */
  291. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  292. /**
  293. * Get the current subtitle delay. Positive values means subtitles are being
  294. * displayed later, negative values earlier.
  295. *
  296. * \return time (in microseconds) the display of subtitles is being delayed
  297. */
  298. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  299. /**
  300. * Chapter selection and enumeration, it is bound
  301. * to a title option.
  302. */
  303. /**
  304. * Return the current video subtitle index, or
  305. * \return NSNotFound if none is set.
  306. *
  307. * To disable subtitle pass NSNotFound.
  308. */
  309. @property (readwrite) int currentChapterIndex;
  310. - (void)previousChapter;
  311. - (void)nextChapter;
  312. - (int)numberOfChaptersForTitle:(int)titleIndex;
  313. - (NSArray *)chaptersForTitleIndex:(int)titleIndex __attribute__((deprecated));
  314. extern NSString *const VLCChapterDescriptionName;
  315. extern NSString *const VLCChapterDescriptionTimeOffset;
  316. extern NSString *const VLCChapterDescriptionDuration;
  317. /**
  318. * chapter descriptions
  319. * an array of all chapters of the given title including information about
  320. * chapter name, time offset and duration
  321. * \note if no title value is provided, information about the chapters of the current title is returned
  322. * \return array describing the titles in details
  323. */
  324. - (NSArray *)chapterDescriptionsOfTitle:(int)titleIndex;
  325. /**
  326. * Title selection and enumeration
  327. * \return NSNotFound if none is set.
  328. */
  329. @property (readwrite) int currentTitleIndex;
  330. @property (readonly) int numberOfTitles;
  331. @property (readonly) NSUInteger countOfTitles __attribute__((deprecated));
  332. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titles __attribute__((deprecated));
  333. extern NSString *const VLCTitleDescriptionName;
  334. extern NSString *const VLCTitleDescriptionDuration;
  335. extern NSString *const VLCTitleDescriptionIsMenu;
  336. /**
  337. * title descriptions
  338. * an array of all titles of the current media including information
  339. * of name, duration and potential menu state
  340. * \return array describing the titles in details
  341. */
  342. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titleDescriptions;
  343. /**
  344. * the title with the longest duration
  345. * \return int matching the title index
  346. */
  347. @property (readonly) int indexOfLongestTitle;
  348. /* Audio Options */
  349. /**
  350. * Return the current audio track index
  351. * Note that the handled values do not match the audioTracks array indexes
  352. * but refer to audioTrackIndexes.
  353. * \return 0 if none is set.
  354. *
  355. * Pass -1 to disable.
  356. */
  357. @property (readwrite) int currentAudioTrackIndex;
  358. /**
  359. * Returns the audio track names, usually a language name or a description
  360. * It includes the "Disabled" fake track at index 0.
  361. */
  362. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackNames;
  363. /**
  364. * Returns the audio track IDs
  365. * those are needed to set the video index
  366. */
  367. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackIndexes;
  368. /**
  369. * returns the number of audio tracks available in the current media
  370. * \return number of tracks
  371. */
  372. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfAudioTracks;
  373. /**
  374. * Return the audio tracks
  375. *
  376. * It includes the "Disable" fake track at index 0.
  377. */
  378. - (NSArray *)audioTracks __attribute__((deprecated));
  379. #pragma mark -
  380. #pragma mark audio functionality
  381. @property (NS_NONATOMIC_IOSONLY) int audioChannel;
  382. /**
  383. * Get the current audio delay. Positive values means audio is delayed further,
  384. * negative values less.
  385. *
  386. * \return time (in microseconds) the audio playback is being delayed
  387. */
  388. @property (readwrite) NSInteger currentAudioPlaybackDelay;
  389. #pragma mark -
  390. #pragma mark equalizer
  391. /**
  392. * Get a list of available equalizer profiles
  393. * \Note Current versions do not allow the addition of further profiles
  394. * so you need to handle this in your app.
  395. *
  396. * \return array of equalizer profiles
  397. */
  398. @property (weak, readonly) NSArray *equalizerProfiles;
  399. /**
  400. * Re-set the equalizer to a profile retrieved from the list
  401. * \Note This doesn't enable the Equalizer automagically
  402. */
  403. - (void)resetEqualizerFromProfile:(unsigned)profile;
  404. /**
  405. * Toggle equalizer state
  406. * \param bool value to enable/disable the equalizer
  407. * \return current state */
  408. @property (readwrite) BOOL equalizerEnabled;
  409. /**
  410. * Set amplification level
  411. * \param The supplied amplification value will be clamped to the -20.0 to +20.0 range.
  412. * \note this will create and enabled an Equalizer instance if not present
  413. * \return current amplification level */
  414. @property (readwrite) CGFloat preAmplification;
  415. /**
  416. * Number of equalizer bands
  417. * \return the number of equalizer bands available in the current release */
  418. @property (readonly) unsigned numberOfBands;
  419. /**
  420. * frequency of equalizer band
  421. * \return frequency of the requested equalizer band */
  422. - (CGFloat)frequencyOfBandAtIndex:(unsigned)index;
  423. /**
  424. * set amplification for band
  425. * \param amplification value (clamped to the -20.0 to +20.0 range)
  426. * \param index of the respective band */
  427. - (void)setAmplification:(CGFloat)amplification forBand:(unsigned)index;
  428. /**
  429. * amplification of band
  430. * \param index of the band
  431. * \return current amplification value (clamped to the -20.0 to +20.0 range) */
  432. - (CGFloat)amplificationOfBand:(unsigned)index;
  433. #pragma mark -
  434. #pragma mark media handling
  435. /* Media Options */
  436. @property (NS_NONATOMIC_IOSONLY, strong) VLCMedia *media;
  437. #pragma mark -
  438. #pragma mark playback operations
  439. /**
  440. * Plays a media resource using the currently selected media controller (or
  441. * default controller. If feed was paused then the feed resumes at the position
  442. * it was paused in.
  443. * \return A Boolean determining whether the stream was played or not.
  444. */
  445. -(BOOL)play;
  446. /**
  447. * Toggle's the pause state of the feed.
  448. */
  449. - (void)pause;
  450. /**
  451. * Stop the playing.
  452. */
  453. - (void)stop;
  454. /**
  455. * Advance one frame.
  456. */
  457. - (void)gotoNextFrame;
  458. /**
  459. * Fast forwards through the feed at the standard 1x rate.
  460. */
  461. - (void)fastForward;
  462. /**
  463. * Fast forwards through the feed at the rate specified.
  464. * \param rate Rate at which the feed should be fast forwarded.
  465. */
  466. - (void)fastForwardAtRate:(float)rate;
  467. /**
  468. * Rewinds through the feed at the standard 1x rate.
  469. */
  470. - (void)rewind;
  471. /**
  472. * Rewinds through the feed at the rate specified.
  473. * \param rate Rate at which the feed should be fast rewound.
  474. */
  475. - (void)rewindAtRate:(float)rate;
  476. /**
  477. * Jumps shortly backward in current stream if seeking is supported.
  478. * \param interval to skip, in sec.
  479. */
  480. - (void)jumpBackward:(int)interval;
  481. /**
  482. * Jumps shortly forward in current stream if seeking is supported.
  483. * \param interval to skip, in sec.
  484. */
  485. - (void)jumpForward:(int)interval;
  486. /**
  487. * Jumps shortly backward in current stream if seeking is supported.
  488. */
  489. - (void)extraShortJumpBackward;
  490. /**
  491. * Jumps shortly forward in current stream if seeking is supported.
  492. */
  493. - (void)extraShortJumpForward;
  494. /**
  495. * Jumps shortly backward in current stream if seeking is supported.
  496. */
  497. - (void)shortJumpBackward;
  498. /**
  499. * Jumps shortly forward in current stream if seeking is supported.
  500. */
  501. - (void)shortJumpForward;
  502. /**
  503. * Jumps shortly backward in current stream if seeking is supported.
  504. */
  505. - (void)mediumJumpBackward;
  506. /**
  507. * Jumps shortly forward in current stream if seeking is supported.
  508. */
  509. - (void)mediumJumpForward;
  510. /**
  511. * Jumps shortly backward in current stream if seeking is supported.
  512. */
  513. - (void)longJumpBackward;
  514. /**
  515. * Jumps shortly forward in current stream if seeking is supported.
  516. */
  517. - (void)longJumpForward;
  518. #pragma mark -
  519. #pragma mark playback information
  520. /**
  521. * Playback state flag identifying that the stream is currently playing.
  522. * \return TRUE if the feed is playing, FALSE if otherwise.
  523. */
  524. @property (NS_NONATOMIC_IOSONLY, getter=isPlaying, readonly) BOOL playing;
  525. /**
  526. * Playback state flag identifying wheather the stream will play.
  527. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  528. */
  529. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL willPlay;
  530. /**
  531. * Playback's current state.
  532. * \see VLCMediaState
  533. */
  534. @property (NS_NONATOMIC_IOSONLY, readonly) VLCMediaPlayerState state;
  535. /**
  536. * Returns the receiver's position in the reading.
  537. * \return movie position as percentage between 0.0 and 1.0.
  538. */
  539. @property (NS_NONATOMIC_IOSONLY) float position;
  540. /**
  541. * Set movie position. This has no effect if playback is not enabled.
  542. * \param movie position as percentage between 0.0 and 1.0.
  543. */
  544. @property (NS_NONATOMIC_IOSONLY, getter=isSeekable, readonly) BOOL seekable;
  545. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL canPause;
  546. @end