Reputation: 215
I'm doing video capture from a webcam in two separate ways (think two applications): using Direct Show and Media Foundation.
Using Direct Show, my Logitech c920 webcam has 3 output pins:
PIN_CATEGORY_CAPTURE
or
PIN_CATEGORY_PREVIEW
) in I420, RGB24 and MJPG pixel formats, with
FPS from 2 to 30, depending on media type.PIN_CATEGORY_STILL
) in I420 and RGB24
with just 1 FPS.PIN_CATEGORY_CAPTURE
or
PIN_CATEGORY_PREVIEW
) in h264 with FPS from 5 to 30.So, since I'm concerned only with video capture, I ignore all pins that are not PIN_CATEGORY_CAPTURE
or PIN_CATEGORY_PREVIEW
, which works great.
Using Media Foundation, the same camera has 3 stream descriptors (IMFPresentationDescriptor::GetStreamDescriptorCount
). Each stream descriptor provides IMFMediaTypeHandler
that allows you to iterate over media types. So I have 3 IMFMediaTypeHandlers:
IMFMediaTypeHandler::GetMajorType == MFMediaType_Video
) in I420, RGB24 and MJPG pixel formats, with
FPS from 2 to 30, depending on media type.IMFMediaTypeHandler::GetMajorType == MFMediaType_Video
) in i420 and RGB24
with just 1 FPS.IMFMediaTypeHandler::GetMajorType == MFMediaType_Video
) in h264 with FPS from 5 to 30.You can notice that Media Foundation's stream descriptors seem to map to Direct Show's output pins 1 on 1. Except that Media Foundation didn't mark the stream descriptor #2 as still image capture (MFMediaType_Image
), in contrast to what Direct Show is doing.
Still image capture requires different handling than video capture, so my Direct Show code errors and doesn't do any capturing at all when trying to use media types from pin #2. Well, I only care about video capturing in the first place, so that is fine.
But even through Media Foundation tells that the stream descriptor #2 is video capture, my Media Foundation code, which works perfectly with all media types from steam descriptors #1 and #3, crashes on media types from stream descriptor #2, similarly to how Direct Show crashes on still image capture only.
So I get the impression that it's either Media Foundation (or the Windows 7 webcam driver provided by Logitech) is buggy and not marking stream descriptor #2 as still image capture when it should, or I'm checking the wrong flag to determine if it's video capture or still image capture. If it's my mistake, then what is the right way to differentiate between video (#1 and #3) and still image (#2) capture stream descriptors?
Upvotes: 2
Views: 1057
Reputation: 1515
Yes, Mediafoundation doesn't have PIN_CATEGORY_STILL style attribute.
Perhaps you can assume that media type with only 1 fps is still capture.
EDIT
doing some more reseach, there is MF_CAPTURE_ENGINE_STREAM_CATEGORY_PHOTO_DEPENDENT
This applies to MFCaptureEngine and it's for Windows 8...
Upvotes: 0