Log in

View Full Version : Developing a Directshow filter who spews...


rogster
6th November 2007, 21:39
I need to develop a Directshow filter who spews frame number and/or current system time to a 2nd java program.

Basically what I want is the ability for my java app to call on the filter to return it those values for the current frame.

I've never done any JNI but I think it to be the solution here, but since I'm treading on new ground, I wanted to ping ya'll for your guidance and first thoughts on how to accomplish this.

I've already tinkered with Directshow and made a simple transform filter that converts video to grayscale, the next step is to just pass the original frame on without modification but to keep track for which frame is being processed, and to make that data available to the calling java app.

I can't really say much about the rest of the program flow, but when an event occurs, i need the ability to extract the time/frame number for the current frame.

Is this even possible? I've found nothing along these lines when i googled it.

Again please spare me the flaming :) I KNOW I'm a n00b, but I'm trying to change that.

Ebobtron
7th November 2007, 04:54
IMediaSeeking uncovers GetPositions(*pCurrent,*pStop)

Of course everything depends upon your filter graph as a whole. If one of the filters isn't seek friendly the result may be unpredictable. I my case I have luck and get the current position and the time reference value for the last frame which it what the documentation advertises. :) I am using the c c++ win32 api so maybe not worky for your java stuff.

Hope that helps, if not, never mind.

LoRd_MuldeR
14th November 2007, 08:56
I am using the c c++ win32 api so maybe not worky for your java stuff.
Java programs can call "native" code from DLL's written in C or C++ ;)
You'll need that as soons as your Java app has to communicate with the underlying OS, e.g. for all the GUI and I/O stuff.
Usually Java hides those calls in some Wrapper Class, but you can use them yourself when needed...

See:
http://www.javaworld.com/javaworld/javatips/jw-javatip23.html

JohnnyMalaria
14th November 2007, 15:02
If the Java app is separate from the filter graph process, you can use named events (assuming Java supports them) and wait for the filter to set the event.

I've used this successfully for sending entire frames from one app on one PC to another on a different PC.

LoRd_MuldeR
14th November 2007, 19:09
If the Java app is separate from the filter graph process, you can use named events (assuming Java supports them) and wait for the filter to set the event.
I think if you compile your C/C++ code into a DLL file and call it from a Java program, then your DLL will run in same process as the Java VM...