1 /* GStreamer
2  * Copyright (C) 2012 Roland Krikava <info@bluedigits.com>
3  * Copyright (C) 2010-2011 David Hoyt <dhoyt@hoytsoft.org>
4  * Copyright (C) 2010 Andoni Morales <ylatuya@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 #ifndef _GSTD3DVIDEOSINK_H_
22 #define _GSTD3DVIDEOSINK_H_
23 
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/video/gstvideosink.h>
27 #include <gst/video/videooverlay.h>
28 #include <gst/video/navigation.h>
29 
30 #include "d3dhelpers.h"
31 
32 G_BEGIN_DECLS
33 
34 #define GST_TYPE_D3DVIDEOSINK                     (gst_d3dvideosink_get_type())
35 #define GST_D3DVIDEOSINK(obj)                     (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3DVIDEOSINK,GstD3DVideoSink))
36 #define GST_D3DVIDEOSINK_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3DVIDEOSINK,GstD3DVideoSinkClass))
37 #define GST_D3DVIDEOSINK_GET_CLASS(obj)           (GST_D3DVIDEOSINK_CLASS(G_OBJECT_GET_CLASS(obj)))
38 #define GST_IS_D3DVIDEOSINK(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3DVIDEOSINK))
39 #define GST_IS_D3DVIDEOSINK_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3DVIDEOSINK))
40 
41 typedef struct _GstD3DVideoSink GstD3DVideoSink;
42 typedef struct _GstD3DVideoSinkClass GstD3DVideoSinkClass;
43 
44 struct _GstD3DVideoSink
45 {
46   GstVideoSink       sink;
47   GstD3DData         d3d;
48 
49   GstCaps *          supported_caps;
50 
51   GstVideoFormat     format;
52   GstVideoInfo       info;
53   gint               width;
54   gint               height;
55   GstBufferPool      *pool;
56   GstBufferPool      *fallback_pool;
57   GstBuffer          *fallback_buffer;
58 
59   GstVideoRectangle  crop_rect;
60   GstVideoRectangle  render_rect;
61 
62   GRecMutex    lock;
63   GThread *internal_window_thread;
64 
65   /* Properties */
66   gboolean           force_aspect_ratio;
67   gboolean           create_internal_window;
68   gboolean           stream_stop_on_close;
69   gboolean           enable_navigation_events;
70 };
71 
72 struct _GstD3DVideoSinkClass
73 {
74   GstVideoSinkClass parent_class;
75   GstD3DDataClass   d3d;
76   GRecMutex   lock;
77 };
78 
79 #define LOCK_SINK(sink) G_STMT_START { \
80     GST_TRACE_OBJECT(sink, "Locking sink from thread %p", g_thread_self()); \
81     g_rec_mutex_lock(&sink->lock); \
82     GST_TRACE_OBJECT(sink, "Locked sink from thread %p", g_thread_self()); \
83 } G_STMT_END
84 #define UNLOCK_SINK(sink) G_STMT_START { \
85   GST_TRACE_OBJECT(sink, "Unlocking sink from thread %p", g_thread_self()); \
86   g_rec_mutex_unlock(&sink->lock); \
87 } G_STMT_END
88 #define LOCK_CLASS(obj, klass) G_STMT_START { \
89     GST_TRACE_OBJECT(obj, "Locking class from thread %p", g_thread_self()); \
90     g_rec_mutex_lock(&klass->lock); \
91     GST_TRACE_OBJECT(obj, "Locked class from thread %p", g_thread_self()); \
92 } G_STMT_END
93 #define UNLOCK_CLASS(obj, klass) G_STMT_START { \
94   GST_TRACE_OBJECT(obj, "Unlocking class from thread %p", g_thread_self()); \
95   g_rec_mutex_unlock(&klass->lock); \
96 } G_STMT_END
97 
98 GType    gst_d3dvideosink_get_type (void);
99 
100 G_END_DECLS
101 
102 
103 #endif /* _GSTD3DVIDEOSINK_H_ */
104