VLCMediaPlayer.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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 *const VLCMediaPlayerTimeChanged;
  39. extern NSString *const VLCMediaPlayerStateChanged;
  40. /**
  41. * VLCMediaPlayerState describes the state of the media player.
  42. */
  43. enum
  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. };
  53. typedef NSInteger VLCMediaPlayerState;
  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. /**
  66. * Sent by the default notification center whenever the player's state has changed.
  67. * \details Discussion The value of aNotification is always an VLCMediaPlayerStateChanged notification. You can retrieve
  68. * the VLCMediaPlayer object in question by sending object to aNotification.
  69. */
  70. - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
  71. @optional
  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. #if !TARGET_OS_IPHONE
  82. /* Initializers */
  83. - (id)initWithVideoView:(VLCVideoView *)aVideoView;
  84. - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
  85. #endif
  86. - (id)initWithOptions:(NSArray *)options;
  87. /* Properties */
  88. - (void)setDelegate:(id)value;
  89. - (id)delegate;
  90. /* Video View Options */
  91. // TODO: Should be it's own object?
  92. #if !TARGET_OS_IPHONE
  93. - (void)setVideoView:(VLCVideoView *)aVideoView;
  94. - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
  95. #endif
  96. @property (retain) id drawable; /* The videoView or videoLayer */
  97. /**
  98. * Set/Get current video aspect ratio.
  99. *
  100. * \param psz_aspect new video aspect-ratio or NULL to reset to default
  101. * \note Invalid aspect ratios are ignored.
  102. * \return the video aspect ratio or NULL if unspecified
  103. * (the result must be released with free()).
  104. */
  105. - (void)setVideoAspectRatio:(char *)value;
  106. - (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. - (void)setVideoCropGeometry:(char *)value;
  114. - (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 (readwrite) 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:(NSUInteger)width andHeight:(NSUInteger)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 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 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 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 NSInteger 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 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 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 float rate;
  188. @property (readonly) VLCAudio * audio;
  189. /* Video Information */
  190. /**
  191. * Get the current video size
  192. * \return video size as CGSize
  193. */
  194. - (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. - (BOOL)hasVideoOut;
  202. /**
  203. * Frames per second
  204. * \return current media's frames per second value
  205. */
  206. - (float)framesPerSecond;
  207. /**
  208. * Sets the current position (or time) of the feed.
  209. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  210. */
  211. - (void)setTime:(VLCTime *)value;
  212. /**
  213. * Returns the current position (or time) of the feed.
  214. * \return VLCTIme object with current time.
  215. */
  216. - (VLCTime *)time;
  217. @property (readonly) 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. /**
  225. * Return the current video track index
  226. * Note that the handled values do not match the videoTracks array indexes
  227. * but refer to videoSubTitlesIndexes.
  228. * \return 0 if none is set.
  229. *
  230. * Pass -1 to disable.
  231. */
  232. @property (readwrite) NSUInteger currentVideoTrackIndex;
  233. /**
  234. * Returns the video track names, usually a language name or a description
  235. * It includes the "Disabled" fake track at index 0.
  236. */
  237. - (NSArray *)videoTrackNames;
  238. /**
  239. * Returns the video track IDs
  240. * those are needed to set the video index
  241. */
  242. - (NSArray *)videoTrackIndexes;
  243. /**
  244. * Return the video tracks
  245. *
  246. * It includes the disabled fake track at index 0.
  247. */
  248. - (NSArray *)videoTracks __attribute__((deprecated));
  249. /**
  250. * Return the current video subtitle index
  251. * Note that the handled values do not match the videoSubTitles array indexes
  252. * but refer to videoSubTitlesIndexes
  253. * \return 0 if none is set.
  254. *
  255. * Pass -1 to disable.
  256. */
  257. @property (readwrite) NSUInteger currentVideoSubTitleIndex;
  258. /**
  259. * Returns the video subtitle track names, usually a language name or a description
  260. * It includes the "Disabled" fake track at index 0.
  261. */
  262. - (NSArray *)videoSubTitlesNames;
  263. /**
  264. * Returns the video subtitle track IDs
  265. * those are needed to set the video subtitle index
  266. */
  267. - (NSArray *)videoSubTitlesIndexes;
  268. /**
  269. * Return the video subtitle tracks
  270. * \note this property is deprecated. use (NSArray *)videoSubtitleNames instead.
  271. * It includes the disabled fake track at index 0.
  272. */
  273. - (NSArray *)videoSubTitles __attribute__((deprecated));
  274. /**
  275. * Load and set a specific video subtitle, from a file.
  276. * \param path to a file
  277. * \return if the call succeed..
  278. */
  279. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  280. /**
  281. * Get the current subtitle delay. Positive values means subtitles are being
  282. * displayed later, negative values earlier.
  283. *
  284. * \return time (in microseconds) the display of subtitles is being delayed
  285. */
  286. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  287. /**
  288. * Chapter selection and enumeration, it is bound
  289. * to a title option.
  290. */
  291. /**
  292. * Return the current video subtitle index, or
  293. * \return NSNotFound if none is set.
  294. *
  295. * To disable subtitle pass NSNotFound.
  296. */
  297. @property (readwrite) NSUInteger currentChapterIndex;
  298. - (void)previousChapter;
  299. - (void)nextChapter;
  300. - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
  301. /**
  302. * Title selection and enumeration
  303. * \return NSNotFound if none is set.
  304. */
  305. @property (readwrite) NSUInteger currentTitleIndex;
  306. - (NSArray *)titles;
  307. /* Audio Options */
  308. /**
  309. * Return the current audio track index
  310. * Note that the handled values do not match the audioTracks array indexes
  311. * but refer to audioTrackIndexes.
  312. * \return 0 if none is set.
  313. *
  314. * Pass -1 to disable.
  315. */
  316. @property (readwrite) NSUInteger currentAudioTrackIndex;
  317. /**
  318. * Returns the audio track names, usually a language name or a description
  319. * It includes the "Disabled" fake track at index 0.
  320. */
  321. - (NSArray *)audioTrackNames;
  322. /**
  323. * Returns the audio track IDs
  324. * those are needed to set the video index
  325. */
  326. - (NSArray *)audioTrackIndexes;
  327. /**
  328. * Return the audio tracks
  329. *
  330. * It includes the "Disable" fake track at index 0.
  331. */
  332. - (NSArray *)audioTracks __attribute__((deprecated));
  333. - (void)setAudioChannel:(NSInteger)value;
  334. - (NSInteger)audioChannel;
  335. /**
  336. * Get the current audio delay. Positive values means audio is delayed further,
  337. * negative values less.
  338. *
  339. * \return time (in microseconds) the audio playback is being delayed
  340. */
  341. @property (readwrite) NSInteger currentAudioPlaybackDelay;
  342. /* Media Options */
  343. - (void)setMedia:(VLCMedia *)value;
  344. - (VLCMedia *)media;
  345. /* Playback Operations */
  346. /**
  347. * Plays a media resource using the currently selected media controller (or
  348. * default controller. If feed was paused then the feed resumes at the position
  349. * it was paused in.
  350. * \return A Boolean determining whether the stream was played or not.
  351. */
  352. - (BOOL)play;
  353. /**
  354. * Toggle's the pause state of the feed.
  355. */
  356. - (void)pause;
  357. /**
  358. * Stop the playing.
  359. */
  360. - (void)stop;
  361. /**
  362. * Advance one frame.
  363. */
  364. - (void)gotoNextFrame;
  365. /**
  366. * Fast forwards through the feed at the standard 1x rate.
  367. */
  368. - (void)fastForward;
  369. /**
  370. * Fast forwards through the feed at the rate specified.
  371. * \param rate Rate at which the feed should be fast forwarded.
  372. */
  373. - (void)fastForwardAtRate:(float)rate;
  374. /**
  375. * Rewinds through the feed at the standard 1x rate.
  376. */
  377. - (void)rewind;
  378. /**
  379. * Rewinds through the feed at the rate specified.
  380. * \param rate Rate at which the feed should be fast rewound.
  381. */
  382. - (void)rewindAtRate:(float)rate;
  383. /**
  384. * Jumps shortly backward in current stream if seeking is supported.
  385. * \param interval to skip, in sec.
  386. */
  387. - (void)jumpBackward:(NSInteger)interval;
  388. /**
  389. * Jumps shortly forward in current stream if seeking is supported.
  390. * \param interval to skip, in sec.
  391. */
  392. - (void)jumpForward:(NSInteger)interval;
  393. /**
  394. * Jumps shortly backward in current stream if seeking is supported.
  395. */
  396. - (void)extraShortJumpBackward;
  397. /**
  398. * Jumps shortly forward in current stream if seeking is supported.
  399. */
  400. - (void)extraShortJumpForward;
  401. /**
  402. * Jumps shortly backward in current stream if seeking is supported.
  403. */
  404. - (void)shortJumpBackward;
  405. /**
  406. * Jumps shortly forward in current stream if seeking is supported.
  407. */
  408. - (void)shortJumpForward;
  409. /**
  410. * Jumps shortly backward in current stream if seeking is supported.
  411. */
  412. - (void)mediumJumpBackward;
  413. /**
  414. * Jumps shortly forward in current stream if seeking is supported.
  415. */
  416. - (void)mediumJumpForward;
  417. /**
  418. * Jumps shortly backward in current stream if seeking is supported.
  419. */
  420. - (void)longJumpBackward;
  421. /**
  422. * Jumps shortly forward in current stream if seeking is supported.
  423. */
  424. - (void)longJumpForward;
  425. /* Playback Information */
  426. /**
  427. * Playback state flag identifying that the stream is currently playing.
  428. * \return TRUE if the feed is playing, FALSE if otherwise.
  429. */
  430. - (BOOL)isPlaying;
  431. /**
  432. * Playback state flag identifying wheather the stream will play.
  433. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  434. */
  435. - (BOOL)willPlay;
  436. /**
  437. * Playback's current state.
  438. * \see VLCMediaState
  439. */
  440. - (VLCMediaPlayerState)state;
  441. /**
  442. * Returns the receiver's position in the reading.
  443. * \return movie position as percentage between 0.0 and 1.0.
  444. */
  445. - (float)position;
  446. /**
  447. * Set movie position. This has no effect if playback is not enabled.
  448. * \param movie position as percentage between 0.0 and 1.0.
  449. */
  450. - (void)setPosition:(float)newPosition;
  451. - (BOOL)isSeekable;
  452. - (BOOL)canPause;
  453. @end