• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2003 Julien Moutte <julien@moutte.net>
4  * Copyright (C) 2005,2006,2007 David A. Schleef <ds@schleef.org>
5  * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef _GLIMAGESINK_H_
24 #define _GLIMAGESINK_H_
25 
26 #include <gst/gst.h>
27 #include <gst/video/gstvideosink.h>
28 #include <gst/video/video.h>
29 
30 #include <gst/gl/gl.h>
31 #include <gst/gl/gstglfuncs.h>
32 
33 G_BEGIN_DECLS
34 
35 GST_DEBUG_CATEGORY_EXTERN (gst_debug_glimage_sink);
36 
37 #define GST_TYPE_GLIMAGE_SINK \
38     (gst_glimage_sink_get_type())
39 #define GST_GLIMAGE_SINK(obj) \
40     (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GLIMAGE_SINK,GstGLImageSink))
41 #define GST_GLIMAGE_SINK_CLASS(klass) \
42     (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GLIMAGE_SINK,GstGLImageSinkClass))
43 #define GST_IS_GLIMAGE_SINK(obj) \
44     (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GLIMAGE_SINK))
45 #define GST_IS_GLIMAGE_SINK_CLASS(klass) \
46     (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GLIMAGE_SINK))
47 
48 typedef struct _GstGLImageSink GstGLImageSink;
49 typedef struct _GstGLImageSinkClass GstGLImageSinkClass;
50 
51 struct _GstGLImageSink
52 {
53     GstVideoSink video_sink;
54 
55     guintptr window_id;
56     guintptr new_window_id;
57     gulong mouse_sig_id;
58     gulong key_sig_id;
59     gulong mouse_scroll_sig_id;
60 
61     /* GstVideoOverlay::set_render_rectangle() cache */
62     gint x;
63     gint y;
64     gint width;
65     gint height;
66 
67     /* Input info before 3d stereo output conversion, if any */
68     GstVideoInfo in_info;
69     GstCaps *in_caps;
70 
71     /* format/caps we actually hand off to the app */
72     GstVideoInfo out_info;
73     GstCaps *out_caps;
74     GstGLTextureTarget texture_target;
75 
76     GstGLDisplay *display;
77     GstGLContext *context;
78     GstGLContext *other_context;
79     gboolean handle_events;
80     gboolean ignore_alpha;
81 
82     GstGLViewConvert *convert_views;
83 
84     /* Original input RGBA buffer, ready for display,
85      * or possible reconversion through the views filter */
86     GstBuffer *input_buffer;
87     /* Secondary view buffer - when operating in frame-by-frame mode */
88     GstBuffer *input_buffer2;
89 
90     guint      next_tex;
91     GstBuffer *next_buffer;
92     GstBuffer *next_buffer2; /* frame-by-frame 2nd view */
93     GstBuffer *next_sync;
94     GstGLSyncMeta *next_sync_meta;
95 
96     gint to_quit;
97     gboolean keep_aspect_ratio;
98     gint par_n, par_d;
99 
100     /* avoid replacing the stored_buffer while drawing */
101     GMutex drawing_lock;
102     GstBuffer *stored_buffer[2];
103     GstBuffer *stored_sync;
104     GstGLSyncMeta *stored_sync_meta;
105     GLuint redisplay_texture;
106 
107     /* protected with drawing_lock */
108     gboolean window_resized;
109     guint window_width;
110     guint window_height;
111 
112     GstVideoRectangle display_rect;
113 
114     GstGLShader *redisplay_shader;
115     GLuint vao;
116     GLuint vbo_indices;
117     GLuint vertex_buffer;
118     GLint  attr_position;
119     GLint  attr_texture;
120 
121     GstVideoMultiviewMode mview_output_mode;
122     GstVideoMultiviewFlags mview_output_flags;
123     gboolean output_mode_changed;
124     GstGLStereoDownmix mview_downmix_mode;
125 
126     GstGLOverlayCompositor *overlay_compositor;
127 
128     /* current video flip method */
129     GstVideoOrientationMethod current_rotate_method;
130     GstVideoOrientationMethod rotate_method;
131     const gfloat *transform_matrix;
132 };
133 
134 struct _GstGLImageSinkClass
135 {
136     GstVideoSinkClass video_sink_class;
137 };
138 
139 GType gst_glimage_sink_get_type(void);
140 GType gst_gl_image_sink_bin_get_type(void);
141 
142 G_END_DECLS
143 
144 #endif
145 
146