Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DirectShow - How to read a file from a source filter

119 views
Skip to first unread message

omri

unread,
Mar 20, 2012, 10:19:18 AM3/20/12
to
I'm writing a DirectShow source filter which is registered as a
CLSID_VideoInputDeviceCategory, so it can be seen as a Video Capture
Device (from Skype, for example, it is viewed as another WebCam). My
source filter is based on the VCam example from here, and, for now,
the filter produces the exact output as this example (random colored
pixels with one Video output pin, no audio yet), all implemented in
the FillBuffer() method of the one and only output pin.

Now the real scenario will be a bit more tricky - The filter uses a
file handle to a hardware device, opened using the CreateFile() API
call (opening the device is out of my control, and is done by a 3Party
library). It should then read chunks of data from this handle (usually
256-512 bytes chunk sizes). The device is a WinUSB device and the
3Party framework just "gives" me an opened file handle to read chunks
from. The data read by the filter is a *.mp4 file, which is streamed
from the device to the "handle".

This scenario is equivalent to a source filter reading from a *.mp4
file on the disk (in "chunks") and pushing its data to the DirectShow
graph, but without the ability to read the file entirely from start to
end, so the file size is unknown (Correct?).

I'm pretty new to DirectShow and I feel as though I'm missing some
basic concepts. I'll be happy if anyone can direct me to solutions
\resources\explanations for the following questions:

1) From various sources on the web and Microsoft SDK (v7.1) samples, I
understood that for an application (such as Skype) to build a correct
& valid DirectShow graph (so it will render the Video & Audio
successfully), the source filter pin (inherits from CSourceStream)
should implement the method "GetMediaType". Depending on the returned
value from this implemented function, an application will be able to
build the correct graph to render the data, thus, build the correct
order of filters. If this is correct - How would I implement it in my
case so that the graph will be built to render *.mp4 input in chunks
(we can assume constant chunk sizes)?

2) I've noticed the the FillBuffer() method is supposed to call
SetTime() for the IMediaSample object it gets (and fills). I'm reading
raw *.mp4 data from the device. Will I have to parse the data and
extract the frames & time values from the stream? If yes - an example
would b great.

3) Will I have to split the data received from the file handle (the
"chunks") to Video & Audio, or can the data be pushed to the graph
without the need to manipulate it in the source filter? If split is
needed - How can it be done (the data is not continuous, and is
spitted to chunks) and will this affect the desired implementation of
"GetMediaType"?

Please feel free to correct me if I'm using incorrect terminology.

Thanks :-)
0 new messages