/* * GStreamer * Copyright (C) 2007 David Schleef * * 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 #include #include #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 { GstElement element; GstPad *srcpad; GstPad *sinkpad; /* < private > */ GstGLDisplay *display; GstVideoFormat format; int width; int height; }; struct _GstGLUploadClass { GstElementClass element_class; }; static const GstElementDetails element_details = GST_ELEMENT_DETAILS ("FIXME", "Filter/Effect", "FIXME example filter", "FIXME "); #define GST_GL_VIDEO_CAPS "video/x-raw-gl" 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 = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx) ); enum { PROP_0 }; #define DEBUG_INIT(bla) \ GST_DEBUG_CATEGORY_INIT (gst_gl_upload_debug, "glupload", 0, "glupload element"); GST_BOILERPLATE_FULL (GstGLUpload, gst_gl_upload, GstElement, GST_TYPE_ELEMENT, DEBUG_INIT); 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 GstFlowReturn gst_gl_upload_chain (GstPad * pad, GstBuffer * buf); static void gst_gl_upload_reset (GstGLUpload * upload); 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; } static void gst_gl_upload_init (GstGLUpload * upload, GstGLUploadClass * klass) { gst_pad_set_chain_function (upload->sinkpad, gst_gl_upload_chain); 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) { } static GstFlowReturn gst_gl_upload_chain (GstPad * pad, GstBuffer * buf) { GstGLUpload *upload; GstGLBuffer *outbuf; upload = GST_GL_UPLOAD (gst_pad_get_parent (pad)); outbuf = gst_gl_buffer_new (upload->display, upload->format, upload->width, upload->height); gst_buffer_copy_metadata (GST_BUFFER (outbuf), buf, GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS); gst_gl_buffer_upload (outbuf, GST_BUFFER_DATA (buf)); gst_pad_push (upload->srcpad, GST_BUFFER (outbuf)); gst_object_unref (upload); return GST_FLOW_OK; }