I have finally managed to drop working with VFW after several problems I have encountered during the application development.
Thanks to StackOverflow, I am now aware that VFW is obsolete and wish to switch to DShow, to let my application work with Vista/W7.
Unfortunately, the work has been made and application has been shipped to the client, but as soon as we realized we have troubles with frame rates on Vista / W7 – we decided to rewrite the video class and use DirectShow to establish a good audio/video capture engine for webcameras.
This will be tricky, as we never coded with DShow, and right now we are looking for few specific examples of how to:
-
Connect to a selected webcamera
similar to: capDriverConnect
-
Set camera resolution to 640×480 and RGB24 format ( we need to do RGB24 to YUV420 for each frame )
similar to: capSetVideoFormat / capCaptureSetSetup
-
Set audio capturing for this webcamera
similar to: capSetAudioFormat
-
Register two callbacks:
- One for video frame ( we will pass frames to video encoder )
similar to: capSetCallbackOnVideoStream
- One for wave buffer ( we will pass wave buffer to audio encoder )
similar to: capSetCallbackOnWaveStream
-
Be able to show a preview window somewhere on parent window
similar to: capPreview
-
Perform Start/Stop operation when needed
- Start – would mean, connect and start capturing audio/video frames
- Disconnect – would mean, stop capturing audio video frames
-
Perform drawing to the actual frame
similar to:
SetBitmapBits(CameraInput.GetFrameBitmap(),w*h*3,vdhdr->lpData);
// draw something with gdi+
GetBitmapBits(CameraInput.GetFrameBitmap(),w*h*3,vdhdr->lpData);//set back the frame with data
All of the above was already made with VFW, but as I wrote before we unfortunately need to switch do Direct Show.
Is there anyone who could help us out achieving a class that could rescue us from months of studying Direct Show ?
Your best bet for examples will be the ones from Microsoft.
Your questions are still phrased in terms of VFW so it’s hard to answer them as written. For example, in DirectShow you wouldn’t register a callback for to encode a video frame. Instead, you’d develop an encoder filter that would receive data from the capture source.
As an alternative, if you’re only targeting Vista and later, there is the Microsoft Media Foundation. I have no experience with it so I don’t know how the learning curve compares to DirectShow.