VLCMediaPlayer.h 16 KB

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