VLCMedia.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*****************************************************************************
  2. * VLCMedia.h: VLCKit.framework VLCMedia header
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2007 VLC authors and VideoLAN
  6. * $Id$
  7. *
  8. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU Lesser General Public License as published by
  12. * the Free Software Foundation; either version 2.1 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with this program; if not, write to the Free Software Foundation,
  22. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23. *****************************************************************************/
  24. #import <Foundation/Foundation.h>
  25. #import "VLCMediaList.h"
  26. #import "VLCTime.h"
  27. /* Meta Dictionary Keys */
  28. /**
  29. * Standard dictionary keys for retreiving meta data.
  30. */
  31. extern NSString * VLCMetaInformationTitle; /* NSString */
  32. extern NSString * VLCMetaInformationArtist; /* NSString */
  33. extern NSString * VLCMetaInformationGenre; /* NSString */
  34. extern NSString * VLCMetaInformationCopyright; /* NSString */
  35. extern NSString * VLCMetaInformationAlbum; /* NSString */
  36. extern NSString * VLCMetaInformationTrackNumber; /* NSString */
  37. extern NSString * VLCMetaInformationDescription; /* NSString */
  38. extern NSString * VLCMetaInformationRating; /* NSString */
  39. extern NSString * VLCMetaInformationDate; /* NSString */
  40. extern NSString * VLCMetaInformationSetting; /* NSString */
  41. extern NSString * VLCMetaInformationURL; /* NSString */
  42. extern NSString * VLCMetaInformationLanguage; /* NSString */
  43. extern NSString * VLCMetaInformationNowPlaying; /* NSString */
  44. extern NSString * VLCMetaInformationPublisher; /* NSString */
  45. extern NSString * VLCMetaInformationEncodedBy; /* NSString */
  46. extern NSString * VLCMetaInformationArtworkURL; /* NSString */
  47. extern NSString * VLCMetaInformationArtwork; /* NSImage */
  48. extern NSString * VLCMetaInformationTrackID; /* NSString */
  49. /* Notification Messages */
  50. /**
  51. * Available notification messages.
  52. */
  53. extern NSString * VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed
  54. // Forward declarations, supresses compiler error messages
  55. @class VLCMediaList;
  56. @class VLCMedia;
  57. typedef enum VLCMediaState
  58. {
  59. VLCMediaStateNothingSpecial, //< Nothing
  60. VLCMediaStateBuffering, //< Stream is buffering
  61. VLCMediaStatePlaying, //< Stream is playing
  62. VLCMediaStateError, //< Can't be played because an error occurred
  63. } VLCMediaState;
  64. /**
  65. * Informal protocol declaration for VLCMedia delegates. Allows data changes to be
  66. * trapped.
  67. */
  68. @protocol VLCMediaDelegate
  69. // TODO: SubItemAdded/SubItemRemoved implementation. Not sure if we really want to implement this.
  70. ///**
  71. // * Delegate method called whenever a sub item has been added to the specified VLCMedia.
  72. // * \param aMedia The media resource that has received the new sub item.
  73. // * \param childMedia The new sub item added.
  74. // * \param index Location of the new subitem in the aMedia's sublist.
  75. // */
  76. // - (void)media:(VLCMedia *)media addedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  77. ///**
  78. // * Delegate method called whenever a sub item has been removed from the specified VLCMedia.
  79. // * \param aMedia The media resource that has had a sub item removed from.
  80. // * \param childMedia The sub item removed.
  81. // * \param index The previous location of the recently removed sub item.
  82. // */
  83. // - (void)media:(VLCMedia *)aMedia removedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  84. /**
  85. * Delegate method called whenever the meta has changed for the receiver.
  86. * \param aMedia The media resource whose meta data has been changed.
  87. * \param oldValue The old meta data value.
  88. * \param key The key of the value that was changed.
  89. */
  90. - (void)media:(VLCMedia *)aMedia metaValueChangedFrom:(id)oldValue forKey:(NSString *)key;
  91. /**
  92. * Delegate method called whenever the media was parsed.
  93. * \param aMedia The media resource whose meta data has been changed.
  94. */
  95. - (void)mediaDidFinishParsing:(VLCMedia *)aMedia;
  96. @end
  97. /**
  98. * Defines files and streams as a managed object. Each media object can be
  99. * administered seperately. VLCMediaPlayer or VLCMediaList must be used
  100. * to execute the appropriate playback functions.
  101. * \see VLCMediaPlayer
  102. * \see VLCMediaList
  103. */
  104. @interface VLCMedia : NSObject
  105. {
  106. void * p_md; //< Internal media descriptor instance
  107. NSURL * url; //< URL (MRL) for this media resource
  108. VLCMediaList * subitems; //< Sub list of items
  109. VLCTime * length; //< Cached duration of the media
  110. NSMutableDictionary * metaDictionary; //< Meta data storage
  111. id delegate; //< Delegate object
  112. BOOL isArtFetched; //< Value used to determine of the artwork has been parsed
  113. BOOL areOthersMetaFetched; //< Value used to determine of the other meta has been parsed
  114. BOOL isArtURLFetched; //< Value used to determine of the other meta has been preparsed
  115. VLCMediaState state; //< Current state of the media
  116. BOOL isParsed;
  117. }
  118. /* Factories */
  119. /**
  120. * Manufactures a new VLCMedia object using the URL specified.
  121. * \param anURL URL to media to be accessed.
  122. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  123. * \see initWithMediaURL
  124. */
  125. + (id)mediaWithURL:(NSURL *)anURL;
  126. /**
  127. * Manufactures a new VLCMedia object using the path specified.
  128. * \param aPath Path to the media to be accessed.
  129. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  130. * \see initWithPath
  131. */
  132. + (id)mediaWithPath:(NSString *)aPath;
  133. /**
  134. * TODO
  135. * \param aName TODO
  136. * \return a new VLCMedia object, only if there were no errors. This object
  137. * will be automatically released.
  138. * \see initAsNodeWithName
  139. */
  140. + (id)mediaAsNodeWithName:(NSString *)aName;
  141. /* Initializers */
  142. /**
  143. * Initializes a new VLCMedia object to use the specified URL.
  144. * \param aPath Path to media to be accessed.
  145. * \return A new VLCMedia object, only if there were no errors.
  146. */
  147. - (id)initWithURL:(NSURL *)anURL;
  148. /**
  149. * Initializes a new VLCMedia object to use the specified path.
  150. * \param aPath Path to media to be accessed.
  151. * \return A new VLCMedia object, only if there were no errors.
  152. */
  153. - (id)initWithPath:(NSString *)aPath;
  154. /**
  155. * TODO
  156. * \param aName TODO
  157. * \return A new VLCMedia object, only if there were no errors.
  158. */
  159. - (id)initAsNodeWithName:(NSString *)aName;
  160. /**
  161. * Returns an NSComparisonResult value that indicates the lexical ordering of
  162. * the receiver and a given meda.
  163. * \param media The media with which to compare with the receiver.
  164. * \return NSOrderedAscending if the URL of the receiver precedes media in
  165. * lexical ordering, NSOrderedSame if the URL of the receiver and media are
  166. * equivalent in lexical value, and NSOrderedDescending if the URL of the
  167. * receiver follows media. If media is nil, returns NSOrderedDescending.
  168. */
  169. - (NSComparisonResult)compare:(VLCMedia *)media;
  170. /* Properties */
  171. /**
  172. * Receiver's delegate.
  173. */
  174. @property (assign) id delegate;
  175. /**
  176. * A VLCTime object describing the length of the media resource, only if it is
  177. * available. Use lengthWaitUntilDate: to wait for a specified length of time.
  178. * \see lengthWaitUntilDate
  179. */
  180. @property (retain, readonly) VLCTime * length;
  181. /**
  182. * Returns a VLCTime object describing the length of the media resource,
  183. * however, this is a blocking operation and will wait until the preparsing is
  184. * completed before returning anything.
  185. * \param aDate Time for operation to wait until, if there are no results
  186. * before specified date then nil is returned.
  187. * \return The length of the media resource, nil if it couldn't wait for it.
  188. */
  189. - (VLCTime *)lengthWaitUntilDate:(NSDate *)aDate;
  190. /**
  191. * Determines if the media has already been preparsed.
  192. */
  193. @property (readonly) BOOL isParsed;
  194. /**
  195. * The URL for the receiver's media resource.
  196. */
  197. @property (retain, readonly) NSURL * url;
  198. /**
  199. * The receiver's sub list.
  200. */
  201. @property (retain, readonly) VLCMediaList * subitems;
  202. /**
  203. * The receiver's meta data as a NSDictionary object.
  204. */
  205. @property (retain, readonly) NSDictionary * metaDictionary;
  206. /**
  207. * The receiver's state, such as Playing, Error, NothingSpecial, Buffering.
  208. */
  209. @property (readonly) VLCMediaState state;
  210. /**
  211. * Tracks information NSDictionary Possible Keys
  212. */
  213. /**
  214. * \returns a NSNumber
  215. */
  216. extern NSString *VLCMediaTracksInformationCodec;
  217. /**
  218. * \returns a NSNumber
  219. */
  220. extern NSString *VLCMediaTracksInformationId;
  221. /**
  222. * \returns a NSString
  223. * \see VLCMediaTracksInformationTypeAudio
  224. * \see VLCMediaTracksInformationTypeVideo
  225. * \see VLCMediaTracksInformationTypeText
  226. * \see VLCMediaTracksInformationTypeUnknown
  227. */
  228. extern NSString *VLCMediaTracksInformationType;
  229. /**
  230. * \returns a NSNumber
  231. */
  232. extern NSString *VLCMediaTracksInformationCodecProfile;
  233. /**
  234. * \returns a NSNumber
  235. */
  236. extern NSString *VLCMediaTracksInformationCodecLevel;
  237. /**
  238. * \returns the audio channels number as NSNumber
  239. */
  240. extern NSString *VLCMediaTracksInformationAudioChannelsNumber;
  241. /**
  242. * \returns the audio rate as NSNumber
  243. */
  244. extern NSString *VLCMediaTracksInformationAudioRate;
  245. /**
  246. * \returns the height as NSNumber
  247. */
  248. extern NSString *VLCMediaTracksInformationVideoHeight;
  249. /**
  250. * \returns the width as NSNumber
  251. */
  252. extern NSString *VLCMediaTracksInformationVideoWidth;
  253. /**
  254. * Tracks information NSDictionary values for
  255. * VLCMediaTracksInformationType
  256. */
  257. extern NSString *VLCMediaTracksInformationTypeAudio;
  258. extern NSString *VLCMediaTracksInformationTypeVideo;
  259. extern NSString *VLCMediaTracksInformationTypeText;
  260. extern NSString *VLCMediaTracksInformationTypeUnknown;
  261. /**
  262. * Returns the tracks information.
  263. *
  264. * This is an array of NSDictionary representing each track.
  265. * It can contains the following keys:
  266. *
  267. * \see VLCMediaTracksInformationCodec
  268. * \see VLCMediaTracksInformationId
  269. * \see VLCMediaTracksInformationType
  270. *
  271. * \see VLCMediaTracksInformationCodecProfile
  272. * \see VLCMediaTracksInformationCodecLevel
  273. *
  274. * \see VLCMediaTracksInformationAudioChannelsNumber
  275. * \see VLCMediaTracksInformationAudioRate
  276. *
  277. * \see VLCMediaTracksInformationVideoHeight
  278. * \see VLCMediaTracksInformationVideoWidth
  279. */
  280. - (NSArray *)tracksInformation;
  281. /**
  282. * Start asynchronously to parse the media.
  283. * This will attempt to fetch the meta data and tracks information.
  284. *
  285. * This is automatically done when an accessor requiring parsing
  286. * is called.
  287. *
  288. * \see -[VLCMediaDelegate mediaDidFinishParsing:]
  289. */
  290. - (void)parse;
  291. /**
  292. * Add options to the media, that will be used to determine how
  293. * VLCMediaPlayer will read the media. This allow to use VLC advanced
  294. * reading/streaming options in a per-media basis
  295. *
  296. * The options are detailed in vlc --long-help, for instance "--sout-all"
  297. * And on the web: http://wiki.videolan.org/VLC_command-line_help
  298. */
  299. - (void) addOptions:(NSDictionary*) options;
  300. /**
  301. * Getter for statistics information
  302. * Returns a NSDictionary with NSNumbers for values.
  303. *
  304. */
  305. - (NSDictionary*) stats;
  306. @end