Commit c2653285 authored by Felix Paul Kühne's avatar Felix Paul Kühne

VLCMedia: add new parse-status API, deprecate isParsed

parent acaff549
...@@ -231,8 +231,21 @@ typedef NS_ENUM(NSUInteger, VLCMediaType) { ...@@ -231,8 +231,21 @@ typedef NS_ENUM(NSUInteger, VLCMediaType) {
/** /**
* Determines if the media has already been preparsed. * Determines if the media has already been preparsed.
* \note: deprecated: use parseStatus instead
*/ */
@property (nonatomic, readonly) BOOL isParsed; @property (nonatomic, readonly) BOOL isParsed __attribute__((deprecated));
typedef NS_ENUM(unsigned, VLCMediaParseStatus)
{
VLCMediaParseStatusInit = 0,
VLCMediaParseStatusSkipped,
VLCMediaParseStatusFailed,
VLCMediaParseStatusDone
};
/**
* \return Returns the parse status of the media
*/
@property (nonatomic, readonly) VLCMediaParseStatus parseStatus;
/** /**
* The URL for the receiver's media resource. * The URL for the receiver's media resource.
......
...@@ -41,7 +41,8 @@ New APIs: ...@@ -41,7 +41,8 @@ New APIs:
- added selectors: codecNameForFourCC:trackType: - added selectors: codecNameForFourCC:trackType:
mediaType mediaType
parseWithOptions: parseWithOptions:
- added enums: VLCMediaType, VLCMediaParsingOptions parseStatus
- added enums: VLCMediaType, VLCMediaParsingOptions, VLCMediaParseStatus
- VLCTime - VLCTime
- added selectors: isEqual: - added selectors: isEqual:
...@@ -51,7 +52,7 @@ Deprecated APIs: ...@@ -51,7 +52,7 @@ Deprecated APIs:
- VLCAudio - VLCAudio
- setMute: - setMute:
- VLCMedia - VLCMedia
- parse - parse, isParsed
- VLCMediaDiscoverer - VLCMediaDiscoverer
- availableMediaDiscoverer - availableMediaDiscoverer
- VLCMediaPlayer - VLCMediaPlayer
......
...@@ -72,7 +72,6 @@ NSString *const VLCMediaMetaChanged = @"VLCMediaMetaChanged"; ...@@ -72,7 +72,6 @@ NSString *const VLCMediaMetaChanged = @"VLCMediaMetaChanged";
BOOL isArtFetched; //< Value used to determine of the artwork has been parsed BOOL isArtFetched; //< Value used to determine of the artwork has been parsed
BOOL areOthersMetaFetched; //< Value used to determine of the other meta has been parsed BOOL areOthersMetaFetched; //< Value used to determine of the other meta has been parsed
BOOL isArtURLFetched; //< Value used to determine of the other meta has been preparsed BOOL isArtURLFetched; //< Value used to determine of the other meta has been preparsed
BOOL isParsed;
NSMutableDictionary *_metaDictionary; NSMutableDictionary *_metaDictionary;
} }
...@@ -337,7 +336,14 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self) ...@@ -337,7 +336,14 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (BOOL)isParsed - (BOOL)isParsed
{ {
return isParsed; VLCMediaParseStatus status = [self parseStatus];
return VLCMediaParseStatusFailed || VLCMediaParseStatusDone;
}
- (VLCMediaParseStatus)parseStatus
{
libvlc_media_parsed_status_t status = libvlc_media_get_parsed_status(p_md);
return status;
} }
- (void)parse - (void)parse
...@@ -597,7 +603,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -597,7 +603,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (NSArray *)tracksInformation - (NSArray *)tracksInformation
{ {
if (!self.isParsed) VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
[self synchronousParse]; [self synchronousParse];
libvlc_media_track_t **tracksInfo; libvlc_media_track_t **tracksInfo;
...@@ -660,7 +667,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -660,7 +667,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
{ {
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
// Trigger parsing if needed // Trigger parsing if needed
if (![self isParsed]) VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
[self synchronousParse]; [self synchronousParse];
NSUInteger biggestWidth = 0; NSUInteger biggestWidth = 0;
...@@ -713,7 +721,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -713,7 +721,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
if (!p_md) if (!p_md)
return nil; return nil;
if (![self isParsed]) VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
[self synchronousParse]; [self synchronousParse];
char *returnValue = libvlc_media_get_meta(p_md, [VLCMedia stringToMetaType:key]); char *returnValue = libvlc_media_get_meta(p_md, [VLCMedia stringToMetaType:key]);
...@@ -853,7 +862,7 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -853,7 +862,7 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
libvlc_event_attach(p_em, libvlc_MediaDurationChanged, HandleMediaDurationChanged, (__bridge void *)(self)); libvlc_event_attach(p_em, libvlc_MediaDurationChanged, HandleMediaDurationChanged, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaStateChanged, HandleMediaStateChanged, (__bridge void *)(self)); libvlc_event_attach(p_em, libvlc_MediaStateChanged, HandleMediaStateChanged, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaSubItemAdded, HandleMediaSubItemAdded, (__bridge void *)(self)); libvlc_event_attach(p_em, libvlc_MediaSubItemAdded, HandleMediaSubItemAdded, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaParsedChanged, HandleMediaParsedChanged, (__bridge void *)(self)); libvlc_event_attach(p_em, libvlc_MediaParsedStatus, HandleMediaParsedChanged, (__bridge void *)(self));
} }
libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md ); libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md );
...@@ -863,7 +872,6 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -863,7 +872,6 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
libvlc_media_list_release( p_mlist ); libvlc_media_list_release( p_mlist );
} }
isParsed = libvlc_media_is_parsed(p_md) != 0;
self.state = LibVLCStateToMediaState(libvlc_media_get_state( p_md )); self.state = LibVLCStateToMediaState(libvlc_media_get_state( p_md ));
} }
...@@ -918,7 +926,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -918,7 +926,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)parseIfNeeded - (void)parseIfNeeded
{ {
if (![self isParsed]) VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
[self parseWithOptions:VLCMediaParseLocal | VLCMediaFetchLocal]; [self parseWithOptions:VLCMediaParseLocal | VLCMediaFetchLocal];
} }
...@@ -946,12 +955,15 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString ...@@ -946,12 +955,15 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)parsedChanged:(NSNumber *)isParsedAsNumber - (void)parsedChanged:(NSNumber *)isParsedAsNumber
{ {
[self willChangeValueForKey:@"parsed"]; VLCMediaParseStatus parseStatus = [self parseStatus];
isParsed = [isParsedAsNumber boolValue];
[self didChangeValueForKey:@"parsed"]; [self willChangeValueForKey:@"parseStatus"];
[self didChangeValueForKey:@"parseStatus"];
if (parseStatus == VLCMediaParseStatusInit || parseStatus == VLCMediaParseStatusSkipped)
return;
// FIXME: Probably don't even call this if there is no delegate. if (!_delegate)
if (!_delegate || !isParsed)
return; return;
if ([_delegate respondsToSelector:@selector(mediaDidFinishParsing:)]) if ([_delegate respondsToSelector:@selector(mediaDidFinishParsing:)])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment