2007-12-18 01:25:58 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2007 David Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2007-12-29 00:37:41 +00:00
|
|
|
#include <gst/base/gstbasetransform.h>
|
2007-12-18 01:25:58 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <gstglbuffer.h>
|
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT gst_gl_upload_debug
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|
|
|
|
|
|
|
#define GST_TYPE_GL_UPLOAD (gst_gl_upload_get_type())
|
|
|
|
#define GST_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_UPLOAD,GstGLUpload))
|
|
|
|
#define GST_IS_GL_UPLOAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_UPLOAD))
|
|
|
|
#define GST_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_UPLOAD,GstGLUploadClass))
|
|
|
|
#define GST_IS_GL_UPLOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_UPLOAD))
|
|
|
|
#define GST_GL_UPLOAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_UPLOAD,GstGLUploadClass))
|
|
|
|
typedef struct _GstGLUpload GstGLUpload;
|
|
|
|
typedef struct _GstGLUploadClass GstGLUploadClass;
|
|
|
|
|
|
|
|
typedef void (*GstGLUploadProcessFunc) (GstGLUpload *, guint8 *, guint);
|
|
|
|
|
|
|
|
struct _GstGLUpload
|
|
|
|
{
|
2007-12-29 00:37:41 +00:00
|
|
|
GstBaseTransform base_transform;
|
2007-12-18 01:25:58 +00:00
|
|
|
|
|
|
|
GstPad *srcpad;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
/* < private > */
|
|
|
|
|
|
|
|
GstGLDisplay *display;
|
2007-12-27 00:52:23 +00:00
|
|
|
GstVideoFormat video_format;
|
|
|
|
GstGLBufferFormat format;
|
2007-12-18 01:25:58 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2007-12-22 05:01:58 +00:00
|
|
|
|
|
|
|
gboolean peek;
|
2007-12-18 01:25:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstGLUploadClass
|
|
|
|
{
|
2007-12-29 00:37:41 +00:00
|
|
|
GstBaseTransformClass base_transform_class;
|
2007-12-18 01:25:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GstElementDetails element_details = GST_ELEMENT_DETAILS ("FIXME",
|
|
|
|
"Filter/Effect",
|
|
|
|
"FIXME example filter",
|
|
|
|
"FIXME <fixme@fixme.com>");
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_gl_upload_src_pad_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_gl_upload_sink_pad_template =
|
2007-12-27 00:52:23 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
2007-12-18 01:25:58 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2007-12-27 00:52:23 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";"
|
|
|
|
GST_VIDEO_CAPS_BGRx ";"
|
|
|
|
GST_VIDEO_CAPS_xRGB ";"
|
|
|
|
GST_VIDEO_CAPS_xBGR ";"
|
|
|
|
GST_VIDEO_CAPS_YUV ("{ YUY2, UYVY, AYUV, YV12, I420 }"))
|
2007-12-18 01:25:58 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEBUG_INIT(bla) \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_gl_upload_debug, "glupload", 0, "glupload element");
|
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
GST_BOILERPLATE_FULL (GstGLUpload, gst_gl_upload, GstBaseTransform,
|
|
|
|
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
2007-12-18 01:25:58 +00:00
|
|
|
|
|
|
|
static void gst_gl_upload_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_gl_upload_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static void gst_gl_upload_reset (GstGLUpload * upload);
|
2007-12-29 00:37:41 +00:00
|
|
|
|
|
|
|
static void gst_gl_upload_reset (GstGLUpload * upload);
|
|
|
|
static gboolean gst_gl_upload_set_caps (GstBaseTransform * bt,
|
|
|
|
GstCaps * incaps, GstCaps * outcaps);
|
|
|
|
static GstCaps *gst_gl_upload_transform_caps (GstBaseTransform * bt,
|
|
|
|
GstPadDirection direction, GstCaps * caps);
|
|
|
|
static gboolean gst_gl_upload_start (GstBaseTransform * bt);
|
|
|
|
static gboolean gst_gl_upload_stop (GstBaseTransform * bt);
|
|
|
|
static GstFlowReturn gst_gl_upload_prepare_output_buffer (GstBaseTransform *
|
|
|
|
trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
|
|
|
|
static GstFlowReturn gst_gl_upload_transform (GstBaseTransform * trans,
|
|
|
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
|
|
|
static gboolean gst_gl_upload_get_unit_size (GstBaseTransform * trans,
|
|
|
|
GstCaps * caps, guint * size);
|
2007-12-18 01:25:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_base_init (gpointer klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &element_details);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_gl_upload_src_pad_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_gl_upload_sink_pad_template));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_class_init (GstGLUploadClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gobject_class->set_property = gst_gl_upload_set_property;
|
|
|
|
gobject_class->get_property = gst_gl_upload_get_property;
|
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
|
|
|
|
gst_gl_upload_transform_caps;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_upload_transform;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_upload_start;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_upload_stop;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_upload_set_caps;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size = gst_gl_upload_get_unit_size;
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
|
|
|
|
gst_gl_upload_prepare_output_buffer;
|
2007-12-18 01:25:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_init (GstGLUpload * upload, GstGLUploadClass * klass)
|
|
|
|
{
|
|
|
|
|
|
|
|
gst_gl_upload_reset (upload);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
//GstGLUpload *upload = GST_GL_UPLOAD (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
//GstGLUpload *upload = GST_GL_UPLOAD (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_upload_reset (GstGLUpload * upload)
|
|
|
|
{
|
2007-12-21 00:03:11 +00:00
|
|
|
if (upload->display) {
|
|
|
|
g_object_unref (upload->display);
|
|
|
|
upload->display = NULL;
|
|
|
|
}
|
2007-12-27 00:52:23 +00:00
|
|
|
upload->format = GST_GL_BUFFER_FORMAT_RGB;
|
2007-12-25 00:34:14 +00:00
|
|
|
upload->peek = FALSE;
|
2007-12-21 00:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-12-29 00:37:41 +00:00
|
|
|
gst_gl_upload_start (GstBaseTransform * bt)
|
2007-12-21 00:03:11 +00:00
|
|
|
{
|
2007-12-29 00:37:41 +00:00
|
|
|
GstGLUpload *upload = GST_GL_UPLOAD (bt);
|
2007-12-21 00:03:11 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2007-12-27 00:52:23 +00:00
|
|
|
upload->format = GST_GL_BUFFER_FORMAT_RGB;
|
2007-12-21 00:03:11 +00:00
|
|
|
upload->display = gst_gl_display_new ();
|
|
|
|
ret = gst_gl_display_connect (upload->display, NULL);
|
2007-12-29 00:37:41 +00:00
|
|
|
//upload->format = GST_VIDEO_FORMAT_RGBx;
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
return TRUE;
|
2007-12-21 00:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-12-29 00:37:41 +00:00
|
|
|
gst_gl_upload_stop (GstBaseTransform * bt)
|
2007-12-21 00:03:11 +00:00
|
|
|
{
|
2007-12-29 00:37:41 +00:00
|
|
|
GstGLUpload *upload = GST_GL_UPLOAD (bt);
|
|
|
|
|
2007-12-21 00:03:11 +00:00
|
|
|
gst_gl_upload_reset (upload);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
#if 0
|
2007-12-21 00:03:11 +00:00
|
|
|
static gboolean
|
|
|
|
gst_gl_upload_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
2007-12-27 00:52:23 +00:00
|
|
|
GstVideoFormat video_format;
|
2007-12-21 00:03:11 +00:00
|
|
|
int height;
|
|
|
|
int width;
|
|
|
|
gboolean ret;
|
|
|
|
GstCaps *srccaps;
|
2007-12-27 05:26:05 +00:00
|
|
|
int fps_n, fps_d;
|
|
|
|
int par_n, par_d;
|
2007-12-21 00:03:11 +00:00
|
|
|
|
|
|
|
upload = GST_GL_UPLOAD (gst_pad_get_parent (pad));
|
|
|
|
|
2007-12-27 00:52:23 +00:00
|
|
|
ret = gst_video_format_parse_caps (caps, &video_format, &width, &height);
|
2007-12-27 05:26:05 +00:00
|
|
|
ret &= gst_video_parse_caps_framerate (caps, &fps_n, &fps_d);
|
|
|
|
|
2007-12-21 00:03:11 +00:00
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-12-27 00:52:23 +00:00
|
|
|
upload->video_format = video_format;
|
2007-12-21 00:03:11 +00:00
|
|
|
upload->width = width;
|
|
|
|
upload->height = height;
|
|
|
|
|
2007-12-27 00:52:23 +00:00
|
|
|
GST_DEBUG ("setcaps %d %d %d", video_format, width, height);
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-27 05:26:05 +00:00
|
|
|
par_n = 1;
|
|
|
|
par_d = 1;
|
|
|
|
gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d);
|
|
|
|
|
2007-12-21 00:03:11 +00:00
|
|
|
srccaps = gst_caps_new_simple ("video/x-raw-gl",
|
2007-12-27 05:26:05 +00:00
|
|
|
"format", G_TYPE_INT, 0,
|
|
|
|
"width", G_TYPE_INT, width, "height", G_TYPE_INT, height,
|
|
|
|
"framerate", GST_TYPE_FRACTION, fps_n, fps_d,
|
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL);
|
|
|
|
|
2007-12-21 00:03:11 +00:00
|
|
|
ret = gst_pad_set_caps (upload->srcpad, srccaps);
|
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
|
|
|
|
return ret;
|
2007-12-18 01:25:58 +00:00
|
|
|
}
|
2007-12-29 00:37:41 +00:00
|
|
|
#endif
|
2007-12-18 01:25:58 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
#if 0
|
2007-12-18 01:25:58 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_gl_upload_chain (GstPad * pad, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
|
|
|
GstGLBuffer *outbuf;
|
|
|
|
|
|
|
|
upload = GST_GL_UPLOAD (gst_pad_get_parent (pad));
|
|
|
|
|
2007-12-27 00:52:23 +00:00
|
|
|
outbuf = gst_gl_buffer_new_from_data (upload->display,
|
|
|
|
upload->video_format, upload->width, upload->height,
|
|
|
|
GST_BUFFER_DATA (buf));
|
2007-12-18 01:25:58 +00:00
|
|
|
|
|
|
|
gst_buffer_copy_metadata (GST_BUFFER (outbuf), buf,
|
|
|
|
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS);
|
2007-12-21 00:03:11 +00:00
|
|
|
gst_buffer_set_caps (GST_BUFFER (outbuf), GST_PAD_CAPS (upload->srcpad));
|
|
|
|
|
|
|
|
GST_DEBUG ("uploading %p size %d", GST_BUFFER_DATA (buf),
|
|
|
|
GST_BUFFER_SIZE (buf));
|
2007-12-22 05:01:58 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
if (upload->peek) {
|
2007-12-24 20:53:56 +00:00
|
|
|
gst_gl_display_draw_texture (outbuf->display, outbuf->texture,
|
2007-12-22 05:01:58 +00:00
|
|
|
outbuf->width, outbuf->height);
|
|
|
|
}
|
2007-12-18 01:25:58 +00:00
|
|
|
|
|
|
|
gst_pad_push (upload->srcpad, GST_BUFFER (outbuf));
|
|
|
|
|
|
|
|
gst_object_unref (upload);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2007-12-29 00:37:41 +00:00
|
|
|
#endif
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_gl_upload_transform_caps (GstBaseTransform * bt,
|
|
|
|
GstPadDirection direction, GstCaps * caps)
|
2007-12-21 00:03:11 +00:00
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
2007-12-29 00:37:41 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
GstCaps *newcaps;
|
|
|
|
GstStructure *newstruct;
|
|
|
|
const GValue *width_value;
|
|
|
|
const GValue *height_value;
|
|
|
|
const GValue *framerate_value;
|
|
|
|
const GValue *par_value;
|
|
|
|
|
|
|
|
upload = GST_GL_UPLOAD (bt);
|
|
|
|
|
|
|
|
GST_ERROR ("transform caps %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
width_value = gst_structure_get_value (structure, "width");
|
|
|
|
height_value = gst_structure_get_value (structure, "height");
|
|
|
|
framerate_value = gst_structure_get_value (structure, "framerate");
|
|
|
|
par_value = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
|
|
|
|
|
|
|
if (direction == GST_PAD_SRC) {
|
|
|
|
newcaps = gst_caps_new_simple ("video/x-raw-rgb", NULL);
|
|
|
|
} else {
|
|
|
|
newcaps = gst_caps_new_simple ("video/x-raw-gl",
|
|
|
|
"format", G_TYPE_INT, GST_GL_BUFFER_FORMAT_RGBA,
|
|
|
|
"is_yuv", G_TYPE_BOOLEAN, FALSE, NULL);
|
|
|
|
}
|
|
|
|
newstruct = gst_caps_get_structure (newcaps, 0);
|
|
|
|
gst_structure_set_value (newstruct, "width", width_value);
|
|
|
|
gst_structure_set_value (newstruct, "height", height_value);
|
|
|
|
gst_structure_set_value (newstruct, "framerate", framerate_value);
|
|
|
|
if (par_value) {
|
|
|
|
gst_structure_set_value (newstruct, "pixel-aspect-ratio", par_value);
|
|
|
|
} else {
|
|
|
|
gst_structure_set (newstruct, "pixel-aspect-ratio", GST_TYPE_FRACTION,
|
|
|
|
1, 1, NULL);
|
|
|
|
}
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
GST_ERROR ("new caps %" GST_PTR_FORMAT, newcaps);
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
return newcaps;
|
|
|
|
}
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
static gboolean
|
|
|
|
gst_gl_upload_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|
|
|
GstCaps * outcaps)
|
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
|
|
|
gboolean ret;
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
upload = GST_GL_UPLOAD (bt);
|
2007-12-21 00:03:11 +00:00
|
|
|
|
2007-12-29 00:37:41 +00:00
|
|
|
GST_DEBUG ("called with %" GST_PTR_FORMAT, incaps);
|
|
|
|
|
|
|
|
ret = gst_video_format_parse_caps (incaps, &upload->video_format,
|
|
|
|
&upload->width, &upload->height);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
GST_DEBUG ("bad caps");
|
|
|
|
return FALSE;
|
2007-12-21 00:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2007-12-29 00:37:41 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_gl_upload_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|
|
|
guint * size)
|
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
GstStructure *structure;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
if (gst_structure_has_name (structure, "video/x-raw-gl")) {
|
|
|
|
GstGLBufferFormat format;
|
|
|
|
|
|
|
|
ret = gst_gl_buffer_format_parse_caps (caps, &format, &width, &height);
|
|
|
|
if (ret) {
|
|
|
|
*size = gst_gl_buffer_format_get_size (format, width, height);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GstVideoFormat format;
|
|
|
|
|
|
|
|
ret = gst_video_format_parse_caps (caps, &format, &width, &height);
|
|
|
|
if (ret) {
|
|
|
|
*size = gst_video_format_get_size (format, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_gl_upload_prepare_output_buffer (GstBaseTransform * trans,
|
|
|
|
GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf)
|
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
|
|
|
GstGLBuffer *gl_outbuf;
|
|
|
|
|
|
|
|
upload = GST_GL_UPLOAD (trans);
|
|
|
|
|
|
|
|
gl_outbuf = gst_gl_buffer_new_from_video_format (upload->display,
|
|
|
|
upload->video_format, upload->width, upload->height);
|
|
|
|
|
|
|
|
*buf = GST_BUFFER (gl_outbuf);
|
|
|
|
gst_buffer_set_caps (*buf, caps);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_gl_upload_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|
|
|
GstBuffer * outbuf)
|
|
|
|
{
|
|
|
|
GstGLUpload *upload;
|
|
|
|
GstGLBuffer *gl_outbuf = GST_GL_BUFFER (outbuf);
|
|
|
|
|
|
|
|
upload = GST_GL_UPLOAD (trans);
|
|
|
|
|
|
|
|
GST_DEBUG ("uploading %p size %d",
|
|
|
|
GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
|
|
|
|
gst_gl_buffer_upload (gl_outbuf, upload->video_format,
|
|
|
|
GST_BUFFER_DATA (inbuf));
|
|
|
|
|
|
|
|
if (upload->peek) {
|
|
|
|
gst_gl_display_draw_texture (gl_outbuf->display, gl_outbuf->texture,
|
2008-01-06 03:01:39 +00:00
|
|
|
gl_outbuf->width, gl_outbuf->height, FALSE);
|
2007-12-29 00:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|