Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VCam Filter - Solved issue with the Flash Player

79 views
Skip to first unread message

stoica...@gmail.com

unread,
Jan 4, 2007, 5:09:43 PM1/4/07
to
Hi,

I am glad that i finally managed to find a place where to ask questions
and probably get some answers too.
>From what i see, most of the questions here are the type of "how may i
do this, and that", in essence they are given by people who do not read
documentation, or maybe not enough.

I also notice the tone used by the ones that know the answers to most
of the problems, is almost frustrating and in some cases it gives you
the impression that it lacks respect. For me, as a programmer, it is
normal to find unusual things in my daily life, like the need to have a
DirectShow virtual camera emulated filter, for a certain solution.

I read the docs, i read the APIs, i read the samples, i download
PlatformSDK, i download WinDDK, i download DirectX SDK, most of these
are very uncommon to an every day application developer.

You, the ones literate in DirectShow, forget that, people like me and
other, need the "interest" factor also, we need guidance, we, for sure,
do not need the exact solution to our problems as you say. We need tips
& tricks on what to follow, most of the time, your answers are not
actual CODE, but a few words.

And this DirectShow its so mangled, and so weird API, how may i talk
about this to a developer that uses .NET SDK, VCL, or even MFC. Its
infuriating!

First we read books about DS, then we find out that ... wait .... we
have BaseClasses, located in what do you know ... "samples" folder of
... NOT DIRECTX, but PlatformSDK .... gees ..... never to mention the
lack of sln or prj files. ( Yeas i know tmhare ... )

Leaving all these behind, i return to letting the people interested,
because it seems that the ones that find out or play with it, are
keeping this for themselves, like in a "indian cast" organization, like
in a special guild.


Fixing the FLASH PLAYER issue of the Virtual Camera ( and probably
other software issues ) :

1) In the file Filters.cpp of http://tmhare.mvps.org/downloads/vcam.zip
( aka vcam , vcam.zip )

there is this method HRESULT STDMETHODCALLTYPE
CVCamStream::SetFormat(AM_MEDIA_TYPE *pmt)

in the method body you have:
m_mt = *pmt
comment this line, make it :
//m_mt = *pmt;

This will fix the flash player issue inside the browser, you will see
the colored dots here also line in GraphEdit, when you test the filter.

2) Now probably you may want to add a custom source image, not random
colored dots, to this virtual camera filter :

All that i know is that it must happen in :

HRESULT CVCamStream::FillBuffer(IMediaSample *pms)

for a test, just change remove random() function in the "for" loop, and
change it to :
pData[i] = i;

you will see some grandiental stripes.

Now here you may :

1) Get Video Stream from a real hardware camera and pass it to pData.
2) Get Video Stream from a real hardware IP camera, over some protocol.
3) Get Video Stream from an image file.
4) Get Video Stream from a video file.
5) Get Video from Desktop Screenshots.
6) Get Video Stream from a custom source. ( like Ball sample )

you can imagine very nifty and nice things, that will always happen in
this magic function, to give your flash player capabilities never seen
before (using red5 or media server, you can the broadcast this to a
large audience).

3) Even fixed in this way, it has some leaks, that we may get rid of
them, with the proper guidance, without tracing/logging every line of
the sample program to see where the leak appears.

Conclusion :

For (1) : I do not actually understand what that data assignment line
really does (m_mt = *pmt), i do not know how may this affect the
behaveour of the vcam.ax itself.

IF SOMEONE KNOWS, please post it here. Please let us know what m_mt =
*pmt does, other that passing by some memory addresses to a certain
media_type which is obvious.

For (2) : Its up to you developers who read this, to discover how to
fill that data structure, if you discover, or find out how to use
FillBuffer or 1-6 sources, please post it here, so that others in need
may find help.

For (3) : I turn my hat to the one that originally developed this
sample source filter, but i put it back knowing that he did not even
let a notice about possible memory leaks and tips on where to look to
find and remove them. Also, i ask you developers out there, to give
further notice on how to fix those leaks ( they appear just after you
close the browser window, when the flash player is unloaded, and then
the flash player unloads the vcam.ax )


