diff options
author | Raimo Jarvi <raimo.jarvi@gmail.com> | 2010-07-25 17:01:19 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-08-06 10:20:19 +0100 |
commit | 7ab007bafeb5e3b32b0156235f51c1f4b4f442d9 (patch) | |
tree | d6dc798967596ec467675ad443ed64e7c80ba161 | |
parent | 3579c1164b6420e2aef31028ef09230e3d33925d (diff) |
dshowvideosink: allow changing window ID whilst in PLAYING state
https://bugzilla.gnome.org/show_bug.cgi?id=574290
-rw-r--r-- | sys/dshowvideosink/dshowvideosink.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/dshowvideosink/dshowvideosink.cpp b/sys/dshowvideosink/dshowvideosink.cpp index 8e19e0091..bfc1c2576 100644 --- a/sys/dshowvideosink/dshowvideosink.cpp +++ b/sys/dshowvideosink/dshowvideosink.cpp @@ -82,6 +82,7 @@ static gboolean gst_dshowvideosink_unlock_stop (GstBaseSink * bsink); static gboolean gst_dshowvideosink_set_caps (GstBaseSink * bsink, GstCaps * caps); static GstCaps *gst_dshowvideosink_get_caps (GstBaseSink * bsink); static GstFlowReturn gst_dshowvideosink_show_frame (GstVideoSink *sink, GstBuffer *buffer); +static void gst_dshowvideosink_set_window_for_renderer (GstDshowVideoSink *sink); /* COM initialization/uninitialization thread */ static void gst_dshowvideosink_com_thread (GstDshowVideoSink * sink); @@ -108,6 +109,7 @@ static void gst_dshowvideosink_set_window_id (GstXOverlay * overlay, ULONG window_id) { GstDshowVideoSink *sink = GST_DSHOWVIDEOSINK (overlay); + HWND previous_window = sink->window_id; HWND videowindow = (HWND)window_id; if (videowindow == sink->window_id) { @@ -115,8 +117,21 @@ gst_dshowvideosink_set_window_id (GstXOverlay * overlay, ULONG window_id) return; } - /* TODO: What if we already have a window? What if we're already playing? */ sink->window_id = videowindow; + + /* Update window if we're already playing. */ + if (sink->connected && sink->filter_media_event) { + HRESULT hres; + + /* Return control of application window */ + SetWindowLongPtr (previous_window, GWL_WNDPROC, (LONG)sink->prevWndProc); + SetWindowPos (previous_window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + gst_dshowvideosink_set_window_for_renderer (sink); + + hres = sink->filter_media_event->SetNotifyWindow ((OAHWND)sink->window_id, WM_GRAPH_NOTIFY, 0); + GST_DEBUG_OBJECT (sink, "SetNotifyWindow(%p) returned %x", sink->window_id, hres); + } } static void @@ -535,6 +550,7 @@ LRESULT APIENTRY WndProcHook (HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa * Then forward back to the original window. */ GstDshowVideoSink *sink = (GstDshowVideoSink *)GetProp (hWnd, L"GstDShowVideoSink"); + g_assert (sink != NULL); switch (message) { case WM_GRAPH_NOTIFY: |