2 * Copyright (C) 2010 David Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 * SECTION:element-gstsdimux
22 * The gstsdimux element does FIXME stuff.
25 * <title>Example launch line</title>
27 * gst-launch -v fakesrc ! gstsdimux ! FIXME ! fakesink
29 * FIXME Describe what the pipeline does.
39 #include "gstsdimux.h"
44 static void gst_sdi_mux_set_property (GObject * object,
45 guint property_id, const GValue * value, GParamSpec * pspec);
46 static void gst_sdi_mux_get_property (GObject * object,
47 guint property_id, GValue * value, GParamSpec * pspec);
48 static void gst_sdi_mux_dispose (GObject * object);
49 static void gst_sdi_mux_finalize (GObject * object);
51 static GstPad *gst_sdi_mux_request_new_pad (GstElement * element,
52 GstPadTemplate * templ, const gchar * name);
53 static void gst_sdi_mux_release_pad (GstElement * element, GstPad * pad);
54 static GstStateChangeReturn
55 gst_sdi_mux_change_state (GstElement * element, GstStateChange transition);
56 static const GstQueryType *gst_sdi_mux_get_query_types (GstElement * element);
57 static gboolean gst_sdi_mux_query (GstElement * element, GstQuery * query);
58 static GstFlowReturn gst_sdi_mux_chain (GstPad * pad, GstBuffer * buffer);
59 static gboolean gst_sdi_mux_sink_event (GstPad * pad, GstEvent * event);
60 static gboolean gst_sdi_mux_src_event (GstPad * pad, GstEvent * event);
69 #define GST_VIDEO_CAPS_NTSC(fourcc) \
70 "video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=480," \
71 "framerate=30000/1001,interlaced=TRUE,pixel-aspect-ratio=10/11," \
72 "chroma-site=mpeg2,color-matrix=sdtv"
73 #define GST_VIDEO_CAPS_NTSC_WIDE(fourcc) \
74 "video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=480," \
75 "framerate=30000/1001,interlaced=TRUE,pixel-aspect-ratio=40/33," \
76 "chroma-site=mpeg2,color-matrix=sdtv"
77 #define GST_VIDEO_CAPS_PAL(fourcc) \
78 "video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=576," \
79 "framerate=25/1,interlaced=TRUE,pixel-aspect-ratio=12/11," \
80 "chroma-site=mpeg2,color-matrix=sdtv"
81 #define GST_VIDEO_CAPS_PAL_WIDE(fourcc) \
82 "video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=576," \
83 "framerate=25/1,interlaced=TRUE,pixel-aspect-ratio=16/11," \
84 "chroma-site=mpeg2,color-matrix=sdtv"
86 static GstStaticPadTemplate gst_sdi_mux_sink_template =
87 GST_STATIC_PAD_TEMPLATE ("sink",
90 GST_STATIC_CAPS (GST_VIDEO_CAPS_NTSC ("{UYVY,v210}") ";"
91 GST_VIDEO_CAPS_PAL ("{UYVY,v210}"))
94 static GstStaticPadTemplate gst_sdi_mux_src_template =
95 GST_STATIC_PAD_TEMPLATE ("src",
99 ("application/x-raw-sdi,rate=270,format=(fourcc){UYVY,v210}")
102 /* class initialization */
104 GST_BOILERPLATE (GstSdiMux, gst_sdi_mux, GstElement, GST_TYPE_ELEMENT);
107 gst_sdi_mux_base_init (gpointer g_class)
109 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
111 gst_element_class_add_static_pad_template (element_class,
112 &gst_sdi_mux_src_template);
113 gst_element_class_add_static_pad_template (element_class,
114 &gst_sdi_mux_sink_template);
116 gst_element_class_set_details_simple (element_class, "SDI Muxer",
118 "Multiplex raw audio and video into SDI",
119 "David Schleef <ds@schleef.org>");
123 gst_sdi_mux_class_init (GstSdiMuxClass * klass)
125 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
126 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
128 gobject_class->set_property = gst_sdi_mux_set_property;
129 gobject_class->get_property = gst_sdi_mux_get_property;
130 gobject_class->dispose = gst_sdi_mux_dispose;
131 gobject_class->finalize = gst_sdi_mux_finalize;
132 element_class->request_new_pad =
133 GST_DEBUG_FUNCPTR (gst_sdi_mux_request_new_pad);
134 element_class->release_pad = GST_DEBUG_FUNCPTR (gst_sdi_mux_release_pad);
135 element_class->change_state = GST_DEBUG_FUNCPTR (gst_sdi_mux_change_state);
136 element_class->get_query_types =
137 GST_DEBUG_FUNCPTR (gst_sdi_mux_get_query_types);
138 element_class->query = GST_DEBUG_FUNCPTR (gst_sdi_mux_query);
143 gst_sdi_mux_init (GstSdiMux * sdimux, GstSdiMuxClass * sdimux_class)
147 gst_pad_new_from_static_template (&gst_sdi_mux_sink_template, "sink");
148 gst_pad_set_event_function (sdimux->sinkpad,
149 GST_DEBUG_FUNCPTR (gst_sdi_mux_sink_event));
150 gst_pad_set_chain_function (sdimux->sinkpad,
151 GST_DEBUG_FUNCPTR (gst_sdi_mux_chain));
152 gst_element_add_pad (GST_ELEMENT (sdimux), sdimux->sinkpad);
154 sdimux->srcpad = gst_pad_new_from_static_template (&gst_sdi_mux_src_template,
156 gst_pad_set_event_function (sdimux->srcpad,
157 GST_DEBUG_FUNCPTR (gst_sdi_mux_src_event));
158 gst_element_add_pad (GST_ELEMENT (sdimux), sdimux->srcpad);
163 gst_sdi_mux_set_property (GObject * object, guint property_id,
164 const GValue * value, GParamSpec * pspec)
166 g_return_if_fail (GST_IS_SDI_MUX (object));
168 switch (property_id) {
170 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
176 gst_sdi_mux_get_property (GObject * object, guint property_id,
177 GValue * value, GParamSpec * pspec)
179 g_return_if_fail (GST_IS_SDI_MUX (object));
181 switch (property_id) {
183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
189 gst_sdi_mux_dispose (GObject * object)
191 g_return_if_fail (GST_IS_SDI_MUX (object));
193 /* clean up as possible. may be called multiple times */
195 G_OBJECT_CLASS (parent_class)->dispose (object);
199 gst_sdi_mux_finalize (GObject * object)
201 g_return_if_fail (GST_IS_SDI_MUX (object));
203 /* clean up object here */
205 G_OBJECT_CLASS (parent_class)->finalize (object);
211 gst_sdi_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
219 gst_sdi_mux_release_pad (GstElement * element, GstPad * pad)
224 static GstStateChangeReturn
225 gst_sdi_mux_change_state (GstElement * element, GstStateChange transition)
228 return GST_STATE_CHANGE_SUCCESS;
231 static const GstQueryType *
232 gst_sdi_mux_get_query_types (GstElement * element)
239 gst_sdi_mux_query (GstElement * element, GstQuery * query)
246 gst_sdi_mux_chain (GstPad * pad, GstBuffer * buffer)
250 sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
252 GST_DEBUG_OBJECT (sdimux, "chain");
255 gst_object_unref (sdimux);
260 gst_sdi_mux_sink_event (GstPad * pad, GstEvent * event)
265 sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
267 GST_DEBUG_OBJECT (sdimux, "event");
269 switch (GST_EVENT_TYPE (event)) {
270 case GST_EVENT_FLUSH_START:
271 res = gst_pad_push_event (sdimux->srcpad, event);
273 case GST_EVENT_FLUSH_STOP:
274 res = gst_pad_push_event (sdimux->srcpad, event);
276 case GST_EVENT_NEWSEGMENT:
277 res = gst_pad_push_event (sdimux->srcpad, event);
280 res = gst_pad_push_event (sdimux->srcpad, event);
283 res = gst_pad_push_event (sdimux->srcpad, event);
287 gst_object_unref (sdimux);
292 gst_sdi_mux_src_event (GstPad * pad, GstEvent * event)
297 sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
299 GST_DEBUG_OBJECT (sdimux, "event");
301 switch (GST_EVENT_TYPE (event)) {
303 res = gst_pad_push_event (sdimux->sinkpad, event);
306 res = gst_pad_push_event (sdimux->sinkpad, event);
310 gst_object_unref (sdimux);