Hello list,
Perhaps somebody is ahead of me on this, its a pretty obvious step but
I haven't found it documented.
I am making an application based on the Quartz Composer Performer
example. It provides just the framework I need, but I was surprised to
find the MovieSource class not using the technique recommended in
technote 2143:
QuickTime movies: create a visual context to render the movie into
using the QuickTime 7 APIs (see QuickTime Reference Update). Then
pass the CVImageBuffers obtained by
QTVisualContextCopyImageForTime() to the appropriate composition's
Image input and release them. For best performances, it's highly
recommended to use a QuickTime OpenGL texture context that uses the
same OpenGL context and pixel format as a the ones used to render
the composition (assuming a QCRenderer is used, as the QCView does
not provide this information).
The example MovieSource passes NSImage, and you can imagine the
performance is less than splendid.
I didn't find an example of that exact scenario anywhere in the sample
code, so I have assembled an "accelerated" MovieSource class from what
I have found. It works, but only for a second or so of playback, at
which point my debugging skills quickly hit the wall. Hence asking
here if anybody has a similar class working, or if somebody at Apple
could supply the seeming obvious hole in their documentation. I
imagine the code is very similar to the async mode in the Movie Loader
patch.
You should be able to drop the attached class into the performer
project, making sure to remove the existing MovieSource from the target.
Thanks,
Toby
#import <QTKit/QTKit.h>
#import "MediaSource.h"
@interface MovieSource : MediaSource
{
Movie channelMovie;
QTVisualContextRef visualContext;
CVOpenGLTextureRef currentTexture;
}
@end
@implementation MovieSource
+ (void) load
{
//Register automatically this MediaSource subclass when the Obj-C
runtime loads it
[MediaSource registerMediaSourceClass:[self class]];
}
+ (NSArray*) supportedFileExtensions
{
//We handle movie files types (make sure QuickTime does not handle
Quartz Composer ".qtz" files as there is an explicit media source class for
them)
return [NSArray arrayWithObjects:@"mov", @"avi", @"dv", @"mpg", @"mp4",
nil];
}
- (id) initWithFile:(NSString*)path openGLContext:(NSOpenGLContext*)context
pixelFormat:(NSOpenGLPixelFormat*)pixelFormat
{
self = [super init];
OSStatus theError = noErr;
Boolean active = TRUE;
UInt32 trackCount = 0;
OSType theTrackType;
Track theTrack = nil;
Media theMedia = nil;
QTNewMoviePropertyElement newMovieProperties[] = {
{kQTPropertyClass_DataLocation, kQTDataLocationPropertyID_CFStringNativePath,
sizeof(path), &path, 0},
{kQTPropertyClass_NewMovieProperty,
kQTNewMoviePropertyID_Active, sizeof(active), &active, 0},
{kQTPropertyClass_Context, kQTContextPropertyID_VisualContext,
sizeof(visualContext), &visualContext, 0},
};
theError = QTOpenGLTextureContextCreate(nil,
[context CGLContextObj],
[pixelFormat CGLPixelFormatObj],
nil,
&visualContext);
if(visualContext == NULL)
{
NSLog(@"QTVisualContext creation failed with error:%d",
theError);
return nil;
}
theError = NewMovieFromProperties(sizeof(newMovieProperties) /
sizeof(newMovieProperties[0]), newMovieProperties, 0, nil, &channelMovie);
if(theError)
{
NSLog(@"NewMovieFromProperties failed with %d", theError);
return nil;
}
// setup the movie
GoToBeginningOfMovie(channelMovie);
SetTimeBaseFlags(GetMovieTimeBase(channelMovie), loopTimeBase);
//SetMoviePlayHints(channelMovie, hintsLoop, hintsLoop);
StartMovie(channelMovie);
return self;
}
- (BOOL) isNewImageAvailableForTime:(const CVTimeStamp*)time
{
QTVisualContextTask(visualContext);
if(QTVisualContextIsNewImageAvailable(visualContext, time)) {
return YES;
} else {
return NO;
}
return YES;
}
- (id) copyTransitionImageForTime:(const CVTimeStamp*)time
{
return nil;
}
- (id) copyImageForTime:(const CVTimeStamp*)time
{
CVImageBufferRef imageBufferRef = nil;
QTVisualContextCopyImageForTime(visualContext, nil, time,
&imageBufferRef);
return imageBufferRef;
}
- (void) dealloc
{
//FIXME: deal with this once playback is working
//Release all objects
//[_movie stop];
//[_movie release];
[super dealloc];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]