VLCMediaPlayer.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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. # import <UIKit/UIKit.h>
  30. #endif
  31. #import "VLCMedia.h"
  32. #import "VLCTime.h"
  33. #import "VLCAudio.h"
  34. #if !TARGET_OS_IPHONE
  35. @class VLCVideoView;
  36. @class VLCVideoLayer;
  37. #endif
  38. @class VLCLibrary;
  39. /* Notification Messages */
  40. extern NSString *const VLCMediaPlayerTimeChanged;
  41. extern NSString *const VLCMediaPlayerStateChanged;
  42. extern NSString *const VLCMediaPlayerTitleChanged;
  43. extern NSString *const VLCMediaPlayerChapterChanged;
  44. /**
  45. * VLCMediaPlayerState describes the state of the media player.
  46. */
  47. typedef NS_ENUM(NSInteger, VLCMediaPlayerState)
  48. {
  49. VLCMediaPlayerStateStopped, //< Player has stopped
  50. VLCMediaPlayerStateOpening, //< Stream is opening
  51. VLCMediaPlayerStateBuffering, //< Stream is buffering
  52. VLCMediaPlayerStateEnded, //< Stream has ended
  53. VLCMediaPlayerStateError, //< Player has generated an error
  54. VLCMediaPlayerStatePlaying, //< Stream is playing
  55. VLCMediaPlayerStatePaused //< Stream is paused
  56. };
  57. /**
  58. * Returns the name of the player state as a string.
  59. * \param state The player state.
  60. * \return A string containing the name of state. If state is not a valid state, returns nil.
  61. */
  62. extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
  63. /**
  64. * Formal protocol declaration for playback delegates. Allows playback messages
  65. * to be trapped by delegated objects.
  66. */
  67. @protocol VLCMediaPlayerDelegate
  68. @optional
  69. /**
  70. * Sent by the default notification center whenever the player's state has changed.
  71. * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
  72. * the VLCMediaPlayer object in question by sending object to aNotification.
  73. */
  74. - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
  75. /**
  76. * Sent by the default notification center whenever the player's time has changed.
  77. * \details Discussion The value of aNotification is always an VLCMediaPlayerTimeChanged notification. You can retrieve
  78. * the VLCMediaPlayer object in question by sending object to aNotification.
  79. */
  80. - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
  81. /**
  82. * Sent by the default notification center whenever the player's title has changed (if any).
  83. * \details Discussion The value of aNotification is always an VLCMediaPlayerTitleChanged notification. You can retrieve
  84. * the VLCMediaPlayer object in question by sending object to aNotification.
  85. * \note this is about a title in the navigation sense, not about metadata
  86. */
  87. - (void)mediaPlayerTitleChanged:(NSNotification *)aNotification;
  88. /**
  89. * Sent by the default notification center whenever the player's chapter has changed (if any).
  90. * \details Discussion The value of aNotification is always an VLCMediaPlayerChapterChanged notification. You can retrieve
  91. * the VLCMediaPlayer object in question by sending object to aNotification.
  92. */
  93. - (void)mediaPlayerChapterChanged:(NSNotification *)aNotification;
  94. #if TARGET_OS_PHONE
  95. /**
  96. * Sent by the default notification center whenever a new snapshot is taken.
  97. * \details Discussion The value of aNotification is always an VLCMediaPlayerSnapshotTaken notification. You can retrieve
  98. * the VLCMediaPlayer object in question by sending object to aNotification.
  99. */
  100. - (void)mediaPlayerSnapshot:(NSNotification *)aNotification;
  101. #endif
  102. @end
  103. // TODO: Should we use medialist_player or our own flavor of media player?
  104. @interface VLCMediaPlayer : NSObject
  105. @property (nonatomic, readonly) VLCLibrary *libraryInstance;
  106. @property (weak) id<VLCMediaPlayerDelegate> delegate;
  107. #if !TARGET_OS_IPHONE
  108. /* Initializers */
  109. - (instancetype)initWithVideoView:(VLCVideoView *)aVideoView;
  110. - (instancetype)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
  111. #endif
  112. - (instancetype)initWithOptions:(NSArray *)options;
  113. - (instancetype)initWithLibVLCInstance:(void *)playerInstance andLibrary:(VLCLibrary *)library;
  114. /* Video View Options */
  115. // TODO: Should be it's own object?
  116. #pragma mark -
  117. #pragma mark video functionality
  118. #if !TARGET_OS_IPHONE
  119. - (void)setVideoView:(VLCVideoView *)aVideoView;
  120. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  121. #endif
  122. @property (strong) id drawable; /* The videoView or videoLayer */
  123. /**
  124. * Set/Get current video aspect ratio.
  125. *
  126. * \param psz_aspect new video aspect-ratio or NULL to reset to default
  127. * \note Invalid aspect ratios are ignored.
  128. * \return the video aspect ratio or NULL if unspecified
  129. * (the result must be released with free()).
  130. */
  131. @property (NS_NONATOMIC_IOSONLY) char *videoAspectRatio;
  132. /**
  133. * Set/Get current crop filter geometry.
  134. *
  135. * \param psz_geometry new crop filter geometry (NULL to unset)
  136. * \return the crop filter geometry or NULL if unset
  137. */
  138. @property (NS_NONATOMIC_IOSONLY) char *videoCropGeometry;
  139. /**
  140. * Set/Get the current video scaling factor.
  141. * That is the ratio of the number of pixels on
  142. * screen to the number of pixels in the original decoded video in each
  143. * dimension. Zero is a special value; it will adjust the video to the output
  144. * window/drawable (in windowed mode) or the entire screen.
  145. *
  146. * \param relative scale factor as float
  147. */
  148. @property (nonatomic) float scaleFactor;
  149. /**
  150. * Take a snapshot of the current video.
  151. *
  152. * If width AND height is 0, original size is used.
  153. * If width OR height is 0, original aspect-ratio is preserved.
  154. *
  155. * \param path the path where to save the screenshot to
  156. * \param width the snapshot's width
  157. * \param height the snapshot's height
  158. */
  159. - (void)saveVideoSnapshotAt: (NSString *)path withWidth:(int)width andHeight:(int)height;
  160. /**
  161. * Enable or disable deinterlace filter
  162. *
  163. * \param name of deinterlace filter to use (availability depends on underlying VLC version), NULL to disable.
  164. */
  165. - (void)setDeinterlaceFilter: (NSString *)name;
  166. /**
  167. * Enable or disable adjust video filter (contrast, brightness, hue, saturation, gamma)
  168. *
  169. * \param bool value
  170. */
  171. @property (nonatomic) BOOL adjustFilterEnabled;
  172. /**
  173. * Set/Get the adjust filter's contrast value
  174. *
  175. * \param float value (range: 0-2, default: 1.0)
  176. */
  177. @property (nonatomic) float contrast;
  178. /**
  179. * Set/Get the adjust filter's brightness value
  180. *
  181. * \param float value (range: 0-2, default: 1.0)
  182. */
  183. @property (nonatomic) float brightness;
  184. /**
  185. * Set/Get the adjust filter's hue value
  186. *
  187. * \param integer value (range: 0-360, default: 0)
  188. */
  189. @property (nonatomic) int hue;
  190. /**
  191. * Set/Get the adjust filter's saturation value
  192. *
  193. * \param float value (range: 0-3, default: 1.0)
  194. */
  195. @property (nonatomic) float saturation;
  196. /**
  197. * Set/Get the adjust filter's gamma value
  198. *
  199. * \param float value (range: 0-10, default: 1.0)
  200. */
  201. @property (nonatomic) float gamma;
  202. /**
  203. * Get the requested movie play rate.
  204. * @warning Depending on the underlying media, the requested rate may be
  205. * different from the real playback rate. Due to limitations of some protocols
  206. * this option may not be taken into account at all, if set.
  207. * \param rate movie play rate to set
  208. *
  209. * \return movie play rate
  210. */
  211. @property (nonatomic) float rate;
  212. @property (nonatomic, readonly, weak) VLCAudio * audio;
  213. /* Video Information */
  214. /**
  215. * Get the current video size
  216. * \return video size as CGSize
  217. */
  218. @property (NS_NONATOMIC_IOSONLY, readonly) CGSize videoSize;
  219. /**
  220. * Does the current media have a video output?
  221. * \note a false return value doesn't mean that the video doesn't have any video
  222. * \note tracks. Those might just be disabled.
  223. * \return current video output status
  224. */
  225. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL hasVideoOut;
  226. /**
  227. * Frames per second
  228. * \note Deprecated, provided for API compatibility only
  229. * \note To retrieve a media's FPS, use VLCMediaTracksInformationFrameRate.
  230. * \returns 0
  231. */
  232. @property (NS_NONATOMIC_IOSONLY, readonly) float framesPerSecond __attribute__((deprecated));
  233. #pragma mark -
  234. #pragma mark time
  235. /**
  236. * Sets the current position (or time) of the feed.
  237. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  238. */
  239. /**
  240. * Returns the current position (or time) of the feed.
  241. * \return VLCTIme object with current time.
  242. */
  243. @property (NS_NONATOMIC_IOSONLY, strong) VLCTime *time;
  244. @property (nonatomic, readonly, weak) VLCTime *remainingTime;
  245. #pragma mark -
  246. #pragma mark ES track handling
  247. /**
  248. * Return the current video track index
  249. *
  250. * \return 0 if none is set.
  251. *
  252. * Pass -1 to disable.
  253. */
  254. @property (readwrite) int currentVideoTrackIndex;
  255. /**
  256. * Returns the video track names, usually a language name or a description
  257. * It includes the "Disabled" fake track at index 0.
  258. */
  259. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackNames;
  260. /**
  261. * Returns the video track IDs
  262. * those are needed to set the video index
  263. */
  264. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackIndexes;
  265. /**
  266. * returns the number of video tracks available in the current media
  267. * \return number of tracks
  268. */
  269. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfVideoTracks;
  270. /**
  271. * Return the current video subtitle index
  272. *
  273. * \return 0 if none is set.
  274. *
  275. * Pass -1 to disable.
  276. */
  277. @property (readwrite) int currentVideoSubTitleIndex;
  278. /**
  279. * Returns the video subtitle track names, usually a language name or a description
  280. * It includes the "Disabled" fake track at index 0.
  281. */
  282. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesNames;
  283. /**
  284. * Returns the video subtitle track IDs
  285. * those are needed to set the video subtitle index
  286. */
  287. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesIndexes;
  288. /**
  289. * returns the number of SPU tracks available in the current media
  290. * \return number of tracks
  291. */
  292. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfSubtitlesTracks;
  293. /**
  294. * Load and set a specific video subtitle, from a file.
  295. * \param path to a file
  296. * \return if the call succeed..
  297. */
  298. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  299. /**
  300. * Get the current subtitle delay. Positive values means subtitles are being
  301. * displayed later, negative values earlier.
  302. *
  303. * \return time (in microseconds) the display of subtitles is being delayed
  304. */
  305. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  306. /**
  307. * Chapter selection and enumeration, it is bound
  308. * to a title option.
  309. */
  310. /**
  311. * Return the current video subtitle index, or
  312. * \return NSNotFound if none is set.
  313. *
  314. * To disable subtitle pass NSNotFound.
  315. */
  316. @property (readwrite) int currentChapterIndex;
  317. - (void)previousChapter;
  318. - (void)nextChapter;
  319. - (int)numberOfChaptersForTitle:(int)titleIndex;
  320. - (NSArray *)chaptersForTitleIndex:(int)titleIndex __attribute__((deprecated));
  321. extern NSString *const VLCChapterDescriptionName;
  322. extern NSString *const VLCChapterDescriptionTimeOffset;
  323. extern NSString *const VLCChapterDescriptionDuration;
  324. /**
  325. * chapter descriptions
  326. * an array of all chapters of the given title including information about
  327. * chapter name, time offset and duration
  328. * \note if no title value is provided, information about the chapters of the current title is returned
  329. * \return array describing the titles in details
  330. */
  331. - (NSArray *)chapterDescriptionsOfTitle:(int)titleIndex;
  332. /**
  333. * Title selection and enumeration
  334. * \return NSNotFound if none is set.
  335. */
  336. @property (readwrite) int currentTitleIndex;
  337. @property (readonly) int numberOfTitles;
  338. @property (readonly) NSUInteger countOfTitles __attribute__((deprecated));
  339. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titles __attribute__((deprecated));
  340. extern NSString *const VLCTitleDescriptionName;
  341. extern NSString *const VLCTitleDescriptionDuration;
  342. extern NSString *const VLCTitleDescriptionIsMenu;
  343. /**
  344. * title descriptions
  345. * an array of all titles of the current media including information
  346. * of name, duration and potential menu state
  347. * \return array describing the titles in details
  348. */
  349. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *titleDescriptions;
  350. /**
  351. * the title with the longest duration
  352. * \return int matching the title index
  353. */
  354. @property (readonly) int indexOfLongestTitle;
  355. /* Audio Options */
  356. /**
  357. * Return the current audio track index
  358. *
  359. * \return 0 if none is set.
  360. *
  361. * Pass -1 to disable.
  362. */
  363. @property (readwrite) int currentAudioTrackIndex;
  364. /**
  365. * Returns the audio track names, usually a language name or a description
  366. * It includes the "Disabled" fake track at index 0.
  367. */
  368. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackNames;
  369. /**
  370. * Returns the audio track IDs
  371. * those are needed to set the video index
  372. */
  373. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackIndexes;
  374. /**
  375. * returns the number of audio tracks available in the current media
  376. * \return number of tracks
  377. */
  378. @property (NS_NONATOMIC_IOSONLY, readonly) int numberOfAudioTracks;
  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. #if TARGET_OS_IPHONE
  547. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *snapshots;
  548. /**
  549. * Get last snapshot available.
  550. * \return an UIImage with the last snapshot available.
  551. * \note return value is nil if there is no snapshot
  552. */
  553. @property (NS_NONATOMIC_IOSONLY, readonly) UIImage *lastSnapshot;
  554. #endif
  555. @end