VLCMedia.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*****************************************************************************
  2. * VLCMedia.h: VLCKit.framework VLCMedia header
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2013 Felix Paul Kühne
  6. * Copyright (C) 2007-2013 VLC authors and VideoLAN
  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. #import "VLCMediaList.h"
  28. #import "VLCTime.h"
  29. /* Meta Dictionary Keys */
  30. /**
  31. * Standard dictionary keys for retreiving meta data.
  32. */
  33. extern NSString *const VLCMetaInformationTitle; /* NSString */
  34. extern NSString *const VLCMetaInformationArtist; /* NSString */
  35. extern NSString *const VLCMetaInformationGenre; /* NSString */
  36. extern NSString *const VLCMetaInformationCopyright; /* NSString */
  37. extern NSString *const VLCMetaInformationAlbum; /* NSString */
  38. extern NSString *const VLCMetaInformationTrackNumber; /* NSString */
  39. extern NSString *const VLCMetaInformationDescription; /* NSString */
  40. extern NSString *const VLCMetaInformationRating; /* NSString */
  41. extern NSString *const VLCMetaInformationDate; /* NSString */
  42. extern NSString *const VLCMetaInformationSetting; /* NSString */
  43. extern NSString *const VLCMetaInformationURL; /* NSString */
  44. extern NSString *const VLCMetaInformationLanguage; /* NSString */
  45. extern NSString *const VLCMetaInformationNowPlaying; /* NSString */
  46. extern NSString *const VLCMetaInformationPublisher; /* NSString */
  47. extern NSString *const VLCMetaInformationEncodedBy; /* NSString */
  48. extern NSString *const VLCMetaInformationArtworkURL; /* NSString */
  49. extern NSString *const VLCMetaInformationArtwork; /* NSImage */
  50. extern NSString *const VLCMetaInformationTrackID; /* NSString */
  51. /* Notification Messages */
  52. /**
  53. * Available notification messages.
  54. */
  55. extern NSString *const VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed
  56. // Forward declarations, supresses compiler error messages
  57. @class VLCMediaList;
  58. @class VLCMedia;
  59. typedef NS_ENUM(NSInteger, VLCMediaState) {
  60. VLCMediaStateNothingSpecial, //< Nothing
  61. VLCMediaStateBuffering, //< Stream is buffering
  62. VLCMediaStatePlaying, //< Stream is playing
  63. VLCMediaStateError, //< Can't be played because an error occurred
  64. };
  65. /**
  66. * Informal protocol declaration for VLCMedia delegates. Allows data changes to be
  67. * trapped.
  68. */
  69. @protocol VLCMediaDelegate <NSObject>
  70. // TODO: SubItemAdded/SubItemRemoved implementation. Not sure if we really want to implement this.
  71. ///**
  72. // * Delegate method called whenever a sub item has been added to the specified VLCMedia.
  73. // * \param aMedia The media resource that has received the new sub item.
  74. // * \param childMedia The new sub item added.
  75. // * \param index Location of the new subitem in the aMedia's sublist.
  76. // */
  77. // - (void)media:(VLCMedia *)media addedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  78. ///**
  79. // * Delegate method called whenever a sub item has been removed from the specified VLCMedia.
  80. // * \param aMedia The media resource that has had a sub item removed from.
  81. // * \param childMedia The sub item removed.
  82. // * \param index The previous location of the recently removed sub item.
  83. // */
  84. // - (void)media:(VLCMedia *)aMedia removedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  85. @optional
  86. /**
  87. * Delegate method called whenever the meta has changed for the receiver.
  88. * \param aMedia The media resource whose meta data has been changed.
  89. * \param oldValue The old meta data value.
  90. * \param key The key of the value that was changed.
  91. */
  92. - (void)media:(VLCMedia *)aMedia metaValueChangedFrom:(id)oldValue forKey:(NSString *)key __attribute__((deprecated));
  93. /**
  94. * Delegate method called whenever the media's meta data was changed for whatever reason
  95. * \note this is called more often than mediaDidFinishParsing, so it may be less efficient
  96. * \param aMedia The media resource whose meta data has been changed.
  97. */
  98. - (void)mediaMetaDataDidChange:(VLCMedia *)aMedia;
  99. /**
  100. * Delegate method called whenever the media was parsed.
  101. * \param aMedia The media resource whose meta data has been changed.
  102. */
  103. - (void)mediaDidFinishParsing:(VLCMedia *)aMedia;
  104. @end
  105. /**
  106. * Defines files and streams as a managed object. Each media object can be
  107. * administered seperately. VLCMediaPlayer or VLCMediaList must be used
  108. * to execute the appropriate playback functions.
  109. * \see VLCMediaPlayer
  110. * \see VLCMediaList
  111. */
  112. @interface VLCMedia : NSObject
  113. /* Factories */
  114. /**
  115. * Manufactures a new VLCMedia object using the URL specified.
  116. * \param anURL URL to media to be accessed.
  117. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  118. * \see initWithMediaURL
  119. */
  120. + (instancetype)mediaWithURL:(NSURL *)anURL;
  121. /**
  122. * Manufactures a new VLCMedia object using the path specified.
  123. * \param aPath Path to the media to be accessed.
  124. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  125. * \see initWithPath
  126. */
  127. + (instancetype)mediaWithPath:(NSString *)aPath;
  128. /**
  129. * TODO
  130. * \param aName TODO
  131. * \return a new VLCMedia object, only if there were no errors. This object
  132. * will be automatically released.
  133. * \see initAsNodeWithName
  134. */
  135. + (instancetype)mediaAsNodeWithName:(NSString *)aName;
  136. /* Initializers */
  137. /**
  138. * Initializes a new VLCMedia object to use the specified URL.
  139. * \param aPath Path to media to be accessed.
  140. * \return A new VLCMedia object, only if there were no errors.
  141. */
  142. - (instancetype)initWithURL:(NSURL *)anURL;
  143. /**
  144. * Initializes a new VLCMedia object to use the specified path.
  145. * \param aPath Path to media to be accessed.
  146. * \return A new VLCMedia object, only if there were no errors.
  147. */
  148. - (instancetype)initWithPath:(NSString *)aPath;
  149. /**
  150. * TODO
  151. * \param aName TODO
  152. * \return A new VLCMedia object, only if there were no errors.
  153. */
  154. - (instancetype)initAsNodeWithName:(NSString *)aName;
  155. /**
  156. * Returns an NSComparisonResult value that indicates the lexical ordering of
  157. * the receiver and a given meda.
  158. * \param media The media with which to compare with the receiver.
  159. * \return NSOrderedAscending if the URL of the receiver precedes media in
  160. * lexical ordering, NSOrderedSame if the URL of the receiver and media are
  161. * equivalent in lexical value, and NSOrderedDescending if the URL of the
  162. * receiver follows media. If media is nil, returns NSOrderedDescending.
  163. */
  164. - (NSComparisonResult)compare:(VLCMedia *)media;
  165. /* Properties */
  166. /**
  167. * Receiver's delegate.
  168. */
  169. @property (nonatomic, weak) id<VLCMediaDelegate> delegate;
  170. /**
  171. * A VLCTime object describing the length of the media resource, only if it is
  172. * available. Use lengthWaitUntilDate: to wait for a specified length of time.
  173. * \see lengthWaitUntilDate
  174. */
  175. @property (nonatomic, readwrite, strong) VLCTime * length;
  176. /**
  177. * Returns a VLCTime object describing the length of the media resource,
  178. * however, this is a blocking operation and will wait until the preparsing is
  179. * completed before returning anything.
  180. * \param aDate Time for operation to wait until, if there are no results
  181. * before specified date then nil is returned.
  182. * \return The length of the media resource, nil if it couldn't wait for it.
  183. */
  184. - (VLCTime *)lengthWaitUntilDate:(NSDate *)aDate;
  185. /**
  186. * Determines if the media has already been preparsed.
  187. */
  188. @property (nonatomic, readonly) BOOL isParsed;
  189. /**
  190. * The URL for the receiver's media resource.
  191. */
  192. @property (nonatomic, readonly, strong) NSURL * url;
  193. /**
  194. * The receiver's sub list.
  195. */
  196. @property (nonatomic, readonly, strong) VLCMediaList * subitems;
  197. /**
  198. * get meta property for key
  199. * \note for performance reasons, fetching the metaDictionary will be faster!
  200. * \see metaDictionary
  201. * \see dictionary keys above
  202. */
  203. - (NSString *)metadataForKey:(NSString *)key;
  204. /**
  205. * set meta property for key
  206. * \param metadata to set as NSString
  207. * \param metadata key
  208. * \see dictionary keys above
  209. */
  210. - (void)setMetadata:(NSString *)data forKey:(NSString *)key;
  211. /**
  212. * Save the previously changed metadata
  213. * \return true if saving was successful
  214. */
  215. @property (NS_NONATOMIC_IOSONLY, readonly) BOOL saveMetadata;
  216. /**
  217. * The receiver's meta data as a NSDictionary object.
  218. */
  219. @property (nonatomic, readonly, copy) NSDictionary * metaDictionary;
  220. /**
  221. * The receiver's state, such as Playing, Error, NothingSpecial, Buffering.
  222. */
  223. @property (nonatomic, readonly) VLCMediaState state;
  224. /**
  225. * returns a bool whether is the media is expected to play fluently on this
  226. * device or not. It always returns YES on a Mac.*/
  227. @property (NS_NONATOMIC_IOSONLY, getter=isMediaSizeSuitableForDevice, readonly) BOOL mediaSizeSuitableForDevice;
  228. /**
  229. * Tracks information NSDictionary Possible Keys
  230. */
  231. /**
  232. * \returns a NSNumber
  233. */
  234. extern NSString *const VLCMediaTracksInformationCodec;
  235. /**
  236. * \returns a NSNumber
  237. */
  238. extern NSString *const VLCMediaTracksInformationId;
  239. /**
  240. * \returns a NSString
  241. * \see VLCMediaTracksInformationTypeAudio
  242. * \see VLCMediaTracksInformationTypeVideo
  243. * \see VLCMediaTracksInformationTypeText
  244. * \see VLCMediaTracksInformationTypeUnknown
  245. */
  246. extern NSString *const VLCMediaTracksInformationType;
  247. /**
  248. * \returns a NSNumber
  249. */
  250. extern NSString *const VLCMediaTracksInformationCodecProfile;
  251. /**
  252. * \returns a NSNumber
  253. */
  254. extern NSString *const VLCMediaTracksInformationCodecLevel;
  255. /**
  256. * \returns the bitrate as NSNumber
  257. */
  258. extern NSString *const VLCMediaTracksInformationBitrate;
  259. /**
  260. * \returns the language as NSString
  261. */
  262. extern NSString *const VLCMediaTracksInformationLanguage;
  263. /**
  264. * \returns the description as NSString
  265. */
  266. extern NSString *const VLCMediaTracksInformationDescription;
  267. /**
  268. * \returns the audio channel number as NSNumber
  269. */
  270. extern NSString *const VLCMediaTracksInformationAudioChannelsNumber;
  271. /**
  272. * \returns the audio rate as NSNumber
  273. */
  274. extern NSString *const VLCMediaTracksInformationAudioRate;
  275. /**
  276. * \returns the height as NSNumber
  277. */
  278. extern NSString *const VLCMediaTracksInformationVideoHeight;
  279. /**
  280. * \returns the width as NSNumber
  281. */
  282. extern NSString *const VLCMediaTracksInformationVideoWidth;
  283. /**
  284. * \returns the source aspect ratio as NSNumber
  285. */
  286. extern NSString *const VLCMediaTracksInformationSourceAspectRatio;
  287. /**
  288. * \returns the source aspect ratio denominator as NSNumber
  289. */
  290. extern NSString *const VLCMediaTracksInformationSourceAspectRatioDenominator;
  291. /**
  292. * \returns the frame rate as NSNumber
  293. */
  294. extern NSString *const VLCMediaTracksInformationFrameRate;
  295. /**
  296. * \returns the frame rate denominator as NSNumber
  297. */
  298. extern NSString *const VLCMediaTracksInformationFrameRateDenominator;
  299. /**
  300. * \returns the text encoding as NSString
  301. */
  302. extern NSString *const VLCMediaTracksInformationTextEncoding;
  303. /**
  304. * Tracks information NSDictionary values for
  305. * VLCMediaTracksInformationType
  306. */
  307. extern NSString *const VLCMediaTracksInformationTypeAudio;
  308. extern NSString *const VLCMediaTracksInformationTypeVideo;
  309. extern NSString *const VLCMediaTracksInformationTypeText;
  310. extern NSString *const VLCMediaTracksInformationTypeUnknown;
  311. /**
  312. * Returns the tracks information.
  313. *
  314. * This is an array of NSDictionary representing each track.
  315. * It can contain the following keys:
  316. *
  317. * \see VLCMediaTracksInformationCodec
  318. * \see VLCMediaTracksInformationId
  319. * \see VLCMediaTracksInformationType
  320. *
  321. * \see VLCMediaTracksInformationCodecProfile
  322. * \see VLCMediaTracksInformationCodecLevel
  323. *
  324. * \see VLCMediaTracksInformationBitrate
  325. * \see VLCMediaTracksInformationLanguage
  326. * \see VLCMediaTracksInformationDescription
  327. *
  328. * \see VLCMediaTracksInformationAudioChannelsNumber
  329. * \see VLCMediaTracksInformationAudioRate
  330. *
  331. * \see VLCMediaTracksInformationVideoHeight
  332. * \see VLCMediaTracksInformationVideoWidth
  333. *
  334. * \see VLCMediaTracksInformationSourceAspectRatio
  335. * \see VLCMediaTracksInformationSourceAspectDenominator
  336. *
  337. * \see VLCMediaTracksInformationFrameRate
  338. * \see VLCMediaTracksInformationFrameRateDenominator
  339. *
  340. * \see VLCMediaTracksInformationTextEncoding
  341. */
  342. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *tracksInformation;
  343. /**
  344. * Start asynchronously to parse the media.
  345. * This will attempt to fetch the meta data and tracks information.
  346. *
  347. * This is automatically done when an accessor requiring parsing
  348. * is called.
  349. *
  350. * \see -[VLCMediaDelegate mediaDidFinishParsing:]
  351. */
  352. - (void)parse;
  353. /**
  354. * Trigger a synchronous parsing of the media
  355. * the selector won't return until parsing finished
  356. */
  357. - (void)synchronousParse;
  358. /**
  359. * Add options to the media, that will be used to determine how
  360. * VLCMediaPlayer will read the media. This allow to use VLC advanced
  361. * reading/streaming options in a per-media basis
  362. *
  363. * The options are detailed in vlc --long-help, for instance "--sout-all"
  364. * And on the web: http://wiki.videolan.org/VLC_command-line_help
  365. */
  366. - (void) addOptions:(NSDictionary*) options;
  367. /**
  368. * Getter for statistics information
  369. * Returns a NSDictionary with NSNumbers for values.
  370. *
  371. */
  372. @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSDictionary *stats;
  373. #pragma mark - individual stats
  374. /**
  375. * returns the number of bytes read by the current input module
  376. * \return a NSInteger with the raw number of bytes
  377. */
  378. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfReadBytesOnInput;
  379. /**
  380. * returns the current input bitrate. may be 0 if the buffer is full
  381. * \return a float of the current input bitrate
  382. */
  383. @property (NS_NONATOMIC_IOSONLY, readonly) float inputBitrate;
  384. /**
  385. * returns the number of bytes read by the current demux module
  386. * \return a NSInteger with the raw number of bytes
  387. */
  388. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfReadBytesOnDemux;
  389. /**
  390. * returns the current demux bitrate. may be 0 if the buffer is empty
  391. * \return a float of the current demux bitrate
  392. */
  393. @property (NS_NONATOMIC_IOSONLY, readonly) float demuxBitrate;
  394. /**
  395. * returns the total number of decoded video blocks in the current media session
  396. * \return a NSInteger with the total number of decoded blocks
  397. */
  398. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfDecodedVideoBlocks;
  399. /**
  400. * returns the total number of decoded audio blocks in the current media session
  401. * \return a NSInteger with the total number of decoded blocks
  402. */
  403. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfDecodedAudioBlocks;
  404. /**
  405. * returns the total number of displayed pictures during the current media session
  406. * \return a NSInteger with the total number of displayed pictures
  407. */
  408. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfDisplayedPictures;
  409. /**
  410. * returns the total number of pictures lost during the current media session
  411. * \return a NSInteger with the total number of lost pictures
  412. */
  413. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfLostPictures;
  414. /**
  415. * returns the total number of played audio buffers during the current media session
  416. * \return a NSInteger with the total number of played audio buffers
  417. */
  418. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfPlayedAudioBuffers;
  419. /**
  420. * returns the total number of audio buffers lost during the current media session
  421. * \return a NSInteger with the total number of displayed pictures
  422. */
  423. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfLostAudioBuffers;
  424. /**
  425. * returns the total number of packets sent during the current media session
  426. * \return a NSInteger with the total number of sent packets
  427. */
  428. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfSentPackets;
  429. /**
  430. * returns the total number of raw bytes sent during the current media session
  431. * \return a NSInteger with the total number of sent bytes
  432. */
  433. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfSentBytes;
  434. /**
  435. * returns the current bitrate of sent bytes
  436. * \return a float of the current bitrate of sent bits
  437. */
  438. @property (NS_NONATOMIC_IOSONLY, readonly) float streamOutputBitrate;
  439. /**
  440. * returns the total number of corrupted data packets during current sout session
  441. * \note value is 0 on non-stream-output operations
  442. * \return a NSInteger with the total number of corrupted data packets
  443. */
  444. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfCorruptedDataPackets;
  445. /**
  446. * returns the total number of discontinuties during current sout session
  447. * \note value is 0 on non-stream-output operations
  448. * \return a NSInteger with the total number of discontinuties
  449. */
  450. @property (NS_NONATOMIC_IOSONLY, readonly) NSInteger numberOfDiscontinuties;
  451. @end