glimage_sink->stored_buffer = NULL;
}
GST_GLIMAGE_SINK_UNLOCK (glimage_sink);
+ gst_buffer_replace (&glimage_sink->next_buffer, NULL);
if (glimage_sink->upload) {
gst_object_unref (glimage_sink->upload);
gst_glimage_sink_prepare (GstBaseSink * bsink, GstBuffer * buf)
{
GstGLImageSink *glimage_sink;
+ GstBuffer *next_buffer = NULL;
glimage_sink = GST_GLIMAGE_SINK (bsink);
return GST_FLOW_NOT_NEGOTIATED;
if (!gst_gl_upload_perform_with_buffer (glimage_sink->upload, buf,
- &glimage_sink->next_tex))
+ &glimage_sink->next_tex, &next_buffer))
goto upload_failed;
+ gst_buffer_replace (&glimage_sink->next_buffer, next_buffer);
+ gst_buffer_unref (next_buffer);
+
if (glimage_sink->window_id != glimage_sink->new_window_id) {
GstGLWindow *window = gst_gl_context_get_window (glimage_sink->context);
GST_GLIMAGE_SINK_LOCK (glimage_sink);
glimage_sink->redisplay_texture = glimage_sink->next_tex;
stored_buffer = glimage_sink->stored_buffer;
- glimage_sink->stored_buffer = gst_buffer_ref (buf);
+ glimage_sink->stored_buffer = gst_buffer_ref (glimage_sink->next_buffer);
GST_GLIMAGE_SINK_UNLOCK (glimage_sink);
- if (stored_buffer)
- gst_buffer_unref (stored_buffer);
/* Ask the underlying window to redraw its content */
if (!gst_glimage_sink_redisplay (glimage_sink))
GST_TRACE ("post redisplay");
+ if (stored_buffer)
+ gst_buffer_unref (stored_buffer);
+
if (g_atomic_int_get (&glimage_sink->to_quit) != 0) {
GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
("%s", gst_gl_context_get_error ()), (NULL));
static gboolean _upload_memory (GstGLUpload * upload);
static gboolean _init_upload (GstGLUpload * upload);
static gboolean _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
- GLuint * texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
+ GLuint * texture_id, gpointer data[GST_VIDEO_MAX_PLANES],
+ GstBuffer ** outbuf);
static void _do_upload_with_meta (GstGLContext * context, GstGLUpload * upload);
static void gst_gl_upload_reset (GstGLUpload * upload);
* @upload: a #GstGLUpload
* @buffer: a #GstBuffer
* @tex_id: resulting texture
+ * @outbuf: (allow-none): resulting buffer
*
* Uploads @buffer to the texture given by @tex_id. @tex_id is valid
* until gst_gl_upload_release_buffer() is called.
*/
gboolean
gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
- guint * tex_id)
+ guint * tex_id, GstBuffer ** outbuf)
{
GstMemory *mem;
GstVideoGLTextureUploadMeta *gl_tex_upload_meta;
gst_memory_unmap (mem, &map_info);
*tex_id = ((GstGLMemory *) mem)->tex_id;
+
+ if (outbuf)
+ *outbuf = gst_buffer_ref (buffer);
+
return TRUE;
}
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {
upload->in_tex[i] = NULL;
}
+
+ if (ret && outbuf != NULL)
+ *outbuf = gst_buffer_ref (upload->priv->outbuf);
+
return ret;
}
#if GST_GL_HAVE_PLATFORM_EGL
texture_ids[0] = upload->priv->tex_id;
if (!gst_gl_upload_perform_with_gl_texture_upload_meta (upload,
- gl_tex_upload_meta, texture_ids)) {
+ gl_tex_upload_meta, texture_ids, outbuf)) {
GST_DEBUG_OBJECT (upload, "Upload with GstVideoGLTextureUploadMeta "
"failed");
} else {
gst_gl_upload_set_format (upload, &upload->priv->frame.info);
if (!gst_gl_upload_perform_with_data (upload, tex_id,
- upload->priv->frame.data)) {
+ upload->priv->frame.data, outbuf)) {
return FALSE;
}
* @upload: a #GstGLUpload
* @meta: a #GstVideoGLTextureUploadMeta
* @texture_id: resulting GL textures to place the data into.
+ * @outbuf: (allow-none): resulting buffer
*
* Uploads @meta into @texture_id.
*
*/
gboolean
gst_gl_upload_perform_with_gl_texture_upload_meta (GstGLUpload * upload,
- GstVideoGLTextureUploadMeta * meta, guint texture_id[4])
+ GstVideoGLTextureUploadMeta * meta, guint texture_id[4],
+ GstBuffer ** outbuf)
{
gboolean ret;
ret = upload->priv->result;
+ if (ret && outbuf != NULL)
+ *outbuf = gst_buffer_ref (upload->priv->outbuf);
+
GST_OBJECT_UNLOCK (upload);
return ret;
* @upload: a #GstGLUpload
* @texture_id: (out): the texture id to upload into
* @data: where the downloaded data should go
+ * @outbuf: (allow-none): resulting buffer
*
* Uploads @data into @texture_id. data size and format is specified by
* the #GstVideoInfo<!-- -->s passed to gst_gl_upload_set_format()
*/
gboolean
gst_gl_upload_perform_with_data (GstGLUpload * upload, GLuint * texture_id,
- gpointer data[GST_VIDEO_MAX_PLANES])
+ gpointer data[GST_VIDEO_MAX_PLANES], GstBuffer ** outbuf)
{
gboolean ret;
g_return_val_if_fail (upload != NULL, FALSE);
GST_OBJECT_LOCK (upload);
- ret = _gst_gl_upload_perform_with_data_unlocked (upload, texture_id, data);
+ ret =
+ _gst_gl_upload_perform_with_data_unlocked (upload, texture_id, data,
+ outbuf);
GST_OBJECT_UNLOCK (upload);
return ret;
static gboolean
_gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
- GLuint * texture_id, gpointer data[GST_VIDEO_MAX_PLANES])
+ GLuint * texture_id, gpointer data[GST_VIDEO_MAX_PLANES],
+ GstBuffer ** outbuf)
{
gboolean ret;
guint i;
ret = _upload_memory (upload);
*texture_id = upload->out_tex->tex_id;
+ if (ret && outbuf != NULL)
+ *outbuf = gst_buffer_ref (upload->priv->outbuf);
+
return ret;
}
void gst_gl_upload_set_format (GstGLUpload * upload, GstVideoInfo * in_info);
GstVideoInfo * gst_gl_upload_get_format (GstGLUpload * upload);
-gboolean gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer, guint * tex_id);
+gboolean gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer, guint * tex_id, GstBuffer ** outbuf);
void gst_gl_upload_release_buffer (GstGLUpload * upload);
gboolean gst_gl_upload_perform_with_data (GstGLUpload * upload, GLuint * texture_id,
- gpointer data[GST_VIDEO_MAX_PLANES]);
+ gpointer data[GST_VIDEO_MAX_PLANES], GstBuffer ** outbuf);
-gboolean gst_gl_upload_perform_with_gl_texture_upload_meta (GstGLUpload *upload, GstVideoGLTextureUploadMeta *meta, guint texture_id[4]);
+gboolean gst_gl_upload_perform_with_gl_texture_upload_meta (GstGLUpload *upload, GstVideoGLTextureUploadMeta *meta, guint texture_id[4], GstBuffer ** outbuf);
G_END_DECLS