28 #import <QTKit/QTKit.h> 
   38 #define QTKIT_TIMEBASE 100 
   83 - (
void)captureOutput:(QTCaptureOutput *)captureOutput
 
   84   didOutputVideoFrame:(CVImageBufferRef)videoFrame
 
   85      withSampleBuffer:(QTSampleBuffer *)sampleBuffer
 
   86        fromConnection:(QTCaptureConnection *)connection;
 
   94     if (
self = [super 
init]) {
 
  100 - (
void)captureOutput:(QTCaptureOutput *)captureOutput
 
  101   didOutputVideoFrame:(CVImageBufferRef)videoFrame
 
  102      withSampleBuffer:(QTSampleBuffer *)sampleBuffer
 
  103        fromConnection:(QTCaptureConnection *)connection
 
  123     [ctx->capture_session stopRunning];
 
  125     [ctx->capture_session release];
 
  126     [ctx->video_output    release];
 
  127     [ctx->qt_delegate     release];
 
  142     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
  154         NSArray *devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
 
  155         for (QTCaptureDevice *device 
in devices) {
 
  156             const char *
name = [[device localizedDisplayName] UTF8String];
 
  157             int index  = [devices indexOfObject:device];
 
  164     QTCaptureDevice *video_device = nil;
 
  172         NSArray *devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
 
  179         video_device = [devices objectAtIndex:ctx->video_device_index];
 
  180     } 
else if (strncmp(s->
filename, 
"",        1) &&
 
  181                strncmp(s->
filename, 
"default", 7)) {
 
  182         NSArray *devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
 
  184         for (QTCaptureDevice *device 
in devices) {
 
  185             if (!strncmp(s->
filename, [[device localizedDisplayName] UTF8String], strlen(s->
filename))) {
 
  186                 video_device = device;
 
  195         video_device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeMuxed];
 
  198     BOOL success = [video_device open:nil];
 
  202         video_device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo];
 
  203         success      = [video_device open:nil];
 
  211     NSString* dev_display_name = [video_device localizedDisplayName];
 
  217     QTCaptureDeviceInput* capture_dev_input = [[[QTCaptureDeviceInput alloc] initWithDevice:video_device] autorelease];
 
  218     success = [ctx->capture_session addInput:capture_dev_input error:nil];
 
  227     ctx->
video_output = [[QTCaptureDecompressedVideoOutput alloc] init];
 
  229     NSDictionary *captureDictionary = [NSDictionary dictionaryWithObject:
 
  230                                        [NSNumber numberWithUnsignedInt:kCVPixelFormatType_24RGB]
 
  231                                        forKey:(id)kCVPixelBufferPixelFormatTypeKey];
 
  233     [ctx->video_output setPixelBufferAttributes:captureDictionary];
 
  237     [ctx->video_output setDelegate:ctx->qt_delegate];
 
  238     [ctx->video_output setAutomaticallyDropsLateVideoFrames:YES];
 
  239     [ctx->video_output setMinimumVideoFrameInterval:1.0/ctx->frame_rate];
 
  241     success = [ctx->capture_session addOutput:ctx->video_output error:nil];
 
  248     [ctx->capture_session startRunning];
 
  252         CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, YES);
 
  333     { 
"frame_rate", 
"set frame rate", offsetof(
CaptureContext, frame_rate), 
AV_OPT_TYPE_FLOAT, { .dbl = 30.0 }, 0.1, 30.0, 
AV_OPT_TYPE_VIDEO_RATE, 
NULL },
 
  334     { 
"list_devices", 
"list available devices", offsetof(
CaptureContext, list_devices), 
AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM, 
"list_devices" },
 
  357     .priv_class     = &qtkit_class,