VLCMedia.h 17 KB

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