Fixed selecting media type in DShow video capture.
authorArtur Wieczorek <artwik@wp.pl>
Thu, 2 Oct 2014 09:48:47 +0000 (11:48 +0200)
committerArtur Wieczorek <artwik@wp.pl>
Fri, 10 Oct 2014 06:53:48 +0000 (08:53 +0200)
Set correct value of sample size when calling IAMStreamConfig::SetFormat function. For non-RGB media type it can be set to zero value.
(See http://msdn.microsoft.com/en-us/library/windows/desktop/dd373477%28v=vs.85%29.aspx)

modules/videoio/src/cap_dshow.cpp

index efbbd08..87fc300 100644 (file)
@@ -2416,7 +2416,15 @@ static bool setSizeAndSubtype(videoDevice * VD, int attemptWidth, int attemptHei
     VD->pAmMediaType->subtype     = mediatype;
 
     //buffer size
-    VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight*3;
+    if (mediatype == MEDIASUBTYPE_RGB24)
+    {
+        VD->pAmMediaType->lSampleSize = attemptWidth*attemptHeight*3;
+    }
+    else
+    {
+        // For compressed data, the value can be zero.
+        VD->pAmMediaType->lSampleSize = 0;
+    }
 
     //set fps if requested
     if( VD->requestedFrameTime != -1){