and only create an up/download object when needed.
g_free (display->error_message);
display->error_message = NULL;
}
- if (display->uploads) {
- g_slist_free_full (display->uploads, g_object_unref);
- display->uploads = NULL;
- }
- if (display->downloads) {
- g_slist_free_full (display->downloads, g_object_unref);
- display->downloads = NULL;
- }
if (display->gl_vtable) {
g_slice_free (GstGLFuncs, display->gl_vtable);
#include <gst/video/video.h>
-typedef struct _GstGLUpload GstGLUpload;
-typedef struct _GstGLDownload GstGLDownload;
typedef struct _GstGLShader GstGLShader;
#include "gstglwindow.h"
#include "gstglshader.h"
-#include "gstglupload.h"
-#include "gstgldownload.h"
G_BEGIN_DECLS
GstGLDisplayConversion colorspace_conversion;
- GSList *uploads;
- GSList *downloads;
-
gchar *error_message;
GstGLFuncs *gl_vtable;
return TRUE;
}
-/**
- * gst_gl_display_find_download_unlocked:
- * @display: a #GstGLDisplay
- * @v_format: a #GstVideoFormat
- * @out_width: the width to download to
- * @out_height: the height to download to
- *
- * Finds a #GstGLDownload with the required download settings, creating one
- * if needed. The returned object may not be initialized so you still
- * have to call gst_gl_download_init_format.
- *
- * This function is safe to be called in the GL thread
- *
- * Returns: a #GstGLDownload object with the required settings
- */
-GstGLDownload *
-gst_gl_display_find_download_unlocked (GstGLDisplay * display,
- GstVideoFormat v_format, guint out_width, guint out_height)
-{
- GstGLDownload *ret = NULL;
- GSList *walk;
-
- walk = display->downloads;
-
- while (walk) {
- ret = walk->data;
-
- if (ret && v_format == GST_VIDEO_INFO_FORMAT (&ret->info) &&
- out_width == GST_VIDEO_INFO_WIDTH (&ret->info) &&
- out_height == GST_VIDEO_INFO_HEIGHT (&ret->info))
- break;
-
- ret = NULL;
- walk = g_slist_next (walk);
- }
-
- if (!ret) {
- ret = gst_gl_download_new (display);
-
- display->downloads = g_slist_prepend (display->downloads, ret);
- }
-
- return ret;
-}
-
-/**
- * gst_gl_display_find_download:
- * @display: a #GstGLDisplay
- * @v_format: a #GstVideoFormat
- * @out_width: the width to download to
- * @out_height: the height to download to
- *
- * Finds a #GstGLDownload with the required download settings, creating one
- * if needed. The returned object may not be initialized so you still
- * have to call gst_gl_download_init_format.
- *
- * Returns: a #GstGLDownload object with the required settings
- */
-GstGLDownload *
-gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
- guint out_width, guint out_height)
-{
- GstGLDownload *ret;
-
- gst_gl_display_lock (display);
-
- ret = gst_gl_display_find_download_unlocked (display, v_format,
- out_width, out_height);
-
- gst_gl_display_unlock (display);
-
- return ret;
-}
-
static void
_init_download (GstGLDisplay * display, GstGLDownload * download)
{
gboolean gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id,
gpointer data[GST_VIDEO_MAX_PLANES]);
-GstGLDownload * gst_gl_display_find_download_unlocked (GstGLDisplay * display, GstVideoFormat v_format,
- guint out_width, guint out_height);
-GstGLDownload * gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
- guint out_width, guint out_height);
-
G_END_DECLS
#endif /* __GST_GL_DOWNLOAD_H__ */
"attempting to wrap for upload");
if (!filter->upload) {
- filter->upload = gst_gl_display_find_upload (filter->display,
- GST_VIDEO_FRAME_FORMAT (&in_frame),
- GST_VIDEO_FRAME_WIDTH (&in_frame),
- GST_VIDEO_FRAME_HEIGHT (&in_frame),
- GST_VIDEO_FRAME_WIDTH (&out_frame),
- GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ filter->upload = gst_gl_upload_new (filter->display);
gst_gl_upload_init_format (filter->upload,
GST_VIDEO_FRAME_FORMAT (&in_frame),
"attempting to wrap for download");
if (!filter->download) {
- filter->download = gst_gl_display_find_download (filter->display,
- GST_VIDEO_FRAME_FORMAT (&out_frame),
- GST_VIDEO_FRAME_WIDTH (&out_frame),
- GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ filter->download = gst_gl_download_new (filter->display);
gst_gl_download_init_format (filter->download,
GST_VIDEO_FRAME_FORMAT (&out_frame),
out_tex = filter->out_tex_id;
} else { /* both non-GL */
if (!filter->upload) {
- filter->upload = gst_gl_display_find_upload (filter->display,
- GST_VIDEO_FRAME_FORMAT (&in_frame),
- GST_VIDEO_FRAME_WIDTH (&in_frame),
- GST_VIDEO_FRAME_HEIGHT (&in_frame),
- GST_VIDEO_FRAME_WIDTH (&out_frame),
- GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ filter->upload = gst_gl_upload_new (filter->display);
gst_gl_upload_init_format (filter->upload,
GST_VIDEO_FRAME_FORMAT (&in_frame),
}
if (!filter->download) {
- filter->download = gst_gl_display_find_download (filter->display,
- GST_VIDEO_FRAME_FORMAT (&out_frame),
- GST_VIDEO_FRAME_WIDTH (&out_frame),
- GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ filter->download = gst_gl_download_new (filter->display);
gst_gl_download_init_format (filter->download,
GST_VIDEO_FRAME_FORMAT (&out_frame),
mem->notify = notify;
mem->user_data = user_data;
mem->wrapped = FALSE;
- mem->upload = gst_gl_display_find_upload (display, v_format,
- width, height, width, height);
- mem->download = gst_gl_display_find_download (display, v_format,
- width, height);
+ mem->upload = gst_gl_upload_new (display);
+ mem->download = gst_gl_download_new (display);
GST_CAT_DEBUG (GST_CAT_GL_MEMORY,
"new GL texture memory:%p format:%u dimensions:%" G_GSIZE_FORMAT
GstGLMixerPrivate *priv = mix->priv;
GstVideoInfo info;
guint out_width, out_height;
- GstVideoFormat out_format;
gboolean ret = TRUE;
GST_INFO_OBJECT (mix, "set src caps: %" GST_PTR_FORMAT, caps);
mix->out_info = info;
- out_format = GST_VIDEO_INFO_FORMAT (&mix->out_info);
out_width = GST_VIDEO_INFO_WIDTH (&mix->out_info);
out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
&mix->fbo, &mix->depthbuffer))
goto display_error;
- mix->download = gst_gl_display_find_download (mix->display,
- out_format, out_width, out_height);
-
- gst_gl_download_init_format (mix->download, out_format, out_width,
- out_height);
-
if (mix->out_tex_id)
gst_gl_display_del_texture (mix->display, &mix->out_tex_id);
gst_gl_display_gen_texture (mix->display, &mix->out_tex_id,
out_tex = mix->out_tex_id;;
+ if (!mix->download) {
+ mix->download = gst_gl_download_new (mix->display);
+ gst_gl_download_init_format (mix->download,
+ GST_VIDEO_FRAME_FORMAT (&out_frame),
+ GST_VIDEO_FRAME_WIDTH (&out_frame),
+ GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ }
+
out_gl_wrapped = TRUE;
}
out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
if (!pad->upload) {
- pad->upload = gst_gl_display_find_upload (mix->display,
- in_format, in_width, in_height, in_width, in_height);
+ pad->upload = gst_gl_upload_new (mix->display);
gst_gl_upload_init_format (pad->upload, in_format,
in_width, in_height, in_width, in_height);
case GST_STATE_CHANGE_PAUSED_TO_READY:
{
guint i;
+ GSList *walk = mix->sinkpads;
GST_LOG_OBJECT (mix, "stopping collectpads");
gst_collect_pads_stop (mix->collect);
mix->fbo = 0;
mix->depthbuffer = 0;
}
+ if (mix->download) {
+ g_object_unref (mix->download);
+ mix->download = NULL;
+ }
+
+ while (walk) {
+ GstGLMixerPad *pad = (GstGLMixerPad *) (walk->data);
+
+ if (pad->upload) {
+ g_object_unref (pad->upload);
+ pad->upload = NULL;
+ }
+
+ walk = walk->next;
+ }
+
if (mix->display) {
g_object_unref (mix->display);
mix->display = NULL;
#include <gst/base/gstcollectpads.h>
#include "gstgldisplay.h"
+#include <gst/gl/gstglupload.h>
G_BEGIN_DECLS
return TRUE;
}
-/**
- * gst_gl_display_find_upload_unlocked:
- * @display: a #GstGLDisplay
- * @v_format: a #GstVideoFormat
- * @in_width: the width of the data to upload
- * @in_height: the height of the data to upload
- * @out_width: the width to upload to
- * @out_height: the height to upload to
- *
- * Finds a #GstGLDownload with the required upload settings, creating one
- * if needed. The returned object may not be initialized so you still
- * have to call gst_gl_upload_init_format.
- *
- * This function is safe to be called in the GL thread
- *
- * Returns: a #GstGLUpload object with the required settings
- */
-GstGLUpload *
-gst_gl_display_find_upload_unlocked (GstGLDisplay * display,
- GstVideoFormat v_format, guint in_width, guint in_height,
- guint out_width, guint out_height)
-{
- GstGLUpload *ret = NULL;
- GSList *walk;
-
- walk = display->uploads;
-
- while (walk) {
- ret = walk->data;
-
- if (ret && v_format == GST_VIDEO_INFO_FORMAT (&ret->info) &&
- out_width == GST_VIDEO_INFO_WIDTH (&ret->info) &&
- out_height == GST_VIDEO_INFO_HEIGHT (&ret->info) &&
- in_width == ret->in_width && in_height == ret->in_height)
- break;
-
- ret = NULL;
- walk = g_slist_next (walk);
- }
-
- if (!ret) {
- ret = gst_gl_upload_new (display);
-
- display->uploads = g_slist_prepend (display->uploads, ret);
- }
-
- return ret;
-}
-
-/**
- * gst_gl_display_find_upload:
- * @display: a #GstGLDisplay
- * @v_format: a #GstVideoFormat
- * @in_width: the width of the data to upload
- * @in_height: the height of the data to upload
- * @out_width: the width to upload to
- * @out_height: the height to upload to
- *
- * Finds a #GstGLDownload with the required upload settings, creating one
- * if needed. The returned object may not be initialized so you still
- * have to call gst_gl_upload_init_format.
- *
- * Returns: a #GstGLUpload object with the required settings
- */
-GstGLUpload *
-gst_gl_display_find_upload (GstGLDisplay * display, GstVideoFormat v_format,
- guint in_width, guint in_height, guint out_width, guint out_height)
-{
- GstGLUpload *ret;
-
- gst_gl_display_lock (display);
-
- ret =
- gst_gl_display_find_upload_unlocked (display, v_format, in_width,
- in_height, out_width, out_height);
-
- gst_gl_display_unlock (display);
-
- return ret;
-}
-
static gboolean
_create_shader (GstGLDisplay * display, const gchar * vertex_src,
const gchar * fragment_src, GstGLShader ** out_shader)
gboolean gst_gl_upload_perform_with_data_thread (GstGLUpload * upload, GLuint texture_id,
gpointer data[GST_VIDEO_MAX_PLANES]);
-GstGLUpload * gst_gl_display_find_upload (GstGLDisplay * display, GstVideoFormat v_format,
- guint in_width, guint in_height,
- guint out_width, guint out_height);
-GstGLUpload * gst_gl_display_find_upload_unlocked (GstGLDisplay * display, GstVideoFormat v_format,
- guint in_width, guint in_height,
- guint out_width, guint out_height);
-
G_END_DECLS
#endif /* __GST_GL_UPLOAD_H__ */
case GST_STATE_CHANGE_PAUSED_TO_READY:
{
if (glimage_sink->stored_buffer) {
- gst_buffer_unref (GST_BUFFER_CAST (glimage_sink->stored_buffer));
+ gst_buffer_unref (glimage_sink->stored_buffer);
glimage_sink->stored_buffer = NULL;
}
- if (glimage_sink->display) {
- g_object_unref (glimage_sink->display);
- glimage_sink->display = NULL;
+ if (glimage_sink->upload) {
+ g_object_unref (glimage_sink->upload);
+ glimage_sink->upload = NULL;
}
glimage_sink->window_id = 0;
GST_VIDEO_SINK_WIDTH (glimage_sink) = 1;
GST_VIDEO_SINK_HEIGHT (glimage_sink) = 1;
- }
+
+ gst_gl_window_set_resize_callback (glimage_sink->display->gl_window,
+ GST_GL_WINDOW_RESIZE_CB (NULL), NULL);
+ gst_gl_window_set_draw_callback (glimage_sink->display->gl_window,
+ GST_GL_WINDOW_CB (NULL), NULL);
+ gst_gl_window_set_close_callback (glimage_sink->display->gl_window,
+ GST_GL_WINDOW_CB (NULL), NULL);
+ if (glimage_sink->display) {
+ g_object_unref (glimage_sink->display);
+ glimage_sink->display = NULL;
+ }
break;
+ }
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
gst_gl_display_gen_texture (glimage_sink->display, &glimage_sink->tex_id,
GST_VIDEO_INFO_FORMAT (&vinfo), width, height);
- glimage_sink->upload = gst_gl_display_find_upload (glimage_sink->display,
- GST_VIDEO_INFO_FORMAT (&vinfo), width, height, width, height);
-
- gst_gl_upload_init_format (glimage_sink->upload,
- GST_VIDEO_INFO_FORMAT (&vinfo), width, height, width, height);
-
par_n = GST_VIDEO_INFO_PAR_N (&vinfo);
par_d = GST_VIDEO_INFO_PAR_D (&vinfo);
GST_INFO ("Input Buffer does not contain correct meta, "
"attempting to wrap for upload");
+ if (!glimage_sink->upload) {
+ glimage_sink->upload = gst_gl_upload_new (glimage_sink->display);
+
+ gst_gl_upload_init_format (glimage_sink->upload,
+ GST_VIDEO_FRAME_FORMAT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
+ GST_VIDEO_FRAME_HEIGHT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
+ GST_VIDEO_FRAME_HEIGHT (&frame));
+ }
+
gst_gl_upload_perform_with_data (glimage_sink->upload,
glimage_sink->tex_id, frame.data);
static gboolean
gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
{
- GstVideoInfo vinfo;
GstGLTestSrc *gltestsrc = GST_GL_TEST_SRC (bsrc);
guint out_width, out_height;
GST_DEBUG ("setcaps");
- if (!gst_video_info_from_caps (&vinfo, caps))
+ if (!gst_video_info_from_caps (&gltestsrc->out_info, caps))
goto wrong_caps;
- gltestsrc->out_info = vinfo;
gltestsrc->negotiated = TRUE;
out_width = GST_VIDEO_INFO_WIDTH (&gltestsrc->out_info);
out_height = GST_VIDEO_INFO_HEIGHT (&gltestsrc->out_info);
&gltestsrc->fbo, &gltestsrc->depthbuffer))
goto display_error;
- if (gltestsrc->out_tex_id)
- gst_gl_display_del_texture (gltestsrc->display, &gltestsrc->out_tex_id);
- gst_gl_display_gen_texture (gltestsrc->display, &gltestsrc->out_tex_id,
- GST_VIDEO_FORMAT_RGBA, out_width, out_height);
-
- gltestsrc->download = gst_gl_display_find_download (gltestsrc->display,
- GST_VIDEO_INFO_FORMAT (&gltestsrc->out_info), out_width, out_height);
-
- gst_gl_download_init_format (gltestsrc->download,
- GST_VIDEO_INFO_FORMAT (&gltestsrc->out_info), out_width, out_height);
-
return TRUE;
/* ERRORS */
GST_INFO ("Output Buffer does not contain correct meta, "
"attempting to wrap for download");
- out_tex = src->out_tex_id;;
+ if (!src->out_tex_id) {
+ gst_gl_display_gen_texture (src->display, &src->out_tex_id,
+ GST_VIDEO_FORMAT_RGBA, GST_VIDEO_FRAME_WIDTH (&out_frame),
+ GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ }
+ out_tex = src->out_tex_id;
+
+ if (!src->download) {
+ src->download = gst_gl_download_new (src->display);
+
+ gst_gl_download_init_format (src->download,
+ GST_VIDEO_FRAME_FORMAT (&out_frame),
+ GST_VIDEO_FRAME_WIDTH (&out_frame),
+ GST_VIDEO_FRAME_HEIGHT (&out_frame));
+ }
out_gl_wrapped = TRUE;
}
- src->buffer = gst_buffer_ref (buffer);
+ gst_buffer_replace (&src->buffer, buffer);
//blocking call, generate a FBO
if (!gst_gl_display_use_fbo (src->display, width, height, src->fbo,
GstGLTestSrc *src = GST_GL_TEST_SRC (basesrc);
if (src->display) {
+ if (src->out_tex_id) {
+ gst_gl_display_del_texture (src->display, &src->out_tex_id);
+ }
+
+ if (src->download) {
+ g_object_unref (src->download);
+ src->download = NULL;
+ }
//blocking call, delete the FBO
gst_gl_display_del_fbo (src->display, src->fbo, src->depthbuffer);
g_object_unref (src->display);