summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-02-17 01:08:18 +1100
committerMatthew Waters <matthew@centricular.com>2016-02-17 10:30:45 +1100
commitac690978f29c7addb90908fe2d597e8f8e0ba2b8 (patch)
tree19f7642f27bd46134f9399b22006d2a8c38c917c /ext
parent0d94c9ae7f7dbb25285f80852dab0524dc50fa87 (diff)
downloadgstreamer-plugins-bad-ac690978f29c7addb90908fe2d597e8f8e0ba2b8.tar.gz
glmixer: Remove usage of GstGLMixerFrameData
Subclasses can just iterate over the list of pads themselves https://bugzilla.gnome.org/show_bug.cgi?id=760873
Diffstat (limited to 'ext')
-rw-r--r--ext/gl/gstglmixer.c75
-rw-r--r--ext/gl/gstglmixer.h18
-rw-r--r--ext/gl/gstglmosaic.c37
-rw-r--r--ext/gl/gstglmosaic.h1
-rw-r--r--ext/gl/gstglstereomix.c94
-rw-r--r--ext/gl/gstglstereomix.h30
-rw-r--r--ext/gl/gstglvideomixer.c41
-rw-r--r--ext/gl/gstglvideomixer.h1
8 files changed, 88 insertions, 209 deletions
diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c
index cfa42c1b5..5ca1316ca 100644
--- a/ext/gl/gstglmixer.c
+++ b/ext/gl/gstglmixer.c
@@ -416,7 +416,6 @@ static void
gst_gl_mixer_init (GstGLMixer * mix)
{
mix->priv = GST_GL_MIXER_GET_PRIVATE (mix);
- mix->array_buffers = 0;
mix->fbo = 0;
mix->depthbuffer = 0;
@@ -605,24 +604,7 @@ _upload_frames (GstAggregator * agg, GstAggregatorPad * agg_pad,
{
GstVideoAggregatorPad *vaggpad = GST_VIDEO_AGGREGATOR_PAD (agg_pad);
GstGLMixerPad *pad = GST_GL_MIXER_PAD (agg_pad);
- GstElement *element = GST_ELEMENT (agg);
GstGLMixer *mix = GST_GL_MIXER (agg);
- GstGLMixerFrameData *frame;
- guint *array_index, i;
-
- array_index = (guint *) user_data;
-
- GST_OBJECT_LOCK (agg);
- /* make sure the frames array is big enough */
- i = mix->frames->len;
- g_ptr_array_set_size (mix->frames, element->numsinkpads);
- for (; i < element->numsinkpads; i++)
- mix->frames->pdata[i] = g_new0 (GstGLMixerFrameData, 1);
-
- frame = g_ptr_array_index (mix->frames, *array_index);
- frame->pad = pad;
- frame->texture = 0;
- GST_OBJECT_UNLOCK (agg);
if (vaggpad->buffer != NULL) {
GstVideoInfo gl_info;
@@ -644,12 +626,10 @@ _upload_frames (GstAggregator * agg, GstAggregatorPad * agg_pad,
return FALSE;
}
- frame->texture = *(guint *) gl_frame.data[0];
+ pad->current_texture = *(guint *) gl_frame.data[0];
gst_video_frame_unmap (&gl_frame);
}
- (*array_index)++;
-
return TRUE;
}
@@ -658,7 +638,6 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
{
guint out_tex;
gboolean res = TRUE;
- guint array_index = 0;
GstVideoFrame out_frame;
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mix);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
@@ -674,7 +653,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
out_tex = *(guint *) out_frame.data[0];
if (!gst_aggregator_iterate_sinkpads (GST_AGGREGATOR (mix),
- (GstAggregatorPadForeachFunc) _upload_frames, &array_index))
+ (GstAggregatorPadForeachFunc) _upload_frames, NULL))
return FALSE;
g_mutex_lock (&priv->gl_resource_lock);
@@ -689,7 +668,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
goto out;
}
- mix_class->process_textures (mix, mix->frames, out_tex);
+ mix_class->process_textures (mix, out_tex);
g_mutex_unlock (&priv->gl_resource_lock);
@@ -702,31 +681,9 @@ out:
static gboolean
gst_gl_mixer_process_buffers (GstGLMixer * mix, GstBuffer * outbuf)
{
- GList *walk;
- guint i, array_index = 0;
- GstElement *element = GST_ELEMENT (mix);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
- GST_OBJECT_LOCK (mix);
- walk = GST_ELEMENT (mix)->sinkpads;
- i = mix->frames->len;
- g_ptr_array_set_size (mix->frames, element->numsinkpads);
- for (; i < element->numsinkpads; i++)
- mix->frames->pdata[i] = g_new0 (GstGLMixerFrameData, 1);
- while (walk) { /* We walk with this list because it's ordered */
- GstVideoAggregatorPad *vaggpad = walk->data;
-
- walk = g_list_next (walk);
-
- if (vaggpad->buffer != NULL) {
- /* put buffer into array */
- mix->array_buffers->pdata[array_index] = vaggpad->buffer;
- }
- ++array_index;
- }
- GST_OBJECT_UNLOCK (mix);
-
- return mix_class->process_buffers (mix, mix->array_buffers, outbuf);
+ return mix_class->process_buffers (mix, outbuf);
}
static GstFlowReturn
@@ -775,23 +732,6 @@ gst_gl_mixer_set_property (GObject * object,
static gboolean
gst_gl_mixer_start (GstAggregator * agg)
{
- guint i;
- GstGLMixer *mix = GST_GL_MIXER (agg);
- GstElement *element = GST_ELEMENT (agg);
-
- GST_OBJECT_LOCK (mix);
- mix->array_buffers = g_ptr_array_new_full (element->numsinkpads, NULL);
- mix->frames = g_ptr_array_new_full (element->numsinkpads,
- (GDestroyNotify) g_free);
-
- g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
- g_ptr_array_set_size (mix->frames, element->numsinkpads);
-
- for (i = 0; i < element->numsinkpads; i++)
- mix->frames->pdata[i] = g_new0 (GstGLMixerFrameData, 1);
-
- GST_OBJECT_UNLOCK (mix);
-
return GST_AGGREGATOR_CLASS (parent_class)->start (agg);
}
@@ -802,13 +742,6 @@ gst_gl_mixer_stop (GstAggregator * agg)
GstGLMixerClass *mixer_class = GST_GL_MIXER_GET_CLASS (mix);
GstGLContext *context = GST_GL_BASE_MIXER (mix)->context;
- GST_OBJECT_LOCK (agg);
- g_ptr_array_free (mix->frames, TRUE);
- mix->frames = NULL;
- g_ptr_array_free (mix->array_buffers, TRUE);
- mix->array_buffers = NULL;
- GST_OBJECT_UNLOCK (agg);
-
if (mixer_class->reset)
mixer_class->reset (mix);
if (mix->fbo) {
diff --git a/ext/gl/gstglmixer.h b/ext/gl/gstglmixer.h
index 01eed34f2..81976a748 100644
--- a/ext/gl/gstglmixer.h
+++ b/ext/gl/gstglmixer.h
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
typedef struct _GstGLMixer GstGLMixer;
typedef struct _GstGLMixerClass GstGLMixerClass;
typedef struct _GstGLMixerPrivate GstGLMixerPrivate;
-typedef struct _GstGLMixerFrameData GstGLMixerFrameData;
#define GST_TYPE_GL_MIXER_PAD (gst_gl_mixer_pad_get_type())
#define GST_GL_MIXER_PAD(obj) \
@@ -52,6 +51,8 @@ typedef struct _GstGLMixerPadClass GstGLMixerPadClass;
struct _GstGLMixerPad
{
GstGLBaseMixerPad parent;
+
+ guint current_texture;
};
struct _GstGLMixerPadClass
@@ -76,18 +77,13 @@ GType gst_gl_mixer_pad_get_type (void);
typedef gboolean (*GstGLMixerSetCaps) (GstGLMixer* mixer,
GstCaps* outcaps);
typedef void (*GstGLMixerReset) (GstGLMixer *mixer);
-typedef gboolean (*GstGLMixerProcessFunc) (GstGLMixer *mix,
- GPtrArray *buffers, GstBuffer *outbuf);
-typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix,
- GPtrArray *frames, guint out_tex);
+typedef gboolean (*GstGLMixerProcessFunc) (GstGLMixer *mix, GstBuffer *outbuf);
+typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, guint out_tex);
struct _GstGLMixer
{
GstGLBaseMixer vaggregator;
- GPtrArray *array_buffers;
- GPtrArray *frames;
-
GLuint fbo;
GLuint depthbuffer;
@@ -106,12 +102,6 @@ struct _GstGLMixerClass
GstGLMixerProcessTextures process_textures;
};
-struct _GstGLMixerFrameData
-{
- GstGLMixerPad *pad;
- guint texture;
-};
-
GType gst_gl_mixer_get_type(void);
gboolean gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf);
diff --git a/ext/gl/gstglmosaic.c b/ext/gl/gstglmosaic.c
index 0a9834138..83ac79810 100644
--- a/ext/gl/gstglmosaic.c
+++ b/ext/gl/gstglmosaic.c
@@ -70,7 +70,7 @@ static gboolean gst_gl_mosaic_init_shader (GstGLMixer * mixer,
GstCaps * outcaps);
static gboolean gst_gl_mosaic_process_textures (GstGLMixer * mixer,
- GPtrArray * frames, guint out_tex);
+ guint out_tex);
static void gst_gl_mosaic_callback (gpointer stuff);
//vertex source
@@ -142,7 +142,6 @@ static void
gst_gl_mosaic_init (GstGLMosaic * mosaic)
{
mosaic->shader = NULL;
- mosaic->input_frames = NULL;
}
static void
@@ -176,8 +175,6 @@ gst_gl_mosaic_reset (GstGLMixer * mixer)
{
GstGLMosaic *mosaic = GST_GL_MOSAIC (mixer);
- mosaic->input_frames = NULL;
-
//blocking call, wait the opengl thread has destroyed the shader
if (mosaic->shader)
gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context,
@@ -196,13 +193,10 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
}
static gboolean
-gst_gl_mosaic_process_textures (GstGLMixer * mix, GPtrArray * frames,
- guint out_tex)
+gst_gl_mosaic_process_textures (GstGLMixer * mix, guint out_tex)
{
GstGLMosaic *mosaic = GST_GL_MOSAIC (mix);
- mosaic->input_frames = frames;
-
//blocking call, use a FBO
gst_gl_context_use_fbo_v2 (GST_GL_BASE_MIXER (mix)->context,
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (mix)->info),
@@ -219,6 +213,7 @@ gst_gl_mosaic_callback (gpointer stuff)
GstGLMosaic *mosaic = GST_GL_MOSAIC (stuff);
GstGLMixer *mixer = GST_GL_MIXER (mosaic);
GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
+ GList *walk;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@@ -255,8 +250,10 @@ gst_gl_mosaic_callback (gpointer stuff)
attr_texture_loc =
gst_gl_shader_get_attribute_location (mosaic->shader, "a_texCoord");
- while (count < mosaic->input_frames->len && count < 6) {
- GstGLMixerFrameData *frame;
+ GST_OBJECT_LOCK (mosaic);
+ walk = GST_ELEMENT (mosaic)->sinkpads;
+ while (walk) {
+ GstGLMixerPad *pad = walk->data;
/* *INDENT-OFF* */
gfloat v_vertices[] = {
/* front face */
@@ -294,20 +291,13 @@ gst_gl_mosaic_callback (gpointer stuff)
guint in_tex;
guint width, height;
- frame = g_ptr_array_index (mosaic->input_frames, count);
- if (!frame) {
- GST_DEBUG ("skipping texture, null frame");
- count++;
- continue;
- }
- in_tex = frame->texture;
- width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR_PAD (frame->pad)->info);
- height =
- GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR_PAD (frame->pad)->info);
+ in_tex = pad->current_texture;
+ width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR_PAD (pad)->info);
+ height = GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR_PAD (pad)->info);
if (!in_tex || width <= 0 || height <= 0) {
- GST_DEBUG ("skipping texture:%u frame:%p width:%u height %u",
- in_tex, frame, width, height);
+ GST_DEBUG ("skipping texture:%u pad:%p width:%u height %u",
+ in_tex, pad, width, height);
count++;
continue;
}
@@ -335,7 +325,10 @@ gst_gl_mosaic_callback (gpointer stuff)
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
++count;
+
+ walk = g_list_next (walk);
}
+ GST_OBJECT_UNLOCK (mosaic);
gl->DisableVertexAttribArray (attr_position_loc);
gl->DisableVertexAttribArray (attr_texture_loc);
diff --git a/ext/gl/gstglmosaic.h b/ext/gl/gstglmosaic.h
index 49c99e775..e0b340cc2 100644
--- a/ext/gl/gstglmosaic.h
+++ b/ext/gl/gstglmosaic.h
@@ -40,7 +40,6 @@ struct _GstGLMosaic
GstGLMixer mixer;
GstGLShader *shader;
- GPtrArray *input_frames;
};
struct _GstGLMosaicClass
diff --git a/ext/gl/gstglstereomix.c b/ext/gl/gstglstereomix.c
index 6768ff010..fee1080c2 100644
--- a/ext/gl/gstglstereomix.c
+++ b/ext/gl/gstglstereomix.c
@@ -30,6 +30,18 @@
#define GST_CAT_DEFAULT gst_gl_stereo_mix_debug
GST_DEBUG_CATEGORY (gst_gl_stereo_mix_debug);
+G_DEFINE_TYPE (GstGLStereoMixPad, gst_gl_stereo_mix_pad, GST_TYPE_GL_MIXER_PAD);
+
+static void
+gst_gl_stereo_mix_pad_class_init (GstGLStereoMixPadClass * klass)
+{
+}
+
+static void
+gst_gl_stereo_mix_pad_init (GstGLStereoMixPad * pad)
+{
+}
+
#define gst_gl_stereo_mix_parent_class parent_class
G_DEFINE_TYPE (GstGLStereoMix, gst_gl_stereo_mix, GST_TYPE_GL_MIXER);
@@ -38,8 +50,7 @@ static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps,
static gboolean _negotiated_caps (GstVideoAggregator * videoaggregator,
GstCaps * caps);
gboolean gst_gl_stereo_mix_make_output (GstGLStereoMix * mix);
-static gboolean gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer,
- GPtrArray * in_frames);
+static gboolean gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer);
#define DEFAULT_DOWNMIX GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS
@@ -144,6 +155,7 @@ gst_gl_stereo_mix_class_init (GstGLStereoMixClass * klass)
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
+ agg_class->sinkpads_type = GST_TYPE_GL_STEREO_MIX_PAD;
agg_class->stop = gst_gl_stereo_mix_stop;
agg_class->start = gst_gl_stereo_mix_start;
agg_class->src_query = gst_gl_stereo_mix_src_query;
@@ -250,10 +262,8 @@ gst_gl_stereo_mix_get_output_buffer (GstVideoAggregator * videoaggregator,
gboolean
gst_gl_stereo_mix_make_output (GstGLStereoMix * mix)
{
- guint i;
GList *walk;
gboolean res = FALSE;
- guint array_index = 0;
GstElement *element = GST_ELEMENT (mix);
gboolean missing_buffer = FALSE;
@@ -261,33 +271,23 @@ gst_gl_stereo_mix_make_output (GstGLStereoMix * mix)
GST_OBJECT_LOCK (mix);
walk = element->sinkpads;
-
- i = mix->frames->len;
- g_ptr_array_set_size (mix->frames, element->numsinkpads);
- for (; i < element->numsinkpads; i++)
- mix->frames->pdata[i] = g_slice_new0 (GstGLStereoMixFrameData);
while (walk) {
- GstGLMixerPad *pad = GST_GL_MIXER_PAD (walk->data);
GstVideoAggregatorPad *vaggpad = walk->data;
- GstGLStereoMixFrameData *frame;
+ GstGLStereoMixPad *pad = walk->data;
GST_LOG_OBJECT (mix, "Checking pad %" GST_PTR_FORMAT, vaggpad);
- frame = g_ptr_array_index (mix->frames, array_index);
- frame->base.pad = pad;
- frame->buf = NULL;
-
- walk = g_list_next (walk);
-
if (vaggpad->buffer != NULL) {
- frame->buf = vaggpad->buffer;
+ pad->current_buffer = vaggpad->buffer;
- GST_DEBUG_OBJECT (pad, "Got buffer %" GST_PTR_FORMAT, frame->buf);
+ GST_DEBUG_OBJECT (pad, "Got buffer %" GST_PTR_FORMAT,
+ pad->current_buffer);
} else {
GST_LOG_OBJECT (mix, "No buffer on pad %" GST_PTR_FORMAT, vaggpad);
+ pad->current_buffer = NULL;
missing_buffer = TRUE;
}
- ++array_index;
+ walk = g_list_next (walk);
}
if (missing_buffer) {
/* We're still waiting for a buffer to turn up on at least one input */
@@ -297,7 +297,7 @@ gst_gl_stereo_mix_make_output (GstGLStereoMix * mix)
}
/* Copy GL memory from each input frame to the output */
- if (!gst_gl_stereo_mix_process_frames (mix, mix->frames)) {
+ if (!gst_gl_stereo_mix_process_frames (mix)) {
GST_LOG_OBJECT (mix, "Failed to process frames to output");
goto out;
}
@@ -371,41 +371,18 @@ gst_gl_stereo_mix_set_property (GObject * object,
}
}
-static void
-_free_glmixer_frame_data (GstGLStereoMixFrameData * frame)
-{
- if (frame == NULL)
- return;
- if (frame->buf)
- gst_buffer_unref (frame->buf);
- g_slice_free1 (sizeof (GstGLStereoMixFrameData), frame);
-}
-
static gboolean
gst_gl_stereo_mix_start (GstAggregator * agg)
{
- guint i;
GstGLStereoMix *mix = GST_GL_STEREO_MIX (agg);
- GstElement *element = GST_ELEMENT (agg);
if (!GST_AGGREGATOR_CLASS (parent_class)->start (agg))
return FALSE;
GST_OBJECT_LOCK (mix);
- mix->array_buffers = g_ptr_array_new_full (element->numsinkpads,
- (GDestroyNotify) _free_glmixer_frame_data);
- mix->frames = g_ptr_array_new_full (element->numsinkpads, NULL);
-
- g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
- g_ptr_array_set_size (mix->frames, element->numsinkpads);
-
- for (i = 0; i < element->numsinkpads; i++)
- mix->frames->pdata[i] = g_slice_new0 (GstGLStereoMixFrameData);
-
mix->viewconvert = gst_gl_view_convert_new ();
g_object_set (G_OBJECT (mix->viewconvert), "downmix-mode",
mix->downmix_mode, NULL);
-
GST_OBJECT_UNLOCK (mix);
return TRUE;
@@ -419,13 +396,6 @@ gst_gl_stereo_mix_stop (GstAggregator * agg)
if (!GST_AGGREGATOR_CLASS (parent_class)->stop (agg))
return FALSE;
- GST_OBJECT_LOCK (agg);
- g_ptr_array_free (mix->frames, TRUE);
- mix->frames = NULL;
- g_ptr_array_free (mix->array_buffers, TRUE);
- mix->array_buffers = NULL;
- GST_OBJECT_UNLOCK (agg);
-
if (mix->viewconvert) {
gst_object_unref (mix->viewconvert);
mix->viewconvert = NULL;
@@ -511,34 +481,34 @@ _negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
return TRUE;
}
+/* called with the object lock held */
static gboolean
-gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer, GPtrArray * frames)
+gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer)
{
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mixer);
GstBuffer *converted_buffer, *inbuf;
GstVideoInfo *out_info = &vagg->info;
- gint count = 0;
#ifndef G_DISABLE_ASSERT
gint n;
#endif
gint v, views;
gint valid_views = 0;
+ GList *walk;
inbuf = gst_buffer_new ();
- while (count < frames->len) {
- GstGLStereoMixFrameData *frame;
+ walk = GST_ELEMENT (mixer)->sinkpads;
+ while (walk) {
+ GstGLStereoMixPad *pad = walk->data;
GstMemory *in_mem;
- frame = g_ptr_array_index (frames, count);
- GST_LOG_OBJECT (mixer, "Handling frame %d", count);
+ GST_LOG_OBJECT (mixer, "Handling frame %d", valid_views);
- if (!frame) {
+ if (!pad || !pad->current_buffer) {
GST_DEBUG ("skipping texture, null frame");
- count++;
continue;
}
- in_mem = gst_buffer_get_memory (frame->buf, 0);
+ in_mem = gst_buffer_get_memory (pad->current_buffer, 0);
GST_LOG_OBJECT (mixer,
"Appending memory %" GST_PTR_FORMAT " to intermediate buffer", in_mem);
@@ -551,10 +521,10 @@ gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer, GPtrArray * frames)
*/
gst_buffer_append_memory (inbuf, in_mem);
/* Use parent buffer meta to keep input buffer alive */
- gst_buffer_add_parent_buffer_meta (inbuf, frame->buf);
+ gst_buffer_add_parent_buffer_meta (inbuf, pad->current_buffer);
- count++;
valid_views++;
+ walk = g_list_next (walk);
}
if (mixer->mix_info.views != valid_views) {
diff --git a/ext/gl/gstglstereomix.h b/ext/gl/gstglstereomix.h
index 0c06d4262..b0f1bd232 100644
--- a/ext/gl/gstglstereomix.h
+++ b/ext/gl/gstglstereomix.h
@@ -40,15 +40,30 @@ G_BEGIN_DECLS
typedef struct _GstGLStereoMix GstGLStereoMix;
typedef struct _GstGLStereoMixClass GstGLStereoMixClass;
-typedef struct _GstGLStereoMixFrameData GstGLStereoMixFrameData;
+typedef struct _GstGLStereoMixPad GstGLStereoMixPad;
+typedef struct _GstGLStereoMixPadClass GstGLStereoMixPadClass;
+
+struct _GstGLStereoMixPad
+{
+ GstGLMixerPad mixer_pad;
+
+ gboolean mapped;
+ GstBuffer *current_buffer;
+};
+
+struct _GstGLStereoMixPadClass
+{
+ GstGLMixerPadClass mixer_pad_class;
+};
+
+#define GST_TYPE_GL_STEREO_MIX_PAD (gst_gl_stereo_mix_pad_get_type ())
+GType gst_gl_stereo_mix_pad_get_type (void);
+
struct _GstGLStereoMix
{
GstGLMixer mixer;
- GPtrArray *array_buffers;
- GPtrArray *frames;
-
GLuint out_tex_id;
GstGLViewConvert *viewconvert;
@@ -69,13 +84,6 @@ struct _GstGLStereoMixClass
GstGLMixerClass mixer_class;
};
-struct _GstGLStereoMixFrameData
-{
- GstGLMixerFrameData base;
- gboolean mapped;
- GstBuffer *buf;
-};
-
GType gst_gl_stereo_mix_get_type(void);
G_END_DECLS
diff --git a/ext/gl/gstglvideomixer.c b/ext/gl/gstglvideomixer.c
index 273d06739..e0fd42775 100644
--- a/ext/gl/gstglvideomixer.c
+++ b/ext/gl/gstglvideomixer.c
@@ -468,7 +468,7 @@ static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
GstCaps * outcaps);
static gboolean gst_gl_video_mixer_process_textures (GstGLMixer * mixer,
- GPtrArray * in_frames, guint out_tex);
+ guint out_tex);
static void gst_gl_video_mixer_callback (gpointer stuff);
/* *INDENT-OFF* */
@@ -878,7 +878,6 @@ gst_gl_video_mixer_init (GstGLVideoMixer * video_mixer)
{
video_mixer->background = DEFAULT_BACKGROUND;
video_mixer->shader = NULL;
- video_mixer->input_frames = NULL;
}
static void
@@ -1096,8 +1095,6 @@ gst_gl_video_mixer_reset (GstGLMixer * mixer)
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mixer);
GstGLContext *context = GST_GL_BASE_MIXER (mixer)->context;
- video_mixer->input_frames = NULL;
-
GST_DEBUG_OBJECT (mixer, "context:%p", context);
if (video_mixer->shader)
@@ -1127,13 +1124,10 @@ gst_gl_video_mixer_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
}
static gboolean
-gst_gl_video_mixer_process_textures (GstGLMixer * mix, GPtrArray * frames,
- guint out_tex)
+gst_gl_video_mixer_process_textures (GstGLMixer * mix, guint out_tex)
{
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mix);
- video_mixer->input_frames = frames;
-
gst_gl_context_use_fbo_v2 (GST_GL_BASE_MIXER (mix)->context,
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (mix)->info),
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR (mix)->info),
@@ -1364,12 +1358,10 @@ gst_gl_video_mixer_callback (gpointer stuff)
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (stuff);
GstGLMixer *mixer = GST_GL_MIXER (video_mixer);
GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
-
GLint attr_position_loc = 0;
GLint attr_texture_loc = 0;
guint out_width, out_height;
-
- guint count = 0;
+ GList *walk;
out_width = GST_VIDEO_INFO_WIDTH (&vagg->info);
out_height = GST_VIDEO_INFO_HEIGHT (&vagg->info);
@@ -1398,9 +1390,11 @@ gst_gl_video_mixer_callback (gpointer stuff)
gl->Enable (GL_BLEND);
- while (count < video_mixer->input_frames->len) {
- GstGLMixerFrameData *frame;
- GstGLVideoMixerPad *pad;
+ GST_OBJECT_LOCK (video_mixer);
+ walk = GST_ELEMENT (video_mixer)->sinkpads;
+ while (walk) {
+ GstGLMixerPad *mix_pad = walk->data;
+ GstGLVideoMixerPad *pad = walk->data;
GstVideoInfo *v_info;
guint in_tex;
guint in_width, in_height;
@@ -1414,22 +1408,14 @@ gst_gl_video_mixer_callback (gpointer stuff)
};
/* *INDENT-ON* */
- frame = g_ptr_array_index (video_mixer->input_frames, count);
- if (!frame) {
- GST_DEBUG ("skipping texture, null frame");
- count++;
- continue;
- }
- pad = (GstGLVideoMixerPad *) frame->pad;
v_info = &GST_VIDEO_AGGREGATOR_PAD (pad)->info;
in_width = GST_VIDEO_INFO_WIDTH (v_info);
in_height = GST_VIDEO_INFO_HEIGHT (v_info);
- if (!frame->texture || in_width <= 0 || in_height <= 0
+ if (!mix_pad->current_texture || in_width <= 0 || in_height <= 0
|| pad->alpha == 0.0f) {
- GST_DEBUG ("skipping texture:%u frame:%p width:%u height:%u alpha:%f",
- frame->texture, frame, in_width, in_height, pad->alpha);
- count++;
+ GST_DEBUG ("skipping texture:%u pad:%p width:%u height:%u alpha:%f",
+ mix_pad->current_texture, pad, in_width, in_height, pad->alpha);
continue;
}
@@ -1438,7 +1424,7 @@ gst_gl_video_mixer_callback (gpointer stuff)
continue;
}
- in_tex = frame->texture;
+ in_tex = mix_pad->current_texture;
_init_vbo_indices (video_mixer);
@@ -1497,8 +1483,9 @@ gst_gl_video_mixer_callback (gpointer stuff)
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
- ++count;
+ walk = g_list_next (walk);
}
+ GST_OBJECT_UNLOCK (video_mixer);
gl->DisableVertexAttribArray (attr_position_loc);
gl->DisableVertexAttribArray (attr_texture_loc);
diff --git a/ext/gl/gstglvideomixer.h b/ext/gl/gstglvideomixer.h
index 86c0506d2..a0776fd9f 100644
--- a/ext/gl/gstglvideomixer.h
+++ b/ext/gl/gstglvideomixer.h
@@ -121,7 +121,6 @@ struct _GstGLVideoMixer
GstGLShader *shader;
GstGLShader *checker;
- GPtrArray *input_frames;
GLuint vao;
GLuint vbo_indices;