VLCMediaPlayer.h 14 KB

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