]> git.sesse.net Git - vlc/blobdiff - modules/access/qtcapture.m
libvlccore: fix AUTO_ADJUST_PTS_DELAY short comment.
[vlc] / modules / access / qtcapture.m
index 78fb6049067cd46fedc117cfa86f5a5228fff2f8..eac2e6f005426e7a80997989869887cfea21307a 100644 (file)
@@ -38,6 +38,7 @@
 #include <vlc_interface.h>
 
 #import <QTKit/QTKit.h>
+#import <CoreAudio/CoreAudio.h>
 
 /*****************************************************************************
 * Local prototypes
@@ -109,7 +110,11 @@ vlc_module_end();
     {
         imageBufferToRelease = currentImageBuffer;
         currentImageBuffer = videoFrame;
-        currentPts = 1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue;
+        currentPts = (mtime_t)(1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue);
+        
+        /* Try to use hosttime of the sample if available, because iSight Pts seems broken */
+        NSNumber *hosttime = (NSNumber *)[sampleBuffer attributeForKey:QTSampleBufferHostTimeAttribute];
+        if( hosttime ) currentPts = (mtime_t)AudioConvertHostTimeToNanos([hosttime unsignedLongLongValue])/1000;
     }
     CVBufferRelease(imageBufferToRelease);
 }
@@ -325,7 +330,6 @@ static void Close( vlc_object_t *p_this )
         [p_sys->session stopRunning];
         [p_sys->output release];
         [p_sys->session release];
-        [p_sys->device release];
     }
     free( p_sys );