VLCMediaPlayer.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. @property float rate;
  187. @property (readonly) VLCAudio * audio;
  188. /* Video Information */
  189. - (CGSize)videoSize;
  190. - (BOOL)hasVideoOut;
  191. - (float)framesPerSecond;
  192. /**
  193. * Sets the current position (or time) of the feed.
  194. * \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
  195. */
  196. - (void)setTime:(VLCTime *)value;
  197. /**
  198. * Returns the current position (or time) of the feed.
  199. * \return VLCTIme object with current time.
  200. */
  201. - (VLCTime *)time;
  202. @property (readonly) VLCTime *remainingTime;
  203. @property (readonly) NSUInteger fps;
  204. /**
  205. * Return the current video track index
  206. * Note that the handled values do not match the videoTracks array indexes
  207. * but refer to VLCMedia's VLCMediaTracksInformationId.
  208. * \return 0 if none is set.
  209. *
  210. * Pass 0 to disable.
  211. */
  212. @property (readwrite) NSUInteger currentVideoTrackIndex;
  213. /**
  214. * Return the video tracks
  215. *
  216. * It includes the disabled fake track at index 0.
  217. */
  218. - (NSArray *)videoTracks;
  219. /**
  220. * Return the current video subtitle index
  221. * Note that the handled values do not match the videoSubTitles array indexes
  222. * but refer to VLCMedia's VLCMediaTracksInformationId.
  223. * \return 0 if none is set.
  224. *
  225. * Pass 0 to disable.
  226. */
  227. @property (readwrite) NSUInteger currentVideoSubTitleIndex;
  228. /**
  229. * Return the video subtitle tracks
  230. *
  231. * It includes the disabled fake track at index 0.
  232. */
  233. - (NSArray *)videoSubTitles;
  234. /**
  235. * Load and set a specific video subtitle, from a file.
  236. * \param path to a file
  237. * \return if the call succeed..
  238. */
  239. - (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
  240. /**
  241. * Get the current subtitle delay. Positive values means subtitles are being
  242. * displayed later, negative values earlier.
  243. *
  244. * \return time (in microseconds) the display of subtitles is being delayed
  245. */
  246. @property (readwrite) NSInteger currentVideoSubTitleDelay;
  247. /**
  248. * Chapter selection and enumeration, it is bound
  249. * to a title option.
  250. */
  251. /**
  252. * Return the current video subtitle index, or
  253. * \return NSNotFound if none is set.
  254. *
  255. * To disable subtitle pass NSNotFound.
  256. */
  257. @property (readwrite) NSUInteger currentChapterIndex;
  258. - (void)previousChapter;
  259. - (void)nextChapter;
  260. - (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
  261. /**
  262. * Title selection and enumeration
  263. * \return NSNotFound if none is set.
  264. */
  265. @property (readwrite) NSUInteger currentTitleIndex;
  266. - (NSArray *)titles;
  267. /* Audio Options */
  268. /**
  269. * Return the current audio track index
  270. * Note that the handled values do not match the audioTracks array indexes
  271. * but refer to VLCMedia's VLCMediaTracksInformationId.
  272. * \return 0 if none is set.
  273. *
  274. * Pass 0 to disable.
  275. */
  276. @property (readwrite) NSUInteger currentAudioTrackIndex;
  277. /**
  278. * Return the audio tracks
  279. *
  280. * It includes the "Disable" fake track at index 0.
  281. */
  282. - (NSArray *)audioTracks;
  283. - (void)setAudioChannel:(NSInteger)value;
  284. - (NSInteger)audioChannel;
  285. /**
  286. * Get the current audio delay. Positive values means audio is delayed further,
  287. * negative values less.
  288. *
  289. * \return time (in microseconds) the audio playback is being delayed
  290. */
  291. @property (readwrite) NSInteger currentAudioPlaybackDelay;
  292. /* Media Options */
  293. - (void)setMedia:(VLCMedia *)value;
  294. - (VLCMedia *)media;
  295. /* Playback Operations */
  296. /**
  297. * Plays a media resource using the currently selected media controller (or
  298. * default controller. If feed was paused then the feed resumes at the position
  299. * it was paused in.
  300. * \return A Boolean determining whether the stream was played or not.
  301. */
  302. - (BOOL)play;
  303. /**
  304. * Toggle's the pause state of the feed.
  305. */
  306. - (void)pause;
  307. /**
  308. * Stop the playing.
  309. */
  310. - (void)stop;
  311. /**
  312. * Advance one frame.
  313. */
  314. - (void)gotoNextFrame;
  315. /**
  316. * Fast forwards through the feed at the standard 1x rate.
  317. */
  318. - (void)fastForward;
  319. /**
  320. * Fast forwards through the feed at the rate specified.
  321. * \param rate Rate at which the feed should be fast forwarded.
  322. */
  323. - (void)fastForwardAtRate:(float)rate;
  324. /**
  325. * Rewinds through the feed at the standard 1x rate.
  326. */
  327. - (void)rewind;
  328. /**
  329. * Rewinds through the feed at the rate specified.
  330. * \param rate Rate at which the feed should be fast rewound.
  331. */
  332. - (void)rewindAtRate:(float)rate;
  333. /**
  334. * Jumps shortly backward in current stream if seeking is supported.
  335. * \param interval to skip, in sec.
  336. */
  337. - (void)jumpBackward:(NSInteger)interval;
  338. /**
  339. * Jumps shortly forward in current stream if seeking is supported.
  340. * \param interval to skip, in sec.
  341. */
  342. - (void)jumpForward:(NSInteger)interval;
  343. /**
  344. * Jumps shortly backward in current stream if seeking is supported.
  345. */
  346. - (void)extraShortJumpBackward;
  347. /**
  348. * Jumps shortly forward in current stream if seeking is supported.
  349. */
  350. - (void)extraShortJumpForward;
  351. /**
  352. * Jumps shortly backward in current stream if seeking is supported.
  353. */
  354. - (void)shortJumpBackward;
  355. /**
  356. * Jumps shortly forward in current stream if seeking is supported.
  357. */
  358. - (void)shortJumpForward;
  359. /**
  360. * Jumps shortly backward in current stream if seeking is supported.
  361. */
  362. - (void)mediumJumpBackward;
  363. /**
  364. * Jumps shortly forward in current stream if seeking is supported.
  365. */
  366. - (void)mediumJumpForward;
  367. /**
  368. * Jumps shortly backward in current stream if seeking is supported.
  369. */
  370. - (void)longJumpBackward;
  371. /**
  372. * Jumps shortly forward in current stream if seeking is supported.
  373. */
  374. - (void)longJumpForward;
  375. /* Playback Information */
  376. /**
  377. * Playback state flag identifying that the stream is currently playing.
  378. * \return TRUE if the feed is playing, FALSE if otherwise.
  379. */
  380. - (BOOL)isPlaying;
  381. /**
  382. * Playback state flag identifying wheather the stream will play.
  383. * \return TRUE if the feed is ready for playback, FALSE if otherwise.
  384. */
  385. - (BOOL)willPlay;
  386. /**
  387. * Playback's current state.
  388. * \see VLCMediaState
  389. */
  390. - (VLCMediaPlayerState)state;
  391. /**
  392. * Returns the receiver's position in the reading.
  393. * \return movie position as percentage between 0.0 and 1.0.
  394. */
  395. - (float)position;
  396. /**
  397. * Set movie position. This has no effect if playback is not enabled.
  398. * \param movie position as percentage between 0.0 and 1.0.
  399. */
  400. - (void)setPosition:(float)newPosition;
  401. - (BOOL)isSeekable;
  402. - (BOOL)canPause;
  403. @end