| Author |
Message |
raddog
Joined: 18 Dec 2005
Posts: 12
Location: Kansas City
|
Posted:
Sun Dec 18, 2005 5:01 pm Post subject:
Grabbing an Image from WMP |
|
|
I am totally new to the WMP SDK as well as ActiveX programming, and I could use some help in interpreting the documentation.
I have three separate tasks I need to do, so I'll create 3 posts. ANY help, suggestions, direction, tips, etc. would be GRATEFULLY received!!! I'm coding in Visual Studio C++, btw.
Per the subject, I need to obtain the image from WMP's window and save it as a file. There's a couple of things I believe to be true:
1) WMP must be paused to get the image
2) A DirectShow "graph" must be installed in the pipeline
3) Installation is done by attaching to your graph's input pin to the output of one graph, your output pin to the input pin of the next graph, and then doing your thing with the stream you receive before passing it on.
This sounds like attaching an interrupt handler in the old TSR way of doing things, or maybe like a series of shell scripts connected by pipes.
Am I on the right track?
If so, here's my confusion:
1) How do you figure out which two "pins" you want to connect to if you simply want to grab the current window off WMP?
2) Once you know the pins, just exactly how do you insert yourself? There's three functions in the "IWMPGraphCreation" interface, and it's not clear to me how to exactly use it.
3) Do you even need to use this interface, or is there a far easier way?
4) I found documentation in the "Embedded OS Dev" portion of MSDN takling about an "IBasicVideo Interface" -- is this available in Win32 and what I want?
I'm just so overloaded with options and layers, my brain is throwing out-of-memory exceptions faster than I can browse MSDN for sample code.
ANY and ALL help will be so greatly appreciated.
Thanks.
- john ferguson, kansas city (raddog58_AT_yahoo.com)
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Dec 18, 2005 9:30 pm Post subject:
Re: Grabbing an Image from WMP |
|
|
raddog wrote:
[CUT]
| Quote: | This sounds like attaching an interrupt handler in the
old TSR way of doing things, or maybe like a series of
shell scripts connected by pipes.
Am I on the right track?
|
No, you're not. Interrupt handlers are in no way related to
how DirectShow graphs work.
A graph is a set of "filters". Each filter perform a
specific set of operations and has a number of input and
output pins. Data flows from an output pin to the connected
input pin of a downstream filter in only one direction.
The specific set of filters in a given graph and the
specific connection topology determine what the graph can
do.
WMP uses DirectShow for playback, which means it internally
builds a graph to play a file. The actual graph depends on
what filters are installed, the type of file, the location
of the file and a few options.
| Quote: | 1) How do you figure out which two "pins" you want to
connect to if you simply want to grab the current window
off WMP?
2) Once you know the pins, just exactly how do you insert
yourself? There's three functions in the
"IWMPGraphCreation" interface, and it's not clear to me
how to exactly use it.
3) Do you even need to use this interface, or is there a
far easier way?
4) I found documentation in the "Embedded OS Dev" portion
of MSDN takling about an "IBasicVideo Interface" -- is
this available in Win32 and what I want?
|
WMP does not give you direct access to its internal graph.
WMP10 provides the IWMPGraphCreation to let you interact
with its graph, before and after it is built, and, as a side
effect, you can get a reference to the graph.
The system's video rendering filters support IBasicVideo and
so the graph object itself supports it.
Keep a reference to the graph after it is built and, when
you want a snapshot, query it for IBasicVideo and use it.
Other techniques in DirectShow require you to insert a
filter before the renderer, either the system's
SampleGrabber or a custom trans-in-place filter. Both are
harder than just using IBasicVideo.
If you are not using WMP10, you can not access its internal
graph without hacking your way in. In this case, either you
use the hack I described many times before or you create a
rendering graph yourself outside of WMP for the same file to
get your snapshots from. One easy way to create this graph
is to use the MediaDet object, part of the DES runtime (see
the DirectShow SDK in the new Platform SDK), but it doesn't
work with every format.
I suggest you get acquainted with DirectShow by reading the
introductions and tutorials in the DirectShow documentation.
Also, take a look at the GraphEdit utility in the SDK to see
what filters and graphs are and play with them in a
graphical way.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
raddog
Joined: 18 Dec 2005
Posts: 12
Location: Kansas City
|
Posted:
Sun Dec 18, 2005 10:43 pm Post subject:
re:Grabbing an Image from WMP |
|
|
<<No, you're not. Interrupt handlers are in no way related to
how DirectShow graphs work. >>
I didn't state that very clearly -- I meant similar in the chaining, to where you either consume the interrupt, pass it on unbaked, or do something processing wise and then pass it on.... which apparently it's really a different scenario, potentially more like piping stdout / stdin in unix scripting.
In any event....
Your explanation is excellent. The part of the documentation that still seems a little fuzzy is the statement:
| Quote: | When you implement IWMPGraphCreation, you must also implement IServiceProvider and return the correct pointer when QueryService is called with IID_IWMPGraphCreation as the value for the second parameter.
(http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/iwmpgraphcreationinterface.asp)
|
It's unclear to me what "the correct pointer" would be... does one pass the pointer to the instance of the CLSID_FilterGraph you create via CoCreateInstance or something else? Still a bit fuzzy....
I think my best bet is to follow your suggestion of reading the D/S documentation a little more thoroughly. I read it once, but the notion of connecting graphs via pinouts made me wonder if I was heading down the wrong path. It should make more sense now.
Thanks again!
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Mon Dec 19, 2005 9:30 am Post subject:
Re: Grabbing an Image from WMP |
|
|
raddog wrote:
| Quote: | When you implement IWMPGraphCreation, you must also
implement
IServiceProvider and return the correct pointer when
QueryService is called with IID_IWMPGraphCreation as the
value for the second parameter.
(http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/iwmpgraphcreationinterface.asp)
[/quote:394bcb759f]
It's unclear to me what "the correct pointer" would be...
does one pass the pointer to the instance of the
CLSID_FilterGraph you create via CoCreateInstance or
something else? Still a bit fuzzy....
|
IWMPGraphCreation is a callback interface so it's not
implemented by WMP but by you. However, WMP will not ask for
it using QueryInterface() directly but it will QI for
IServiceProvider and then call
IServiceProvider::QueryService() to get a reference to
IWMPGraphCreation.
| Quote: | I think my best bet is to follow your suggestion of
reading the D/S documentation a little more thoroughly.
I read it once, but the notion of connecting graphs via
pinouts made me wonder if I was heading down the wrong
path. It should make more sense now.
|
Use GraphEdit in the SDK. Seeing a graphical representation
of a graph you can interact with goes a long way towards
giving sense to it all :-) Anything you can do in GraphEdit
is equivalent to some method call in the API.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
raddog
Joined: 18 Dec 2005
Posts: 12
Location: Kansas City
|
Posted:
Mon Dec 19, 2005 2:32 pm Post subject:
re:Grabbing an Image from WMP |
|
|
| Quote: | IWMPGraphCreation is a callback interface so it's not
implemented by WMP but by you. However, WMP will not ask for
it using QueryInterface() directly but it will QI for
IServiceProvider and then call
IServiceProvider::QueryService() to get a reference to
IWMPGraphCreation. |
Ahhhh, okay, that explanation helps make it click! Somehow I TOTALLY missed the fact this was a callback.
So in the default case (ie, no IWMPGraphCreation handler registered), WMP will obtain the interface to get the provider of this service (if installed), it obtains any runtime flags (GetGraphCreationFlags) which without a handler is a NOP, then calls the PreRender, runs the movie, and calls the PostRender.
Am I on the right track? I think I'm getting there.
Incidentally, I've fired up the graphedit program (changed to graphedt.exe in the Platform SDK I just installed), and I'll mokey around with it. I expanded the filters and there's a lot to choose from. I see the SampleGrabber but not the BasicVideo - it'll be a nice challenge to track it down and quite helpful to see them in action.
Hey thanks again for these tips. I'm sure in a month I'll be shaking my head as to why the f-graphs were stumping me, but for right now every tidbit of info is like an extra lit candle in an otherwise dark cavern. |
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Mon Dec 19, 2005 9:30 pm Post subject:
Re: re:Grabbing an Image from WMP |
|
|
raddog wrote:
| Quote: | So in the default case (ie, no IWMPGraphCreation handler
registered), WMP will obtain the interface to get the
provider of this service (if installed), it obtains any
runtime flags (GetGraphCreationFlags) which without a
handler is a NOP, then calls the PreRender, runs the
movie, and calls the PostRender.
Am I on the right track? I think I'm getting there.
|
More or less. WMP creates the graph anyway but, before doing
so, it tries to get a IWMPGraphCreation from its site (you)
so it can notify you of graoh events and follows your hints.
If you don't provide a IWMPGraphCreation when asked bt WMP,
WMP will simplt go on in its default way without firing
graph-related events (that is, calling the callbacks).
| Quote: | Incidentally, I've fired up the graphedit program
(changed to graphedt.exe in the Platform SDK I just
installed), and I'll mokey around with it. I expanded
the filters and there's a lot to choose from. I see the
SampleGrabber but not the BasicVideo - it'll be a nice
challenge to track it down and quite helpful to see them
in action.
|
Use the menu File -> Render Media File to open a file WMP
can play, for example an AVI, and see the automatically
generated graph, which you can modify or actually run. WMP
does not rely on this automatic graph builing and inserts a
lot of its own private filters, but it will give you an idea
without the need to understand beforehand what each filter
does.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
|
|
|
|