[vlc-devel] commit: qtcapture: Use Hosttime when available. (Derk-Jan Hartman )

git version control git at videolan.org
Mon Jul 21 02:33:34 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Mon Jul 21 02:28:42 2008 +0200| [344b1df55529d28aadf452b294fbe8256a70f4c5]

qtcapture: Use Hosttime when available.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=344b1df55529d28aadf452b294fbe8256a70f4c5
---

 configure.ac               |    1 +
 modules/access/qtcapture.m |    7 ++++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4c4dbc3..351db9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4954,6 +4954,7 @@ then
   VLC_ADD_LDFLAGS([macosx],                           [-Wl,-framework,IOKit])
   VLC_ADD_LDFLAGS([macosx],                           [-Wl,-framework,QuickTime])
   VLC_ADD_LDFLAGS([macosx qtcapture],                 [-Wl,-framework,QTKit])
+  VLC_ADD_LDFLAGS([qtcapture],                        [-Wl,-framework,CoreAudio])
   VLC_ADD_LDFLAGS([macosx],                           [-Wl,-framework,WebKit])
   VLC_ADD_LDFLAGS([opengllayer qtcapture],            [-Wl,-framework,QuartzCore])
   VLC_ADD_LDFLAGS([qtcapture],                        [-Wl,-framework,CoreVideo])
diff --git a/modules/access/qtcapture.m b/modules/access/qtcapture.m
index bb99846..0a334ec 100644
--- a/modules/access/qtcapture.m
+++ b/modules/access/qtcapture.m
@@ -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);
 }




More information about the vlc-devel mailing list