VLCMediaPlayer.h 15 KB

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