mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
gl/mixer: make fbo instance field private and provide accessor function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4608>
This commit is contained in:
parent
007a602726
commit
14e7e991d3
9 changed files with 92 additions and 21 deletions
|
@ -217,6 +217,7 @@ static void
|
|||
_mosaic_render (GstGLContext * context, GstGLMosaic * mosaic)
|
||||
{
|
||||
GstGLMixer *mixer = GST_GL_MIXER (mosaic);
|
||||
GstGLFramebuffer *fbo = gst_gl_mixer_get_framebuffer (mixer);
|
||||
|
||||
if (!mosaic->shader) {
|
||||
gchar *frag_str = g_strdup_printf ("%s%s",
|
||||
|
@ -230,8 +231,10 @@ _mosaic_render (GstGLContext * context, GstGLMosaic * mosaic)
|
|||
g_free (frag_str);
|
||||
}
|
||||
|
||||
gst_gl_framebuffer_draw_to_texture (mixer->fbo, mosaic->out_tex,
|
||||
gst_gl_framebuffer_draw_to_texture (fbo, mosaic->out_tex,
|
||||
gst_gl_mosaic_callback, mosaic);
|
||||
|
||||
gst_clear_object (&fbo);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
#include "gstglelements.h"
|
||||
#include "gstglstereomix.h"
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_stereo_mix_debug
|
||||
GST_DEBUG_CATEGORY (gst_gl_stereo_mix_debug);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __GST_GL_STEREO_MIX_H__
|
||||
#define __GST_GL_STEREO_MIX_H__
|
||||
|
||||
#include <gst/gl/gstglmixer.h>
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -1845,9 +1845,12 @@ static void
|
|||
_video_mixer_process_gl (GstGLContext * context, GstGLVideoMixer * video_mixer)
|
||||
{
|
||||
GstGLMixer *mixer = GST_GL_MIXER (video_mixer);
|
||||
GstGLFramebuffer *fbo = gst_gl_mixer_get_framebuffer (mixer);
|
||||
|
||||
gst_gl_framebuffer_draw_to_texture (mixer->fbo, video_mixer->out_tex,
|
||||
gst_gl_framebuffer_draw_to_texture (fbo, video_mixer->out_tex,
|
||||
gst_gl_video_mixer_callback, video_mixer);
|
||||
|
||||
gst_clear_object (&fbo);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -52,5 +52,7 @@
|
|||
#include <gst/gl/gstglsyncmeta.h>
|
||||
#include <gst/gl/gstgloverlaycompositor.h>
|
||||
#include <gst/gl/gstglquery.h>
|
||||
#include <gst/gl/gstglbasemixer.h>
|
||||
#include <gst/gl/gstglmixer.h>
|
||||
|
||||
#endif /* __GST_GL_H__ */
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* Generic video mixer plugin
|
||||
*
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
|
||||
*
|
||||
|
@ -27,6 +26,20 @@
|
|||
#include <gst/video/video.h>
|
||||
|
||||
#include "gstglbasemixer.h"
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
/**
|
||||
* SECTION:gstglbasemixer
|
||||
* @short_description: #GstVideoAggregator subclass for transforming OpenGL resources
|
||||
* @title: GstGLBaseMixer
|
||||
* @see_also: #GstVideoAggregator, #GstGLMixer
|
||||
*
|
||||
* #GstGLBaseMixer handles the nitty gritty details of retrieving an OpenGL
|
||||
* context. It provides some virtual methods to know when the OpenGL context
|
||||
* is available and is not available within this element.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_base_mixer_debug
|
||||
GST_DEBUG_CATEGORY (gst_gl_base_mixer_debug);
|
||||
|
@ -663,7 +676,7 @@ gst_gl_base_mixer_change_state (GstElement * element, GstStateChange transition)
|
|||
*
|
||||
* Returns: (transfer full) (nullable): the #GstGLContext found by @mix
|
||||
*
|
||||
* Since: 1.18
|
||||
* Since: 1.24
|
||||
*/
|
||||
GstGLContext *
|
||||
gst_gl_base_mixer_get_gl_context (GstGLBaseMixer * mix)
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/gl/gl.h>
|
||||
#include <gst/video/gstvideoaggregator.h>
|
||||
#include <gst/gl/gstglcontext.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -54,6 +54,8 @@ struct _GstGLBaseMixerPadClass
|
|||
GstVideoAggregatorPadClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseMixerPad, gst_object_unref);
|
||||
|
||||
GST_GL_API
|
||||
GType gst_gl_base_mixer_pad_get_type (void);
|
||||
|
||||
|
@ -96,6 +98,8 @@ struct _GstGLBaseMixerClass
|
|||
gpointer _padding[GST_PADDING];
|
||||
};
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLBaseMixer, gst_object_unref);
|
||||
|
||||
GST_GL_API
|
||||
GType gst_gl_base_mixer_get_type(void);
|
||||
|
||||
|
|
|
@ -30,8 +30,20 @@
|
|||
|
||||
#include "gstglmixer.h"
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
#include <gst/gl/gstglfuncs.h>
|
||||
|
||||
/**
|
||||
* SECTION:gstglmixer
|
||||
* @short_description: #GstVideoAggregator subclass for transforming RGBA textures
|
||||
* @title: GstGLMixer
|
||||
* @see_also: #GstGLBaseMixer, #GstVideoAggregator
|
||||
*
|
||||
* #GstGLMixer helps implement an element that operates on RGBA textures.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_mixer_debug
|
||||
GST_DEBUG_CATEGORY (gst_gl_mixer_debug);
|
||||
|
||||
|
@ -57,6 +69,8 @@ struct _GstGLMixerPrivate
|
|||
gboolean gl_resource_ready;
|
||||
GMutex gl_resource_lock;
|
||||
GCond gl_resource_cond;
|
||||
|
||||
GstGLFramebuffer *fbo;
|
||||
};
|
||||
|
||||
#define gst_gl_mixer_parent_class parent_class
|
||||
|
@ -533,9 +547,15 @@ _mixer_create_fbo (GstGLContext * context, GstGLMixer * mix)
|
|||
guint out_width = GST_VIDEO_INFO_WIDTH (&vagg->info);
|
||||
guint out_height = GST_VIDEO_INFO_HEIGHT (&vagg->info);
|
||||
|
||||
mix->fbo =
|
||||
gst_gl_framebuffer_new_with_default_depth (context, out_width,
|
||||
out_height);
|
||||
g_mutex_lock (&mix->priv->gl_resource_lock);
|
||||
if (!mix->priv->fbo)
|
||||
mix->priv->fbo =
|
||||
gst_gl_framebuffer_new_with_default_depth (context, out_width,
|
||||
out_height);
|
||||
g_cond_signal (&mix->priv->gl_resource_cond);
|
||||
if (mix->priv->fbo)
|
||||
mix->priv->gl_resource_ready = TRUE;
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -554,7 +574,7 @@ gst_gl_mixer_gl_stop (GstGLBaseMixer * base_mix)
|
|||
mixer_class->reset (mix);
|
||||
|
||||
g_mutex_lock (&mix->priv->gl_resource_lock);
|
||||
gst_clear_object (&mix->fbo);
|
||||
gst_clear_object (&mix->priv->fbo);
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
|
||||
GST_GL_BASE_MIXER_CLASS (parent_class)->gl_stop (base_mix);
|
||||
|
@ -585,13 +605,15 @@ gst_gl_mixer_decide_allocation (GstAggregator * agg, GstQuery * query)
|
|||
|
||||
g_mutex_lock (&mix->priv->gl_resource_lock);
|
||||
mix->priv->gl_resource_ready = FALSE;
|
||||
if (mix->fbo)
|
||||
gst_object_unref (mix->fbo);
|
||||
gst_clear_object (&mix->priv->fbo);
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
|
||||
gst_gl_context_thread_add (context,
|
||||
(GstGLContextThreadFunc) _mixer_create_fbo, mix);
|
||||
if (!mix->fbo) {
|
||||
g_cond_signal (&mix->priv->gl_resource_cond);
|
||||
|
||||
g_mutex_lock (&mix->priv->gl_resource_lock);
|
||||
if (!mix->priv->fbo) {
|
||||
mix->priv->gl_resource_ready = FALSE;
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
goto context_error;
|
||||
}
|
||||
|
@ -676,10 +698,10 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
|
|||
goto out;
|
||||
}
|
||||
|
||||
mix_class->process_textures (mix, out_tex);
|
||||
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
|
||||
mix_class->process_textures (mix, out_tex);
|
||||
|
||||
out:
|
||||
gst_video_frame_unmap (&out_frame);
|
||||
|
||||
|
@ -760,3 +782,22 @@ gst_gl_mixer_stop (GstAggregator * agg)
|
|||
|
||||
return GST_AGGREGATOR_CLASS (parent_class)->stop (agg);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_mixer_get_framebuffer:
|
||||
* @mix: the #GstGLMixer
|
||||
*
|
||||
* Returns: (transfer full): (nullable): The #GstGLFramebuffer in use by this @mix
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
GstGLFramebuffer *
|
||||
gst_gl_mixer_get_framebuffer (GstGLMixer * mix)
|
||||
{
|
||||
GstGLFramebuffer *fbo = NULL;
|
||||
g_mutex_lock (&mix->priv->gl_resource_lock);
|
||||
if (mix->priv->fbo)
|
||||
fbo = gst_object_ref (mix->priv->fbo);
|
||||
g_mutex_unlock (&mix->priv->gl_resource_lock);
|
||||
return fbo;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/gl/gl.h>
|
||||
#include "gstglbasemixer.h"
|
||||
#include <gst/gl/gstglbasemixer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -60,6 +59,8 @@ struct _GstGLMixerPadClass
|
|||
GstGLBaseMixerPadClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMixerPad, gst_object_unref);
|
||||
|
||||
GST_GL_API
|
||||
GType gst_gl_mixer_pad_get_type (void);
|
||||
|
||||
|
@ -85,8 +86,6 @@ struct _GstGLMixer
|
|||
{
|
||||
GstGLBaseMixer vaggregator;
|
||||
|
||||
GstGLFramebuffer *fbo;
|
||||
|
||||
GstCaps *out_caps;
|
||||
|
||||
GstGLMixerPrivate *priv;
|
||||
|
@ -102,11 +101,16 @@ struct _GstGLMixerClass
|
|||
GstGLMixerProcessTextures process_textures;
|
||||
};
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstGLMixer, gst_object_unref);
|
||||
|
||||
GST_GL_API
|
||||
GType gst_gl_mixer_get_type(void);
|
||||
|
||||
GST_GL_API
|
||||
gboolean gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf);
|
||||
|
||||
GST_GL_API
|
||||
GstGLFramebuffer * gst_gl_mixer_get_framebuffer (GstGLMixer * mix);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GST_GL_MIXER_H__ */
|
||||
|
|
Loading…
Reference in a new issue