VLCMediaPlayer.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. - (instancetype)initWithLibVLCInstance:(void *)playerInstance andLibrary:(VLCLibrary *)library;
  90. /* Video View Options */
  91. // TODO: Should be it's own object?
  92. #pragma mark -
  93. #pragma mark video functionality
  94. #if !TARGET_OS_IPHONE
  95. - (void)setVideoView:(VLCVideoView *)aVideoView;
  96. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  97. #endif
  98. @property (strong) id drawable; /* The videoView or videoLayer */
  99. /**
  100. * Set/Get current video aspect ratio.
  101. *
  102. * \param psz_aspect new video aspect-ratio or NULL to reset to default
  103. * \note Invalid aspect ratios are ignored.
  104. * \return the video aspect ratio or NULL if unspecified
  105. * (the result must be released with free()).
  106. */
  107. @property (NS_NONATOMIC_IOSONLY) char *videoAspectRatio;
  108. /**
  109. * Set/Get current crop filter geometry.
  110. *
  111. * \param psz_geometry new crop filter geometry (NULL to unset)
  112. * \return the crop filter geometry or NULL if unset
  113. */
  114. @property (NS_NONATOMIC_IOSONLY) char *videoCropGeometry;
  115. /**
  116. * Set/Get the current video scaling factor.
  117. * That is the ratio of the number of pixels on
  118. * screen to the number of pixels in the original decoded video in each
  119. * dimension. Zero is a special value; it will adjust the video to the output
  120. * window/drawable (in windowed mode) or the entire screen.
  121. *
  122. * \param relative scale factor as float
  123. */
  124. @property (nonatomic) float scaleFactor;
  125. /**
  126. * Take a snapshot of the current video.
  127. *
  128. * If width AND height is 0, original size is used.
  129. * If width OR height is 0, original aspect-ratio is preserved.
  130. *
  131. * \param path the path where to save the screenshot to
  132. * \param width the snapshot's width
  133. * \param height the snapshot's height
  134. */
  135. - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(int)width andHeight:(int)height;
  136. /**
  137. * Enable or disable deinterlace filter
  138. *
  139. * \param name of deinterlace filter to use (availability depends on underlying VLC version), NULL to disable.
  140. */
  141. - (void)setDeinterlaceFilter: (NSString *)name;
  142. /**
  143. * Enable or disable adjust video filter (contrast, brightness, hue, saturation, gamma)
  144. *
  145. * \param bool value
  146. */
  147. @property (nonatomic) BOOL adjustFilterEnabled;
  148. /**
  149. * Set/Get the adjust filter's contrast value
  150. *
  151. * \param float value (range: 0-2, default: 1.0)
  152. */
  153. @property (nonatomic) float contrast;
  154. /**
  155. * Set/Get the adjust filter's brightness value
  156. *
  157. * \param float value (range: 0-2, default: 1.0)
  158. */
  159. @property (nonatomic) float brightness;
  160. /**
  161. * Set/Get the adjust filter's hue value
  162. *
  163. * \param integer value (range: 0-360, default: 0)
  164. */
  165. @property (nonatomic) int hue;
  166. /**
  167. * Set/Get the adjust filter's saturation value
  168. *
  169. * \param float value (range: 0-3, default: 1.0)
  170. */
  171. @property (nonatomic) float saturation;
  172. /**
  173. * Set/Get the adjust filter's gamma value
  174. *
  175. * \param float value (range: 0-10, default: 1.0)
  176. */
  177. @property (nonatomic) float gamma;
  178. /**
  179. * Get the requested movie play rate.
  180. * @warning Depending on the underlying media, the requested rate may be
  181. * different from the real playback rate. Due to limitations of some protocols
  182. * this option may not be taken into account at all, if set.
  183. * \param rate movie play rate to set
  184. *
  185. * \return movie play rate
  186. */
  187. @property (nonatomic) float rate;
  188. @property (nonatomic, readonly, weak) VLCAudio * audio;
  189. /* Video Information */
  190. /**
  191. * Get the current video size
  192. * \return video size as CGSize
  193. */
  194. @property (NS_NONATOMIC_IOSONLY, readonly) CGSize videoSize;
  195. /**
  196. * Does the current media have a video output?
  197. * \note a false return value doesn't mean that the video doesn't have any video
  198. * \note tracks. Those might just be disabled.
  199. * \return current video output status
  200. */
  201. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL hasVideoOut;
  202. /**
  203. * Frames per second
  204. * \return current media's frames per second value
  205. */
  206. @property (NS_NONATOMIC_IOSONLY, readonly) float framesPerSecond;
  207. #pragma mark -
  208. #pragma mark time
  209. /**
  210. * Sets the current position (or time) of the feed.
  211. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  212. */
  213. /**
  214. * Returns the current position (or time) of the feed.
  215. * \return VLCTIme object with current time.
  216. */
  217. @property (NS_NONATOMIC_IOSONLY, strong) VLCTime *time;
  218. @property (nonatomic, readonly, weak) VLCTime *remainingTime;
  219. #pragma mark -
  220. #pragma mark ES track handling
  221. /**
  222. * Return the current video track index
  223. *
  224. * \return 0 if none is set.
  225. *
  226. * Pass -1 to disable.
  227. */
  228. @property (readwrite) int currentVideoTrackIndex;
  229. /**
  230. * Returns the video track names, usually a language name or a description
  231. * It includes the "Disabled" fake track at index 0.
  232. */
  233. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackNames;
  234. /**
  235. * Returns the video track IDs
  236. * those are needed to set the video index
  237. */
  238. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackIndexes;
  239. /**
  240. * returns the number of video tracks available in the current media
  241. * \return number of tracks
  242. */
  243. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfVideoTracks;
  244. /**
  245. * Return the current video subtitle index
  246. *
  247. * \return 0 if none is set.
  248. *
  249. * Pass -1 to disable.
  250. */
  251. @property (readwrite) int currentVideoSubTitleIndex;
  252. /**
  253. * Returns the video subtitle track names, usually a language name or a description
  254. * It includes the "Disabled" fake track at index 0.
  255. */
  256. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesNames;
  257. /**
  258. * Returns the video subtitle track IDs
  259. * those are needed to set the video subtitle index
  260. */
  261. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesIndexes;
  262. /**
  263. * returns the number of SPU tracks available in the current media
  264. * \return number of tracks
  265. */
  266. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfSubtitlesTracks;
  267. /**
  268. * Load and set a specific video subtitle, from a file.
  269. * \param path to a file
  270. * \return if the call succeed..
  271. */
  272. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  273. /**
  274. * Get the current subtitle delay. Positive values means subtitles are being
  275. * displayed later, negative values earlier.
  276. *
  277. * \return time (in microseconds) the display of subtitles is being delayed
  278. */
  279. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  280. /**
  281. * Chapter selection and enumeration, it is bound
  282. * to a title option.
  283. */
  284. /**
  285. * Return the current video subtitle index, or
  286. * \return NSNotFound if none is set.
  287. *
  288. * To disable subtitle pass NSNotFound.
  289. */
  290. @property (readwrite) int currentChapterIndex;
  291. - (void)previousChapter;
  292. - (void)nextChapter;
  293. - (int)numberOfChaptersForTitle:(int)titleIndex;
  294. - (NSArray *)chaptersForTitleIndex:(int)titleIndex __attribute__((deprecated));
  295. extern NSString *const VLCChapterDescriptionName;
  296. extern NSString *const VLCChapterDescriptionTimeOffset;
  297. extern NSString *const VLCChapterDescriptionDuration;
  298. /**
  299. * chapter descriptions
  300. * an array of all chapters of the given title including information about
  301. * chapter name, time offset and duration
  302. * \note if no title value is provided, information about the chapters of the current title is returned
  303. * \return array describing the titles in details
  304. */
  305. - (NSArray *)chapterDescriptionsOfTitle:(int)titleIndex;
  306. /**
  307. * Title selection and enumeration
  308. * \return NSNotFound if none is set.
  309. */
  310. @property (readwrite) int currentTitleIndex;
  311. @property (readonly) int numberOfTitles;
  312. @property (readonly) NSUInteger countOfTitles __attribute__((deprecated));
  313. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titles __attribute__((deprecated));
  314. extern NSString *const VLCTitleDescriptionName;
  315. extern NSString *const VLCTitleDescriptionDuration;
  316. extern NSString *const VLCTitleDescriptionIsMenu;
  317. /**
  318. * title descriptions
  319. * an array of all titles of the current media including information
  320. * of name, duration and potential menu state
  321. * \return array describing the titles in details
  322. */
  323. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titleDescriptions;
  324. /**
  325. * the title with the longest duration
  326. * \return int matching the title index
  327. */
  328. @property (readonly) int indexOfLongestTitle;
  329. /* Audio Options */
  330. /**
  331. * Return the current audio track index
  332. *
  333. * \return 0 if none is set.
  334. *
  335. * Pass -1 to disable.
  336. */
  337. @property (readwrite) int currentAudioTrackIndex;
  338. /**
  339. * Returns the audio track names, usually a language name or a description
  340. * It includes the "Disabled" fake track at index 0.
  341. */
  342. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackNames;
  343. /**
  344. * Returns the audio track IDs
  345. * those are needed to set the video index
  346. */
  347. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackIndexes;
  348. /**
  349. * returns the number of audio tracks available in the current media
  350. * \return number of tracks
  351. */
  352. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfAudioTracks;
  353. #pragma mark -
  354. #pragma mark audio functionality
  355. @property (NS_NONATOMIC_IOSONLY) int audioChannel;
  356. /**
  357. * Get the current audio delay. Positive values means audio is delayed further,
  358. * negative values less.
  359. *
  360. * \return time (in microseconds) the audio playback is being delayed
  361. */
  362. @property (readwrite) NSInteger currentAudioPlaybackDelay;
  363. #pragma mark -
  364. #pragma mark equalizer
  365. /**
  366. * Get a list of available equalizer profiles
  367. * \Note Current versions do not allow the addition of further profiles
  368. * so you need to handle this in your app.
  369. *
  370. * \return array of equalizer profiles
  371. */
  372. @property (weak, readonly) NSArray *equalizerProfiles;
  373. /**
  374. * Re-set the equalizer to a profile retrieved from the list
  375. * \Note This doesn't enable the Equalizer automagically
  376. */
  377. - (void)resetEqualizerFromProfile:(unsigned)profile;
  378. /**
  379. * Toggle equalizer state
  380. * \param bool value to enable/disable the equalizer
  381. * \return current state */
  382. @property (readwrite) BOOL equalizerEnabled;
  383. /**
  384. * Set amplification level
  385. * \param The supplied amplification value will be clamped to the -20.0 to +20.0 range.
  386. * \note this will create and enabled an Equalizer instance if not present
  387. * \return current amplification level */
  388. @property (readwrite) CGFloat preAmplification;
  389. /**
  390. * Number of equalizer bands
  391. * \return the number of equalizer bands available in the current release */
  392. @property (readonly) unsigned numberOfBands;
  393. /**
  394. * frequency of equalizer band
  395. * \return frequency of the requested equalizer band */
  396. - (CGFloat)frequencyOfBandAtIndex:(unsigned)index;
  397. /**
  398. * set amplification for band
  399. * \param amplification value (clamped to the -20.0 to +20.0 range)
  400. * \param index of the respective band */
  401. - (void)setAmplification:(CGFloat)amplification forBand:(unsigned)index;
  402. /**
  403. * amplification of band
  404. * \param index of the band
  405. * \return current amplification value (clamped to the -20.0 to +20.0 range) */
  406. - (CGFloat)amplificationOfBand:(unsigned)index;
  407. #pragma mark -
  408. #pragma mark media handling
  409. /* Media Options */
  410. @property (NS_NONATOMIC_IOSONLY, strong) VLCMedia *media;
  411. #pragma mark -
  412. #pragma mark playback operations
  413. /**
  414. * Plays a media resource using the currently selected media controller (or
  415. * default controller. If feed was paused then the feed resumes at the position
  416. * it was paused in.
  417. * \return A Boolean determining whether the stream was played or not.
  418. */
  419. -(BOOL)play;
  420. /**
  421. * Toggle's the pause state of the feed.
  422. */
  423. - (void)pause;
  424. /**
  425. * Stop the playing.
  426. */
  427. - (void)stop;
  428. /**
  429. * Advance one frame.
  430. */
  431. - (void)gotoNextFrame;
  432. /**
  433. * Fast forwards through the feed at the standard 1x rate.
  434. */
  435. - (void)fastForward;
  436. /**
  437. * Fast forwards through the feed at the rate specified.
  438. * \param rate Rate at which the feed should be fast forwarded.
  439. */
  440. - (void)fastForwardAtRate:(float)rate;
  441. /**
  442. * Rewinds through the feed at the standard 1x rate.
  443. */
  444. - (void)rewind;
  445. /**
  446. * Rewinds through the feed at the rate specified.
  447. * \param rate Rate at which the feed should be fast rewound.
  448. */
  449. - (void)rewindAtRate:(float)rate;
  450. /**
  451. * Jumps shortly backward in current stream if seeking is supported.
  452. * \param interval to skip, in sec.
  453. */
  454. - (void)jumpBackward:(int)interval;
  455. /**
  456. * Jumps shortly forward in current stream if seeking is supported.
  457. * \param interval to skip, in sec.
  458. */
  459. - (void)jumpForward:(int)interval;
  460. /**
  461. * Jumps shortly backward in current stream if seeking is supported.
  462. */
  463. - (void)extraShortJumpBackward;
  464. /**
  465. * Jumps shortly forward in current stream if seeking is supported.
  466. */
  467. - (void)extraShortJumpForward;
  468. /**
  469. * Jumps shortly backward in current stream if seeking is supported.
  470. */
  471. - (void)shortJumpBackward;
  472. /**
  473. * Jumps shortly forward in current stream if seeking is supported.
  474. */
  475. - (void)shortJumpForward;
  476. /**
  477. * Jumps shortly backward in current stream if seeking is supported.
  478. */
  479. - (void)mediumJumpBackward;
  480. /**
  481. * Jumps shortly forward in current stream if seeking is supported.
  482. */
  483. - (void)mediumJumpForward;
  484. /**
  485. * Jumps shortly backward in current stream if seeking is supported.
  486. */
  487. - (void)longJumpBackward;
  488. /**
  489. * Jumps shortly forward in current stream if seeking is supported.
  490. */
  491. - (void)longJumpForward;
  492. #pragma mark -
  493. #pragma mark playback information
  494. /**
  495. * Playback state flag identifying that the stream is currently playing.
  496. * \return TRUE if the feed is playing, FALSE if otherwise.
  497. */
  498. @property (NS_NONATOMIC_IOSONLY, getter=isPlaying, readonly) BOOL playing;
  499. /**
  500. * Playback state flag identifying wheather the stream will play.
  501. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  502. */
  503. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL willPlay;
  504. /**
  505. * Playback's current state.
  506. * \see VLCMediaState
  507. */
  508. @property (NS_NONATOMIC_IOSONLY, readonly) VLCMediaPlayerState state;
  509. /**
  510. * Returns the receiver's position in the reading.
  511. * \return movie position as percentage between 0.0 and 1.0.
  512. */
  513. @property (NS_NONATOMIC_IOSONLY) float position;
  514. /**
  515. * Set movie position. This has no effect if playback is not enabled.
  516. * \param movie position as percentage between 0.0 and 1.0.
  517. */
  518. @property (NS_NONATOMIC_IOSONLY, getter=isSeekable, readonly) BOOL seekable;
  519. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL canPause;
  520. #if TARGET_OS_IPHONE
  521. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *snapshots;
  522. /**
  523. * Get last snapshot available.
  524. * \return an UIImage with the last snapshot available.
  525. * \note return value is nil if there is no snapshot
  526. */
  527. @property (NS_NONATOMIC_IOSONLY, readonly) UIImage *lastSnapshot;
  528. #endif
  529. @end