Luke
Luke

Reputation: 5971

How to develop a video combiner/builder filter in directshow

I am trying to build a filter. It should have 3 video input as well as 1 audio input and build a vido file according to a fixed schema. An example of this schema might be: "Play 3 seconds of the first source; then play 3 seconds of the second source; play 3 seconds of the third source; repeat"

There are some tutorials on the web on how to build filters, but I have some questions:

Is it correct to use a transform filter baseclass for this projcet?

Do I need to create custom pinclasses?

In which function is the actual video from the source passed to the filter where i can grab it?

How do I make some kind of synchronisation between the pins?

Assuming I had only one source: Could I just copy the value of the input sample to the output sample?

How do I send data to the output pin?

Upvotes: 0

Views: 114

Answers (2)

CPlusSharp
CPlusSharp

Reputation: 891

Why do you need an own filter for this? With DirectShowEditingServices you have a complete infrastrucure to build playlist and all. But this works only for file sources.

To work with Live-sources, the best solution would be GMFBridge. Here you create 1 to N Graphs for you sources and one playback/capture Graph. Then in the GMFBridge you can switch the connection from source to playback Graph.

Upvotes: 0

Roman Ryltsov
Roman Ryltsov

Reputation: 69734

Is it correct to use a transform filter baseclass for this project?

No, explained here: DirectShow Filter: Transform

Do I need to create custom pinclasses?

Most likely. You need media type checking, then you would want to pass data to the filter class with identification on which pin it was received.

In which function is the actual video from the source passed to the filter where i can grab it?

The earliest point where you have the data under your control is IPin::Receive method on input in class.

How do I make some kind of synchronisation between the pins?

It's completely up to you: you are supposed to implement a sort of input queues, then match data from input queues to produce output. You are responsible to block execution on pins if you want them to wait until other input streams keep up and supply their data.

Assuming I had only one source: Could I just copy the value of the input sample to the output sample?

Input and output data come as media samples - objects that belongs to allocators. Actual copying depends on whether pin allocators are the same or different, in the latter case whether they are compatible. All in all, yes you can copy data.

How do I send data to the output pin?

CBaseOutputPin::Deliver gets you this (actually calls IPin::Receive of the connected downstream pin).

Upvotes: 2

Related Questions