简体   繁体   中英

DirectShow BaseClasses - a video renderer class with video and input pin

I couldn't find a suitable renderer class in BaseClasses that has 2 input pins - one for video and one for audio. Can anybody recommend/provide some code?

Regards Dominik

The CBaseRenderer class is a base class for implementing renderer filters. It only supports one input pin though.

I've never encountered a renderer class that handles both audio and video, they're always rendered via separate renderer filters.

The VMR9 renderer (CLSID_VideoMixingRenderer9) is great for rendering video, while the DirectSound Renderer (CLSID_DSoundRender) is used for rendering audio.

Are you maybe trying to get both streams written to disk in a media file? Then you'll need a mux filter that understands both media types. Since I don't know what media types you're using, I could recommend you might have a look at the AVI Mux filter , which does such a job.

I hope that this points you in the right direction ;)

Alternatively you can add sample grabber filters to your media pipeline after your video and audio encoders and packetize the media and deliver the RTP packets in the sample grabber callbacks. The sample grabbers can be connected to the NULL renderer. That way you can avoid writing a filter and focus on the network transport.

Also, you should consider if you even want to mux the streams: usually in RTP video and audio are delivered in separate RTP sessions. If you still want to write a filter with multiple input pins, you can have a look at some baseclasses I wrote for a video mixer available at http://sourceforge.net/projects/videoprocessing/ as a starting point.

As far as I know there aren't any MSDN samples that have multiple input pins, an unfortunate omission.

The GDCL mp4 multiplexer is well written and has multiple input pins and source code is available on a pretty liberal license. It's 'reference quality' having been written by one of DirectShow's original architects. Though the mp4 handling is quite complex the DirectShow side of it is reasonably simple. GDCL mp4 filters

Most filters with multiple input pins will queue the input pins' incoming data in queues of some kind that are processed by a worker thread that generates the file output file or sends processed data out on the output pins or pins. CQueue in the base classes is a good starting point for a queue that blocks readers/writers when empty/full though it will require some extra work to support stopping and flushing. CAMThread is a useful starting point for a worker thread - see CSource for an example implementation.

Additional references How to make a DirectShow Muxer Filter - Part 1 How to make a DirectShow Muxer Filter - Part 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM