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

VLCMedia: update parsing implementation to match latest libvlc

NOTE: this breaks the public API
parent 4700ce95
......@@ -235,17 +235,17 @@ typedef NS_ENUM(NSUInteger, VLCMediaType) {
*/
@property (nonatomic, readonly) BOOL isParsed __attribute__((deprecated));
typedef NS_ENUM(unsigned, VLCMediaParseStatus)
typedef NS_ENUM(unsigned, VLCMediaParsedStatus)
{
VLCMediaParseStatusInit = 0,
VLCMediaParseStatusSkipped,
VLCMediaParseStatusFailed,
VLCMediaParseStatusDone
VLCMediaParsedStatusInit = 0,
VLCMediaParsedStatusSkipped,
VLCMediaParsedStatusFailed,
VLCMediaParsedStatusDone
};
/**
* \return Returns the parse status of the media
*/
@property (nonatomic, readonly) VLCMediaParseStatus parseStatus;
@property (nonatomic, readonly) VLCMediaParsedStatus parsedStatus;
/**
* The URL for the receiver's media resource.
......@@ -461,6 +461,19 @@ typedef int VLCMediaParsingOptions;
*/
- (int)parseWithOptions:(VLCMediaParsingOptions)options;
/**
* triggers an asynchronous parse of the media item
* using the given options
* \param the option mask based on VLCMediaParsingOptions
* \param a time-out value in milliseconds (-1 for default, 0 for infinite)
* \see VLCMediaParsingOptions
* \return an int. 0 on success, -1 in case of error
* \note listen to the "parsed" key value or the mediaDidFinishParsing:
* delegate method to be notified about parsing results. Those triggers
* will _NOT_ be raised if parsing fails and this method returns an error.
*/
- (int)parseWithOptions:(VLCMediaParsingOptions)options timeout:(int)timeoutValue;
/**
* Add options to the media, that will be used to determine how
* VLCMediaPlayer will read the media. This allow to use VLC advanced
......
......@@ -41,8 +41,9 @@ New APIs:
- added selectors: codecNameForFourCC:trackType:
mediaType
parseWithOptions:
parseStatus
- added enums: VLCMediaType, VLCMediaParsingOptions, VLCMediaParseStatus
parseWithOptions:Timeout:
parsedStatus
- added enums: VLCMediaType, VLCMediaParsingOptions, VLCMediaParsedStatus
- VLCTime
- added selectors: isEqual:
......
......@@ -256,7 +256,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
libvlc_event_detach(p_em, libvlc_MediaDurationChanged, HandleMediaDurationChanged, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaStateChanged, HandleMediaStateChanged, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaSubItemAdded, HandleMediaSubItemAdded, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaParsedStatus, HandleMediaParsedChanged, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_MediaParsedChanged, HandleMediaParsedChanged, (__bridge void *)(self));
}
[[VLCEventManager sharedManager] cancelCallToObject:self];
......@@ -322,7 +322,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
// wait until we are preparsed
libvlc_media_parsed_status_t status = libvlc_media_get_parsed_status(p_md);
while (!_length && !(status == VLCMediaParseStatusFailed || status == VLCMediaParseStatusDone) && [aDate timeIntervalSinceNow] > 0) {
while (!_length && !(status == VLCMediaParsedStatusFailed || status == VLCMediaParsedStatusDone) && [aDate timeIntervalSinceNow] > 0) {
usleep( thread_sleep );
status = libvlc_media_get_parsed_status(p_md);
}
......@@ -339,16 +339,16 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (BOOL)isParsed
{
VLCMediaParseStatus status = [self parseStatus];
return (status == VLCMediaParseStatusFailed || status == VLCMediaParseStatusDone) ? YES:NO;
VLCMediaParsedStatus status = [self parsedStatus];
return (status == VLCMediaParsedStatusFailed || status == VLCMediaParsedStatusDone) ? YES:NO;
}
- (VLCMediaParseStatus)parseStatus
- (VLCMediaParsedStatus)parsedStatus
{
if ( !p_md )
return VLCMediaParseStatusFailed;
return VLCMediaParsedStatusFailed;
libvlc_media_parsed_status_t status = libvlc_media_get_parsed_status(p_md);
return (VLCMediaParseStatus)status;
return (VLCMediaParsedStatus)status;
}
- (void)parse
......@@ -363,13 +363,26 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
libvlc_media_parse(p_md);
}
- (int)parseWithOptions:(VLCMediaParsingOptions)options timeout:(int)timeoutValue
{
if (!p_md)
return -1;
// we are using the default time-out value
return libvlc_media_parse_with_options(p_md,
options,
timeoutValue);
}
- (int)parseWithOptions:(VLCMediaParsingOptions)options
{
if (!p_md)
return -1;
// we are using the default time-out value
return libvlc_media_parse_with_options(p_md,
options);
options,
-1);
}
- (void)addOptions:(NSDictionary*)options
......@@ -608,8 +621,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (NSArray *)tracksInformation
{
VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
VLCMediaParsedStatus parsedStatus = [self parsedStatus];
if (parsedStatus == VLCMediaParsedStatusSkipped || parsedStatus == VLCMediaParsedStatusInit)
[self synchronousParse];
libvlc_media_track_t **tracksInfo;
......@@ -672,8 +685,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
{
#if TARGET_OS_IPHONE
// Trigger parsing if needed
VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
VLCMediaParsedStatus parsedStatus = [self parsedStatus];
if (parsedStatus == VLCMediaParsedStatusSkipped || parsedStatus == VLCMediaParsedStatusInit)
[self synchronousParse];
NSUInteger biggestWidth = 0;
......@@ -726,8 +739,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
if (!p_md)
return nil;
VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
VLCMediaParsedStatus parsedStatus = [self parsedStatus];
if (parsedStatus == VLCMediaParsedStatusSkipped || parsedStatus == VLCMediaParsedStatusInit)
[self synchronousParse];
char *returnValue = libvlc_media_get_meta(p_md, [VLCMedia stringToMetaType:key]);
......@@ -867,7 +880,7 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
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_MediaSubItemAdded, HandleMediaSubItemAdded, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaParsedStatus, HandleMediaParsedChanged, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_MediaParsedChanged, HandleMediaParsedChanged, (__bridge void *)(self));
}
libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md );
......@@ -931,8 +944,8 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)parseIfNeeded
{
VLCMediaParseStatus parseStatus = [self parseStatus];
if (parseStatus == VLCMediaParseStatusSkipped || parseStatus == VLCMediaParseStatusInit)
VLCMediaParsedStatus parsedStatus = [self parsedStatus];
if (parsedStatus == VLCMediaParsedStatusSkipped || parsedStatus == VLCMediaParsedStatusInit)
[self parseWithOptions:VLCMediaParseLocal | VLCMediaFetchLocal];
}
......@@ -960,10 +973,9 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)parsedChanged:(NSNumber *)isParsedAsNumber
{
VLCMediaParseStatus parseStatus = [self parseStatus];
[self willChangeValueForKey:@"parseStatus"];
[self didChangeValueForKey:@"parseStatus"];
[self willChangeValueForKey:@"parsedStatus"];
[self parsedStatus];
[self didChangeValueForKey:@"parsedStatus"];
if (!_delegate)
return;
......
......@@ -143,8 +143,8 @@ static void display(void *opaque, void *picture)
{
NSAssert(!_data, @"We are already fetching a thumbnail");
VLCMediaParseStatus parseStatus = [_media parseStatus];
if (!(parseStatus == VLCMediaParseStatusFailed || parseStatus == VLCMediaParseStatusDone)) {
VLCMediaParsedStatus parsedStatus = [_media parsedStatus];
if (!(parsedStatus == VLCMediaParsedStatusFailed || parsedStatus == VLCMediaParsedStatusDone)) {
[_media addObserver:self forKeyPath:@"parsed" options:0 context:NULL];
[_media parseWithOptions:VLCMediaParseLocal];
NSAssert(!_parsingTimeoutTimer, @"We already have a timer around");
......@@ -243,8 +243,8 @@ static void display(void *opaque, void *picture)
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == _media && [keyPath isEqualToString:@"parsed"]) {
VLCMediaParseStatus parseStatus = [_media parseStatus];
if (parseStatus == VLCMediaParseStatusFailed || parseStatus == VLCMediaParseStatusDone) {
VLCMediaParsedStatus parsedStatus = [_media parsedStatus];
if (parsedStatus == VLCMediaParsedStatusFailed || parsedStatus == VLCMediaParsedStatusDone) {
[_parsingTimeoutTimer invalidate];
_parsingTimeoutTimer = nil;
[_media removeObserver:self forKeyPath:@"parsed"];
......
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