• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2008 Pioneers of the Inevitable <songbird@songbirdnest.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __DSHOWVIDEOSINK_H__
21 #define __DSHOWVIDEOSINK_H__
22 
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25 #include <gst/video/gstvideosink.h>
26 
27 #include "dshowvideofakesrc.h"
28 
29 #include <dshow.h>
30 
31 #include "d3d9.h"
32 #include "vmr9.h"
33 #include "evr.h"
34 #include "mfidl.h"
35 
36 #pragma warning( disable : 4090 4024)
37 
38 G_BEGIN_DECLS
39 #define GST_TYPE_DSHOWVIDEOSINK              (gst_dshowvideosink_get_type())
40 #define GST_DSHOWVIDEOSINK(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DSHOWVIDEOSINK,GstDshowVideoSink))
41 #define GST_DSHOWVIDEOSINK_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DSHOWVIDEOSINK,GstDshowVideoSinkClass))
42 #define GST_IS_DSHOWVIDEOSINK(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DSHOWVIDEOSINK))
43 #define GST_IS_DSHOWVIDEOSINK_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DSHOWVIDEOSINK))
44 typedef struct _GstDshowVideoSink GstDshowVideoSink;
45 typedef struct _GstDshowVideoSinkClass GstDshowVideoSinkClass;
46 
47 #define GST_DSHOWVIDEOSINK_GRAPH_LOCK(sink)	g_mutex_lock (&GST_DSHOWVIDEOSINK (sink)->graph_lock)
48 #define GST_DSHOWVIDEOSINK_GRAPH_UNLOCK(clock) g_mutex_unlock (&GST_DSHOWVIDEOSINK (sink)->graph_lock)
49 
50 /* Renderer-specific support classes */
51 class RendererSupport
52 {
53 public:
~RendererSupport()54   virtual ~RendererSupport() {};
55   virtual const char *GetName() = 0;
56   virtual IBaseFilter *GetFilter() = 0;
57   virtual gboolean Configure() = 0;
58   virtual gboolean SetRendererWindow(HWND window) = 0;
59   virtual void PaintWindow() = 0;
60   virtual void MoveWindow() = 0;
61   virtual void DestroyWindow() = 0;
62   virtual void DisplayModeChanged() = 0;
63   virtual void SetAspectRatioMode() = 0;
64 };
65 
66 struct _GstDshowVideoSink
67 {
68   GstVideoSink sink;
69 
70   /* Preferred renderer to use: VM9 or VMR */
71   char *preferredrenderer;
72 
73    /* The filter graph (DirectShow equivalent to pipeline */
74   IFilterGraph *filter_graph;
75 
76   IMediaEventEx *filter_media_event;
77 
78   /* Renderer wrapper (EVR, VMR9, or VMR) and support code */
79   RendererSupport *renderersupport;
80 
81   /* Our fakesrc filter */
82   VideoFakeSrc *fakesrc;
83 
84   /* DirectShow description of media type (equivalent of GstCaps) */
85   AM_MEDIA_TYPE mediatype;
86 
87   gboolean keep_aspect_ratio;
88   gboolean full_screen;
89 
90   /* If the window is closed, we set this and error out */
91   gboolean window_closed;
92 
93   /* The video window set through GstXOverlay */
94   HWND window_id;
95 
96   /* If we created the window, it needs to be closed in ::stop() */
97   gboolean is_new_window;
98 
99   gboolean connected;
100   gboolean graph_running;
101 
102   /* If we create our own window, we run it from another thread */
103   GThread *window_thread;
104   HANDLE window_created_signal;
105 
106   /* If we use an app-supplied window, we need to hook its WNDPROC */
107   WNDPROC prevWndProc;
108 
109   /* Lock for transitions */
110   GMutex graph_lock;
111 
112   gboolean comInitialized;
113   GMutex   com_init_lock;
114   GMutex   com_deinit_lock;
115   GCond    com_initialized;
116   GCond    com_uninitialize;
117   GCond    com_uninitialized;
118 };
119 
120 struct _GstDshowVideoSinkClass
121 {
122   GstVideoSinkClass parent_class;
123 };
124 
125 GType gst_dshowvideosink_get_type (void);
126 
127 G_END_DECLS
128 #endif /* __DSHOWVIDEOSINK_H__ */
129