VLCMediaPlayer.h 14 KB

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