]> git.sesse.net Git - vlc/blobdiff - modules/access/qtcapture.m
YUV 422 Packed motion detect (still kind of broken).
[vlc] / modules / access / qtcapture.m
index d8843693ca4052fc50ba3d79c34809e4945df9aa..48b8ac718dff388e02e169e99c225e50c9ccb1c8 100644 (file)
@@ -30,7 +30,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_input.h>
 #include <vlc_vout.h>
@@ -182,23 +182,14 @@ static int Open( vlc_object_t *p_this )
     int i_aspect;
     int result = 0;
 
-    /* Set up p_demux */
-    p_demux->pf_demux = Demux;
-    p_demux->pf_control = Control;
-    p_demux->info.i_update = 0;
-    p_demux->info.i_title = 0;
-    p_demux->info.i_seekpoint = 0;
+    /* Only when selected */
+    if( *p_demux->psz_access == '\0' )
+        return VLC_EGENERIC;
 
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
     msg_Dbg( p_demux, "QTCapture Probed" );
 
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
-    if( !p_sys ) return VLC_ENOMEM;
-
-    memset( p_sys, 0, sizeof( demux_sys_t ) );
-    memset( &fmt, 0, sizeof( es_format_t ) );
-
     QTCaptureDeviceInput * input = nil;
     QTCaptureSession * session = nil;
     VLCDecompressedVideoOutput * output = nil;
@@ -225,6 +216,11 @@ static int Open( vlc_object_t *p_this )
 
     output = [[VLCDecompressedVideoOutput alloc] init];
 
+    /* Hack - This will lower CPU consumption for some reason */
+    [output setPixelBufferAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
+        [NSNumber numberWithInt:480], kCVPixelBufferHeightKey,
+        [NSNumber numberWithInt:640], kCVPixelBufferWidthKey, nil]];
+
     session = [[QTCaptureSession alloc] init];
 
     bool ret = [session addInput:input error:nil  /* FIXME */];
@@ -243,6 +239,7 @@ static int Open( vlc_object_t *p_this )
 
     [session startRunning];
 
+
     int qtchroma = [[[device formatDescriptions] objectAtIndex: 0] formatType]; /* FIXME */
     int chroma = qtchroma_to_fourcc( qtchroma );
     if( !chroma )
@@ -251,6 +248,21 @@ static int Open( vlc_object_t *p_this )
         goto error;
     }
 
+    /* Now we can init */
+
+    /* Set up p_demux */
+    p_demux->pf_demux = Demux;
+    p_demux->pf_control = Control;
+    p_demux->info.i_update = 0;
+    p_demux->info.i_title = 0;
+    p_demux->info.i_seekpoint = 0;
+
+    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    if( !p_sys ) return VLC_ENOMEM;
+
+    memset( p_sys, 0, sizeof( demux_sys_t ) );
+    memset( &fmt, 0, sizeof( es_format_t ) );
+
     es_format_Init( &fmt, VIDEO_ES, chroma );
 
     NSSize size = [[device attributeForKey:QTFormatDescriptionVideoEncodedPixelsSizeAttribute] sizeValue];