VLCMedia.h 18 KB

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