I also give you a tip on how to debug Flash Applications, either you
create a projector (standalone exe) of the swf that uses vcam.ax camera
and then you use Debug->Attach to Process and then select the running
projector exe, or you just put it online and attach to the browser that
is soon to open the camera swf url.


PLEASE GIVE HELP on ALL OF US on this issues.
My kind regards to you developers out there, that do not forget the
beauty of descovering new things, even if in big need, sharing them.

xbunny

unread,
Jan 4, 2007, 8:42:18 PM1/4/07
to
stoica...@gmail.com wrote:
> 1) In the file Filters.cpp of http://tmhare.mvps.org/downloads/vcam.zip
> ( aka vcam , vcam.zip )
>
> there is this method HRESULT STDMETHODCALLTYPE
> CVCamStream::SetFormat(AM_MEDIA_TYPE *pmt)
>
> in the method body you have:
> m_mt = *pmt
> comment this line, make it :
> //m_mt = *pmt;
>
> This will fix the flash player issue inside the browser, you will see
> the colored dots here also line in GraphEdit, when you test the filter.
>
> Conclusion :
>
> For (1) : I do not actually understand what that data assignment line
> really does (m_mt = *pmt), i do not know how may this affect the
> behaveour of the vcam.ax itself.
>
> IF SOMEONE KNOWS, please post it here. Please let us know what m_mt =
> *pmt does, other that passing by some memory addresses to a certain
> media_type which is obvious.

I dont know what the 'flash player issue' is but anyways I wanted to
help so I downloaded the vcam source you referenced. In the source code
directly above the method you refer to there is a comment which says
IAMStreamConfig, look it up in the docs and we see what that interface
does and that it has the method SetFormat, one would think thats what
this method is an implementation of and can confirm the assumption by
reading the header. Further more by searching the docs for m_mt I get
just one hit which is that is a property of the CBasePin class.
Examining the header shows the CVCamStream class derives from
CSourceStream. Looking in the docs for CSourceStream they show that this
class derives from CBasePin (theres a nice diagram even!). Read the docs
for CBasePin::m_mt and they state that it determines the media type of
the pins connection. You can see that slightly further in the GetFormat
implementation that it calls IFilterGraph::Reconnect, this is consistant
with what you might expect a pin that implements
IAMStreamConfig::SetFormat to do given what the docs describe it should
do. Examining the docs for IFilterGraph::Reconnect you will see that
they state that before calling the function the pin should call
QueryAccept to verify that the upstream pin can accept the new type, the
vcam SetFormat implementation fails to do this! the docs state that
failing to do this may result in the graph being left in an inconsistant
state if the upstream pin cannot accept the new format.
So to answer your question, I would suggest that failing to call m_mt =
*pmt means that SetFormat does nothing as the new format is not set on
the pin and it reconnects to the upstream pin without the new format.
Perhaps the root of the problem is that in your graph the upstream pin
cannot accept the requested type and the vcam SetFormat has missed this.

I have a question for you, if you didnt already know what I described
above then how did you arrive at the solution of commenting out that
line to solve your problem?

Bunny

stoica...@gmail.com

unread,
Jan 5, 2007, 6:02:01 AM1/5/07
to
Thanks Bunny, for your intervention

Well, how did i come up to that ?
In a brainless way, i debugged the dll (VcamD.ax) with "Attach To
Process ..."

I simply open a browser page with a flash player applet, there, in the
player i use the camera.

I took it step by step until it crashed, you may check it out by
opening :

http://vs03.netstairs.ro/gion/milka/publisher.html

And then right click on the right in the browser where the flash applet
is ( an area of 320x240 starting from the top left corner of the
document view of the browser ) and from there select "settings" from
the context menu, bellow you'll have a camera like icon, press that
icon then select the VCamD camera from the menu. If the colored dots
appear then it means the camera works, if they dont appear and browser
crashes, then it doesnt work.

At this point the debugger was at that line in the source of the VCamD
( the beauty of debugging ).
I just commented that out, unregisterd the old VCamD then reregister
it, and there we have it, a working, dot generator version of VCamD.
If you close your browser in this phase, when colored dots show up, you
will be presented with some error messages of some objects not being
freed.

This is how i arrived to that solution.

I will take everything that you explained above and follow it by the
book to see how i can make everything work with no errors, then
concentrated on developing sources for the FillBuffer, with the promise
that i will post here everything that i find out.

