Graph Works in GraphEdit but not in Code  
Author Message
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

I wrote a DVD player application and built the graph manually (didn't use DVDGraphBuilder and its auto graph building feature, just a normal GraphBuilder with manually connected filters). I added the graph created at runtime to the ROT (Runtime Object Table) and then did "Connect to Remote Graph" in graph edit, thereby loading the graph from my code into graph edit. If I play this graph in graph edit, it works perfectly. But in my program the first screen shows up for about 1 second and then it goes white and then the dvd plays with no video, only audio (with the ActiveMovie window continually filled a white screen). I can't figure out why the graph will not keep on rendering the video when running the code, since the exact same graph (same because I loaded it from my code at runtime) works when run in GraphEdit. Here is a link to the source: http://www.hide-link.com/
Also, here is a link that has an image of the graph that is loaded into graph edit at runtime and two images of the results I get when I run my code. http://www.hide-link.com/

Anyone have any idea what could be happening Any help would be greatly appreciated; I don't really know what to do to try to find out what is wrong.
Thanks.

--Jon G.--


Software Development for Windows Vista17  
 
 
Michel Roujansky





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

Jon,

what may happen is that when you reload the graph, you get different connection parameters (mediatypes, or buffers) from those you get when building the graph in the application (it might be dependent on the order in which you establish the connections).

You should compare for the two graphs all connection mediatypes. Could you also post links to the two .grf files (the one saved from attaching to your application, and the good one, after reloading .grf from file and resaving) ( I mean, the .grf files themselves, not the image of the graphs).

Cheers,



 
 
grolich





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

I haven't had the time to look at the code yet, but from the description you gave it sounds like a problem with handling the video window (IVideoWindow), or with a related interface (like the IMediaEventEx...).

The only difference between graphedit and your app (assuming you're not setting incorrect formats from your code...) is that the graphedit app handles its own IVideoWindow interface, and it does it very well... Hope looking at the code will teach me more.

 
 
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

 
Could you also post links to the two .grf files (the one saved from attaching to your application, and the good one, after reloading .grf from file and resaving)

Well, there is only one graph file. The one that I get from attaching to my application and saving (once that is) is the good one. It runs well in graph edit, without needing to reload and resave. Here is the link to that file:
http://acidrainlite.googlepages.com/GraphLoadedFromProgram.GRF

Thanks again.

 
 
Michel Roujansky





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

Perhaps you should handle DVD events

"The DVD Navigator sends notifications to an application-specified window when certain events take place, ..... The application specifies the window that will handle the event notifications by using the IMediaEventEx pointer to call SetNotifyWindow, ...."

http://msdn2.microsoft.com/en-gb/library/ms783760.aspx



 
 
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top


int i;
while(i!=100)
{
cin>>i;
}
Since I didn't initialize i and then compared it to 100 in the next line, I get a runtime error:
http://acidrainlite.googlepages.com/run_time_error
However, the video actually runs perfectly behind this error message as long as I do not click Abort.
I used the cin>>i to keep the application from completing (if I removed it the program would say "press any key to continue" and have no time to play the video), but I think the cin is the problem. I think that it is keeping the video from being able to refresh/it is holding up the ActiveMovie Window somehow (note the "not responding" in the title of the ActiveMovie Window three images down http://acidrainlite.googlepages.com/almostworking (representative of when the program is run without getting the runtime error)). Am I right in saying that the cin could be the problem Is there a different way I am supposed to keep the program from ending How are other people doing it


The Section of the code in question is:

media_control->Run();

int i;
while(i!=100)
{
cin>>i;
}
where I run the graph and then call cin (need to enter 100 to exit) to keep the program from completeing.

Thanks.


 
 
Michel Roujansky





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

IMediaEvent *pEvent;
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
media_control->Run();
pEvent->WaitForCompletion(INFINITE, &evCode);
This prevents the application from exiting before the end of the clip...


 
 
Michel Roujansky





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

IMediaEvent *pEvent;
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
media_control->Run();
pEvent->WaitForCompletion(INFINITE, &evCode);
This prevents the application from exiting before the end of the clip...

 
 
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

That worked!
Though I can't drag the window around, nor can I maximize it; it is acting like it is completely tied up in playing the video and can't recieve any other events.
Thanks for all of your help.

 
 
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

Sorry for another question, but do you have any idea why it would be getting tied up like it is. That line of code (WaitForCompletion(INFINITE,&EventCode);) fixes the problem so that the DVD plays, but the ActiveMovie Window cannot be dragged around (seemingly because it is completely tied up playing the video and it isnt responding to the drag events) and if I drag something over the ActiveMovie Window and then drag it away, it doesn't refresh and the image of what I dragged over the ActiveMovie wWndow is still painted on the ActiveMovie Window until a few seconds later when it goes away. This doesn't happen in GraphEdit.

Thanks again for your help.

 
 
LGS





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

It sounds like you have the wait in a bad place. This isn't in your message processing loop or anything, is it
 
 
Michel Roujansky





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

A console app is definitely not the best solution to run a video display. You need a message pump to handle refresh messages (Graphedit has one). I suggest you move your code to a windowed app.

You might look at the following thread. It is suggested that letting DirectShow create the video renderer might solve your problem. (You can do this by not adding any video renderer to the graph, and by asking DS to render the last pin before the renderer).

http://groups-beta.google.com/group/microsoft.public.win32.programmer.directx.video/browse_frm/thread/49f6e79674f10082/c7cf17c111355631 lnk=gst&q=console+message+pump&rnum=4#c7cf17c111355631

Quote

"Do you create the [renderer] instance yourself If you render the video file
without directly creating the video renderer yourself, I believe the
renderer is created on a thread owned by DirectShow, which has a message
pump. If you create the renderer yourself, your thread owns it and you
need your own message pump. "

Unquote



 
 
AcidRainLiTE





PostPosted: DirectShow Development, Graph Works in GraphEdit but not in Code Top

Not creating the video renderer and making DirectShow handle the renderer (by telling the graph manager to render the pin) worked.

Thanks.