AFgone
AFgone

Reputation: 1250

DirectShow Auto Resize

I was using my directshow app as an in-process library. However now I need to run it as a separate background process. So rendering surface is on another process. I'm passing handle (hwnd) of the render surface (picturebox) to the background process.

Previously I had this for resizing; ( Since it was in same process and I have access to the Control directly)

...      
m_VideoControl.Resize += new EventHandler(VideoControl_Resize); 
...

private void VideoControl_Resize(object sender, EventArgs e)
        {
            lock (m_csAsyncLock)
            {
                ResizeVideoWindow();
            }
        }

protected virtual void ResizeVideoWindow()
        {
            if (m_VideoWindow != null && m_VideoControl != null)
            {
                m_VideoWindow.SetWindowPosition(0, 0, m_VideoControl.Width, m_VideoControl.Height);
            }
        }

However now I don't have access to the direct Control so I can not subscribe to the VideoControl_Resize event. I only have the handle of the control.

How can I make my video to resize if external control is resized?

If possible I don't want to use a new filter and solve it like before SetWindowPosition function?

Upvotes: 0

Views: 346

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69662

If your instance of video renderer filter is running in context of another process, your Resize handler needs to pass control to that process by posting a message or otherwise using interprocess communication, and receiving the event in the other process you are to call IVideoWindow.SetWindowPosition there, in the process where video renderer runs.

In order to make it more convenient, I would offload not just a graph with a video renderer to a helper process, but also a hosting window or control. This way it is sufficient for a parent UI handler to resize the children the usual normal way, cross process communication would take place between the windows, and helper process window will receive again normal UI messages and events letting you handle them the direct way and manage your DirectShow video renderers.

Upvotes: 1

Related Questions