Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Help regarding writing a Source Filter
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alessandro Angeli [MVP::DS/MF]  
View profile  
 More options Feb 16 2006, 2:34 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "Alessandro Angeli [MVP::DS/MF]" <nob...@nowhere.in.the.net>
Date: Thu, 16 Feb 2006 20:34:15 +0100
Local: Thurs, Feb 16 2006 2:34 pm
Subject: Re: Help regarding writing a Source Filter

DevX wrote:
> I agree to your suggestion of a pull model from the
> Filter. But only some more questions (sorry again, I'm
> very newbie on DirectShow and low-level COM Programming):

Instead I disagree. A push model would be easier to
implement. See below.

> my real problem is a confusion about where/when/how the
> CSourceStream-derived class is created when building the
> filter graph.

Your source filter can be created in 2 ways and it's up to
you to decide:

1. you create it anyway you like and add it to the graph
yourself; this way you have a reference to the object and
you can do whatever you need with it

2. the filter graph adds it when it tries to render a custom
URL; this way you need to package the filter in its own COM
inproc server DLL, globally register it, register your
custom protocol and last you will need to enumerate the
filters in the graph to get a reference to it

If your filter is only used internally in your application,
#1 is a lot easier.

> Later, in your reply, you suggest using named pipe. If I
> understand correctly, in this manner you suggest a
> completely separated mode of operation between the dotNET
> code (that write on the pipe unaware of the client) and
> the filter (that can read from the pipe, unaware of the
> writer)...this approach can be Ok for me and much more
> easier to implement,

An alternative would be using UDP sockets: they are
message-based instead of stream-based, so that they would
preserve the sample boundaries without you implementing your
own framing, and as efficient (since they would be routed
over the virtual loopback device), but you would need to
implement your own inter-process security, if local security
is a concern (local meaning on the same machine, since total
security from the outside world would be provided the socket
itself).

> but a more coupled approach (like
> the one I tried to describe with the questions above) is
> possible?

Yes. You can do it in any number of ways depending on your
needs and how complex you want it to be, but this is the
easiest:

1. derive your filter class from CBaseFilter and your output
pin class from CBaseOutputPin

2. in your filter class, override GetPin() and GetPinCount()

3. in your output pin class override GetMediaType(),
CheckMediaType() and DecideBufferSize()

4. add a custom interface to your filter class that has a
single method you call to synchronously feed a data block to
the graph; this method calls GetDeliveryBuffer() on the
output pin, copies the data block to the sample and calls
Deliver() on the output pin

5. you may want to add a couple more methods to the custom
interface to set the number of output pins and their media
types

From the application point of view, pushing data through the
graph will be as simple as calling a normal synchronous
function in VideoForWindows style and the code required to
create filter and pins is less the 3 screenfuls in C++.

This works well unless you need asynchronous processing or
you need to connect to a parser/splitter, which will expect
an async reader upstream instead of a push source (but this
would be easy enough to accomplish as well).

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// a dot angeli at psynet dot net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google