Added seeking to quicktime decoder.
parent
96ed93e5eb
commit
2402daac91
|
@ -16,12 +16,7 @@
|
||||||
@interface QuicktimeDecoder : NSObject <CogDecoder> {
|
@interface QuicktimeDecoder : NSObject <CogDecoder> {
|
||||||
AudioStreamBasicDescription _asbd;
|
AudioStreamBasicDescription _asbd;
|
||||||
MovieAudioExtractionRef _extractionSessionRef;
|
MovieAudioExtractionRef _extractionSessionRef;
|
||||||
|
Movie _movie;
|
||||||
int bitrate;
|
|
||||||
int bitsPerSample;
|
|
||||||
int channels;
|
|
||||||
float frequency;
|
|
||||||
double length;
|
|
||||||
|
|
||||||
unsigned long _totalFrames;
|
unsigned long _totalFrames;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,12 @@
|
||||||
OSErr error;
|
OSErr error;
|
||||||
Handle dataRef;
|
Handle dataRef;
|
||||||
OSType dataRefType;
|
OSType dataRefType;
|
||||||
Movie soundToPlay;
|
|
||||||
AudioChannelLayout* layout = nil;
|
AudioChannelLayout* layout = nil;
|
||||||
UInt32 size = 0;
|
UInt32 size = 0;
|
||||||
|
|
||||||
NSLog(@"EnterMovies...");
|
NSLog(@"EnterMovies...");
|
||||||
EnterMovies();
|
EnterMovies();
|
||||||
|
|
||||||
|
|
||||||
NSLog(@"Creating new data reference...");
|
NSLog(@"Creating new data reference...");
|
||||||
error = QTNewDataReferenceFromCFURL((CFURLRef)url, 0, &dataRef, &dataRefType);
|
error = QTNewDataReferenceFromCFURL((CFURLRef)url, 0, &dataRef, &dataRefType);
|
||||||
NSLog(@" %d",error);
|
NSLog(@" %d",error);
|
||||||
|
@ -34,14 +32,14 @@
|
||||||
NSLog(@"Creating new movie...");
|
NSLog(@"Creating new movie...");
|
||||||
short fileID = movieInDataForkResID;
|
short fileID = movieInDataForkResID;
|
||||||
short flags = 0;
|
short flags = 0;
|
||||||
error = NewMovieFromDataRef(&soundToPlay, flags, &fileID, dataRef, dataRefType);
|
error = NewMovieFromDataRef(&_movie, flags, &fileID, dataRef, dataRefType);
|
||||||
NSLog(@" %d",error);
|
NSLog(@" %d",error);
|
||||||
|
|
||||||
NSLog(@"Setting movie active...");
|
NSLog(@"Setting movie active...");
|
||||||
SetMovieActive(soundToPlay, TRUE);
|
SetMovieActive(_movie, TRUE);
|
||||||
|
|
||||||
NSLog(@"Beginning extraction session...");
|
NSLog(@"Beginning extraction session...");
|
||||||
error = MovieAudioExtractionBegin(soundToPlay, 0, &_extractionSessionRef);
|
error = MovieAudioExtractionBegin(_movie, 0, &_extractionSessionRef);
|
||||||
NSLog(@" %d",error);
|
NSLog(@" %d",error);
|
||||||
|
|
||||||
NSLog(@"Getting property info...");
|
NSLog(@"Getting property info...");
|
||||||
|
@ -111,7 +109,7 @@
|
||||||
NSLog(@" channels/frame = %d",_asbd.mChannelsPerFrame);
|
NSLog(@" channels/frame = %d",_asbd.mChannelsPerFrame);
|
||||||
NSLog(@" b/channel = %d",_asbd.mBitsPerChannel);
|
NSLog(@" b/channel = %d",_asbd.mBitsPerChannel);
|
||||||
|
|
||||||
_totalFrames = _asbd.mSampleRate * ((float) GetMovieDuration(soundToPlay) / (float) GetMovieTimeScale(soundToPlay));
|
_totalFrames = _asbd.mSampleRate * ((float) GetMovieDuration(_movie) / (float) GetMovieTimeScale(_movie));
|
||||||
|
|
||||||
[self willChangeValueForKey:@"properties"];
|
[self willChangeValueForKey:@"properties"];
|
||||||
[self didChangeValueForKey:@"properties"];
|
[self didChangeValueForKey:@"properties"];
|
||||||
|
@ -155,7 +153,22 @@
|
||||||
|
|
||||||
- (double) seekToTime:(double)milliseconds
|
- (double) seekToTime:(double)milliseconds
|
||||||
{
|
{
|
||||||
return 0.0;
|
OSErr error;
|
||||||
|
TimeRecord timeRec;
|
||||||
|
|
||||||
|
timeRec.scale = GetMovieTimeScale(_movie);
|
||||||
|
timeRec.base = NULL;
|
||||||
|
timeRec.value.hi = 0;
|
||||||
|
timeRec.value.lo = (milliseconds/1000.0) * timeRec.scale;
|
||||||
|
|
||||||
|
error = MovieAudioExtractionSetProperty(_extractionSessionRef, kQTPropertyClass_MovieAudioExtraction_Movie, kQTMovieAudioExtractionMoviePropertyID_CurrentTime, sizeof(timeRec), &timeRec);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
NSLog(@"Error seeking! %i", error);
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)fileTypes
|
+ (NSArray *)fileTypes
|
||||||
|
@ -208,7 +221,7 @@
|
||||||
[NSNumber numberWithInt:0],@"bitrate",
|
[NSNumber numberWithInt:0],@"bitrate",
|
||||||
[NSNumber numberWithFloat:_asbd.mSampleRate],@"sampleRate",
|
[NSNumber numberWithFloat:_asbd.mSampleRate],@"sampleRate",
|
||||||
[NSNumber numberWithDouble:_totalFrames/(_asbd.mSampleRate/1000.0)],@"length",
|
[NSNumber numberWithDouble:_totalFrames/(_asbd.mSampleRate/1000.0)],@"length",
|
||||||
[NSNumber numberWithBool:NO], @"seekable",
|
[NSNumber numberWithBool:YES], @"seekable",
|
||||||
@"big", @"endian",
|
@"big", @"endian",
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue