PDA

View Full Version : Getting event from MVSmartControlClass



derek
May 26, 2004, 01:44:39
I'm a little unsure when to use MVSmartControlClass verses AxMVSmartControl?

I was writing a transcode application that will not Render video to the screen. As such, I created a MVSmartControlClass to do the work. I want to get an EndOfStream event to know when the processing is finished. I use the following code:

MVSmartControl.MVSmartControl sc = new MVSmartControl.MVSmartControlClass();
...
sc.EndOfStream +=new _IMVSmartControlEvents_EndOfStreamEventHandler(sc_ EndOfStream);

However, sc_EndOfStreams is never called when the stream ends.


The following works (ocxSC_EndOfStream is called):

AxMVSmartControl.AxMVSmartControl ocxSC = new AxMVSmartControl.AxMVSmartControl();
...
ocxSC.EndOfStream +=new EventHandler(ocxSC_EndOfStream);


And the following also works:

AxMVSmartControl.AxMVSmartControl ocxSC = new AxMVSmartControl.AxMVSmartControl();
...

MVSmartControl.MVSmartControl sc = (MVSmartControl.MVSmartControl)ocxSC.GetOCX();
sc.EndOfStream +=new _IMVSmartControlEvents_EndOfStreamEventHandler(sc_ EndOfStream);


So it looks like events will not be generated using only the MVSmartControlClass? I know I can make the OCX not visible but it just seemed like using the MVSmartControlClass directly was the proper thing to do. What else is its purpose?

Thanks in advance for help.

Bernd Peretzke
May 27, 2004, 14:40:32
Hello,

I think you have to call the Create method from MVSmartControl but why do you not use AxMVSmartControl and make it invisible if you have no video output?

Regards
Bernd Peretzke

derek
May 27, 2004, 21:10:48
There is no MVSmartControl.Create??

If we are making a transcoder, there is not necessarily any UI. We would like to make this usable from the command line, a GUI, or encapsulated into a worker thread without access to a UI.

If we use AxMVSmartControl, then we must have a Form to place it in. Now we could create a form but to actually get the OCX to be created, it must be added to the forms Controls list and while the form is being shown. The following code demonstrates at a minimum what is needed to get a valid IMVSmartControl:

Form f = new Form();
f.StartPosition = FormStartPosition.Manual; // allow it to be moved off screen
f.SetDesktopLocation( 5000, 0 ); // move it off screen so no one will see it when it is shown
f.Show(); // needed for the OXC to be created
f.Controls.Add( ax ); // needed forthe OCX to be created
if (ax.Created)
{// only TRUE if both preceeding line happen
IMVSmartControl sc = (IMVSmartControl)ax.GetOcx(); // GetOcx is null if Show and Add don't occur
}
f.Hide(); // we don't really want it visible

Compare this to the desired:
MVSmartControl sc = new MVSmartControl.MVSmartControlClass();

Bernd Peretzke
May 28, 2004, 10:55:43
Hi,

the problem with

MVSmartControl sc = new VSmartControl.MVSmartControlClass();

is that the control need a window to get end of stream notifications from the filter graph. The new operator doesn't create that window so the control can't receive the end of stream notifications and can't fire the EndOfStream event.

Regards
Bernd Peretzke

derek
May 28, 2004, 20:29:10
Yes, I discovered this. It also needs to have a message pump too.