views:

62

answers:

1

I need to split a PCM audio stream with up to 16 channels into several stereo streams. As I haven't found anything capable of doing that, I'm trying to write my first directshow filter.

Anything capable of splitting the audio would be very welcomed but I'm assuming that I must do it so there's what I've done:

At first, I tried to create a filter based on ITransformFilter. However, it seems that it's made thinking of filters with only one input pin and one output pin. As I need several output pins, I disregarded it, however perhaps it can be adapted more easily than I thought, so any advice is highly appreciated.

Then, I begin basing on IBaseFilter. I managed to do something. I create the necessary output pins when the input pin gets connected, and destroy them when the input gets disconnected. However, when I connect any output pin to an ACM Wrapper (just to test it), the input tries to reconnect, destroying all my output pins. I tried to just not destroy them, but then I checked the media type of my input pin and it had changed to a stereo stream. I'm not calling QueryAccept from my code.

How could I avoid the reconnection, or what's the right way to do a demuxer filter?

Edit 2010-07-09: I've come back to ITransformFilter, but I'm creating the necessary pins. However I've encountered the same problem as with IBaseFilter: When I connect my output pin to an ACM Wrapper, the input pins changes its mediatype to 2 channels. Not sure how to proceed now...

+1  A: 

You can take a look at the DMOSample in the Windows Server 2003 R2 Platform SDK. It is also included in older directx sdk's, but not in newer windows sdk's. You can locate it in Samples\Multimedia\DirectShow\DMO\DMOSample. Here is the documentation of this sample.

I have seen someone create a filter based on this which had a stereo input and two mono outputs. Unfortunately I cannot post the sourcecode.

Wimmel
Thank you very much! I will take a look at it.
Jaime Pardos
I'm not sure this is what I need. It seems that the output pins must be declared in advance. Being able to create them in real time would be nice, as I don't know how much channels I've got until the input is connected. Will pick your answer if nobody answers in one day or two, tho.
Jaime Pardos
You can create 16 output pins and only use the pins you need.
Wimmel
Yeah, I thought of that but the "up to 16" could change in the future. When it's "up to 32", what, 32 pins? And then, when someone has a 128 channel stream? Doesn't seem very likely, but again 15 years ago I would have not believed that you could have 64 gb of data in 1 square cm, so...My solution has finally been to write a standard transform filter and connect several instances of it through an Inf Tee, then configuring each one to pick the channels I want. Thank you very much.
Jaime Pardos