All the best!

xbunny

unread,
Jan 5, 2007, 8:08:29 AM1/5/07
to
stoica...@gmail.com wrote:
> Thanks Bunny, for your intervention
>
> Well, how did i come up to that ?
> In a brainless way, i debugged the dll (VcamD.ax) with "Attach To
> Process ..."
>
> I simply open a browser page with a flash player applet, there, in the
> player i use the camera.
>
> I took it step by step until it crashed, you may check it out by
> opening :
>
> http://vs03.netstairs.ro/gion/milka/publisher.html
>
> And then right click on the right in the browser where the flash applet
> is ( an area of 320x240 starting from the top left corner of the
> document view of the browser ) and from there select "settings" from
> the context menu, bellow you'll have a camera like icon, press that
> icon then select the VCamD camera from the menu. If the colored dots
> appear then it means the camera works, if they dont appear and browser
> crashes, then it doesnt work.
>
> At this point the debugger was at that line in the source of the VCamD
> ( the beauty of debugging ).
> I just commented that out, unregisterd the old VCamD then reregister
> it, and there we have it, a working, dot generator version of VCamD.
> If you close your browser in this phase, when colored dots show up, you
> will be presented with some error messages of some objects not being
> freed.
>

Interesting that it crashed, was the pointer that it was assigning to
m_mt NULL? this is another check the vcam SetFormat implementation does
not do and is another bug, In fact the docs suggest that setting NULL
for the new media type is ok and that generally it should reset the
media type to the default, I suppose though the CMediaType class could
have magic in its assignment handling for NULL pointers, looking in my
copy of the baseclasses it doesnt appear to!
Studying more closely the vcam SetFormat it doesnt appear to validate
the media type at all, although the supported media types are passed
back to whereever via the GetStreamCaps method, its quite possible an
application might ignore them and try something completely different
anyways!

Bunny

stoica...@gmail.com

unread,
Jan 5, 2007, 8:22:57 AM1/5/07
to
I take all of these into high consideration.

Setting m_mt to NULL and just this, will cause the flash player to
crash.

I take it step by step until i find the monster here.

jd6strings

unread,
Jan 12, 2007, 12:11:20 PM1/12/07
to
This is an interesting post. I've been looking into writing a source
filter to grab frames from an Axis IP camera (using HTTP) and then
publish to Red5. Has anyone done this using modified vcam code? If
so...I'd like to see the source.

It's been a while since I've written DirectX code so I'm putting my dev
environment back together to begin working on the above mentioned.
Anybody interested in giving the above mentioned a whirl?

rep_movsd

unread,
Jan 14, 2007, 5:25:33 AM1/14/07
to
Whoaaa!!

I was off getting married and meanwhile everyone found holes in my code
( blush! cringe! ).

The SetFormat() implementation does seem broken.
The code should actually be similar to the one in the DX9 docs under
the topic :
IAMStreamConfig Interface -> Exposing Capture and Compression Formats
-> Reconnecting Your Input to Ensure Specific Output Types

I have done some projects to stream IP cams (DLink, Varieon) input via
WM encoder to a WMS server,
MPEG2 DVB broadcast to WM Encoder and Axis IP cam to On2 Flix encoder.

FWIW, WM encoder isnt very finicky and altho it queries for
IAMstreamconfig, no method on that interface ever seemed to be called.
A similar virtual audio device too worked fine with WM encoder.
On2 flix was finicky about the virtual audio device ( by pure chance i
found out that it expects the output pin of the audio device to be
labelled "Capture" ), After much fight, i threw that out and settled
for using Virtual Audio cable or stereo mix for that app.

I'll try sometime to clean up the VCam code and make it more readable
and correct.
Meanwhile Libgraph COM version is soon to be uploaded.

Regards
Vivek

The March Hare [MVP]

unread,
Jan 14, 2007, 2:28:26 PM1/14/07
to
On 14 Jan 2007 02:25:33 -0800, rep_movsd wrote:

> I'll try sometime to clean up the VCam code and make it more readable
> and correct.
> Meanwhile Libgraph COM version is soon to be uploaded.

Send me the updates if you want me to post them to my downloads page.
Thanks.


--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution

0 new messages