VLCMedia.h 17 KB

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