Commit ec6e7c42 authored by David Schleef's avatar David Schleef

sdi: Add raw SDI muxing/demuxing elements

parent 9ed93db1
......@@ -340,6 +340,7 @@ AG_GST_CHECK_PLUGIN(real)
AG_GST_CHECK_PLUGIN(rtpmux)
AG_GST_CHECK_PLUGIN(rtpvp8)
AG_GST_CHECK_PLUGIN(scaletempo)
AG_GST_CHECK_PLUGIN(sdi)
AG_GST_CHECK_PLUGIN(sdp)
AG_GST_CHECK_PLUGIN(segmentclip)
AG_GST_CHECK_PLUGIN(siren)
......@@ -1763,6 +1764,7 @@ gst/real/Makefile
gst/rtpmux/Makefile
gst/rtpvp8/Makefile
gst/scaletempo/Makefile
gst/sdi/Makefile
gst/sdp/Makefile
gst/segmentclip/Makefile
gst/siren/Makefile
......
plugin_LTLIBRARIES = libgstsdi.la
libgstsdi_la_SOURCES = gstsdi.c \
gstsdidemux.c \
gstsdimux.c
libgstsdi_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstsdi_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
$(GST_LIBS)
libgstsdi_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstsdi_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstsdidemux.h gstsdimux.h
/* GStreamer
* Copyright (C) 2010 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 "gstsdidemux.h"
#include "gstsdimux.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gst_element_register (plugin, "sdidemux", GST_RANK_NONE,
gst_sdi_demux_get_type ());
gst_element_register (plugin, "sdimux", GST_RANK_NONE,
gst_sdi_mux_get_type ());
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"sdi",
"SDI elements", plugin_init, VERSION, "LGPL", PACKAGE_NAME,
GST_PACKAGE_ORIGIN)
This diff is collapsed.
/* GStreamer
* Copyright (C) 2010 REAL_NAME <EMAIL_ADDRESS>
*
* 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.
*/
#ifndef _GST_SDI_DEMUX_H_
#define _GST_SDI_DEMUX_H_
#include <gst/gst.h>
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_SDI_DEMUX (gst_sdi_demux_get_type())
#define GST_SDI_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SDI_DEMUX,GstSdiDemux))
#define GST_SDI_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SDI_DEMUX,GstSdiDemuxClass))
#define GST_IS_SDI_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDI_DEMUX))
#define GST_IS_SDI_DEMUX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDI_DEMUX))
typedef struct _GstSdiDemux GstSdiDemux;
typedef struct _GstSdiDemuxClass GstSdiDemuxClass;
typedef struct _GstSdiFormat GstSdiFormat;
struct _GstSdiDemux
{
GstElement base_sdidemux;
GstPad *sinkpad;
GstPad *srcpad;
GstBuffer *output_buffer;
int line;
int offset;
gboolean have_hsync;
gboolean have_vsync;
guchar stored_line[2160]; /* 864/2*5 */
int frame_number;
guint32 last_sync;
GstSdiFormat *format;
};
struct _GstSdiFormat
{
int lines;
int active_lines;
int width;
int start0;
int start1;
int tff;
};
struct _GstSdiDemuxClass
{
GstElementClass base_sdidemux_class;
};
GType gst_sdi_demux_get_type (void);
G_END_DECLS
#endif
/* GStreamer
* Copyright (C) 2010 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.
*/
/**
* SECTION:element-gstsdimux
*
* The gstsdimux element does FIXME stuff.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch -v fakesrc ! gstsdimux ! FIXME ! fakesink
* ]|
* FIXME Describe what the pipeline does.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/gst.h>
#include "gstsdimux.h"
/* prototypes */
static void gst_sdi_mux_set_property (GObject * object,
guint property_id, const GValue * value, GParamSpec * pspec);
static void gst_sdi_mux_get_property (GObject * object,
guint property_id, GValue * value, GParamSpec * pspec);
static void gst_sdi_mux_dispose (GObject * object);
static void gst_sdi_mux_finalize (GObject * object);
static GstPad *gst_sdi_mux_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name);
static void gst_sdi_mux_release_pad (GstElement * element, GstPad * pad);
static GstStateChangeReturn
gst_sdi_mux_change_state (GstElement * element, GstStateChange transition);
static const GstQueryType *gst_sdi_mux_get_query_types (GstElement * element);
static gboolean gst_sdi_mux_query (GstElement * element, GstQuery * query);
static GstFlowReturn gst_sdi_mux_chain (GstPad * pad, GstBuffer * buffer);
static gboolean gst_sdi_mux_sink_event (GstPad * pad, GstEvent * event);
static gboolean gst_sdi_mux_src_event (GstPad * pad, GstEvent * event);
enum
{
PROP_0
};
/* pad templates */
#define GST_VIDEO_CAPS_NTSC(fourcc) \
"video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=480," \
"framerate=30000/1001,interlaced=TRUE,pixel-aspect-ratio=10/11," \
"chroma-site=mpeg2,color-matrix=sdtv"
#define GST_VIDEO_CAPS_NTSC_WIDE(fourcc) \
"video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=480," \
"framerate=30000/1001,interlaced=TRUE,pixel-aspect-ratio=40/33," \
"chroma-site=mpeg2,color-matrix=sdtv"
#define GST_VIDEO_CAPS_PAL(fourcc) \
"video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=576," \
"framerate=25/1,interlaced=TRUE,pixel-aspect-ratio=12/11," \
"chroma-site=mpeg2,color-matrix=sdtv"
#define GST_VIDEO_CAPS_PAL_WIDE(fourcc) \
"video/x-raw-yuv,format=(fourcc)" fourcc ",width=720,height=576," \
"framerate=25/1,interlaced=TRUE,pixel-aspect-ratio=16/11," \
"chroma-site=mpeg2,color-matrix=sdtv"
static GstStaticPadTemplate gst_sdi_mux_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_NTSC ("{UYVY,v210}") ";"
GST_VIDEO_CAPS_PAL ("{UYVY,v210}"))
);
static GstStaticPadTemplate gst_sdi_mux_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS
("application/x-raw-sdi,rate=270,format=(fourcc){UYVY,v210}")
);
/* class initialization */
GST_BOILERPLATE (GstSdiMux, gst_sdi_mux, GstElement, GST_TYPE_ELEMENT);
static void
gst_sdi_mux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_sdi_mux_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_sdi_mux_sink_template));
gst_element_class_set_details_simple (element_class, "SDI Muxer",
"Muxer",
"Multiplex raw audio and video into SDI",
"David Schleef <ds@schleef.org>");
}
static void
gst_sdi_mux_class_init (GstSdiMuxClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gobject_class->set_property = gst_sdi_mux_set_property;
gobject_class->get_property = gst_sdi_mux_get_property;
gobject_class->dispose = gst_sdi_mux_dispose;
gobject_class->finalize = gst_sdi_mux_finalize;
element_class->request_new_pad =
GST_DEBUG_FUNCPTR (gst_sdi_mux_request_new_pad);
element_class->release_pad = GST_DEBUG_FUNCPTR (gst_sdi_mux_release_pad);
element_class->change_state = GST_DEBUG_FUNCPTR (gst_sdi_mux_change_state);
element_class->get_query_types =
GST_DEBUG_FUNCPTR (gst_sdi_mux_get_query_types);
element_class->query = GST_DEBUG_FUNCPTR (gst_sdi_mux_query);
}
static void
gst_sdi_mux_init (GstSdiMux * sdimux, GstSdiMuxClass * sdimux_class)
{
sdimux->sinkpad =
gst_pad_new_from_static_template (&gst_sdi_mux_sink_template, "sink");
gst_pad_set_event_function (sdimux->sinkpad,
GST_DEBUG_FUNCPTR (gst_sdi_mux_sink_event));
gst_pad_set_chain_function (sdimux->sinkpad,
GST_DEBUG_FUNCPTR (gst_sdi_mux_chain));
gst_element_add_pad (GST_ELEMENT (sdimux), sdimux->sinkpad);
sdimux->srcpad = gst_pad_new_from_static_template (&gst_sdi_mux_src_template,
"src");
gst_pad_set_event_function (sdimux->srcpad,
GST_DEBUG_FUNCPTR (gst_sdi_mux_src_event));
gst_element_add_pad (GST_ELEMENT (sdimux), sdimux->srcpad);
}
void
gst_sdi_mux_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GstSdiMux *sdimux;
g_return_if_fail (GST_IS_SDI_MUX (object));
sdimux = GST_SDI_MUX (object);
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gst_sdi_mux_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GstSdiMux *sdimux;
g_return_if_fail (GST_IS_SDI_MUX (object));
sdimux = GST_SDI_MUX (object);
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gst_sdi_mux_dispose (GObject * object)
{
GstSdiMux *sdimux;
g_return_if_fail (GST_IS_SDI_MUX (object));
sdimux = GST_SDI_MUX (object);
/* clean up as possible. may be called multiple times */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
void
gst_sdi_mux_finalize (GObject * object)
{
GstSdiMux *sdimux;
g_return_if_fail (GST_IS_SDI_MUX (object));
sdimux = GST_SDI_MUX (object);
/* clean up object here */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GstPad *
gst_sdi_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name)
{
return NULL;
}
static void
gst_sdi_mux_release_pad (GstElement * element, GstPad * pad)
{
}
static GstStateChangeReturn
gst_sdi_mux_change_state (GstElement * element, GstStateChange transition)
{
return GST_STATE_CHANGE_SUCCESS;
}
static const GstQueryType *
gst_sdi_mux_get_query_types (GstElement * element)
{
return NULL;
}
static gboolean
gst_sdi_mux_query (GstElement * element, GstQuery * query)
{
return FALSE;
}
static GstFlowReturn
gst_sdi_mux_chain (GstPad * pad, GstBuffer * buffer)
{
GstSdiMux *sdimux;
sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (sdimux, "chain");
gst_object_unref (sdimux);
return GST_FLOW_OK;
}
static gboolean
gst_sdi_mux_sink_event (GstPad * pad, GstEvent * event)
{
gboolean res;
GstSdiMux *sdimux;
sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (sdimux, "event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
res = gst_pad_push_event (sdimux->srcpad, event);
break;
case GST_EVENT_FLUSH_STOP:
res = gst_pad_push_event (sdimux->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
res = gst_pad_push_event (sdimux->srcpad, event);
break;
case GST_EVENT_EOS:
res = gst_pad_push_event (sdimux->srcpad, event);
break;
default:
res = gst_pad_push_event (sdimux->srcpad, event);
break;
}
gst_object_unref (sdimux);
return TRUE;
}
static gboolean
gst_sdi_mux_src_event (GstPad * pad, GstEvent * event)
{
gboolean res;
GstSdiMux *sdimux;
sdimux = GST_SDI_MUX (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (sdimux, "event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
res = gst_pad_push_event (sdimux->sinkpad, event);
break;
default:
res = gst_pad_push_event (sdimux->sinkpad, event);
break;
}
gst_object_unref (sdimux);
return TRUE;
}
/* GStreamer
* Copyright (C) 2010 REAL_NAME <EMAIL_ADDRESS>
*
* 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.
*/
#ifndef _GST_SDI_MUX_H_
#define _GST_SDI_MUX_H_
#include <gst/gst.h>
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_SDI_MUX (gst_sdi_mux_get_type())
#define GST_SDI_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SDI_MUX,GstSdiMux))
#define GST_SDI_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SDI_MUX,GstSdiMuxClass))
#define GST_IS_SDI_MUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDI_MUX))
#define GST_IS_SDI_MUX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDI_MUX))
typedef struct _GstSdiMux GstSdiMux;
typedef struct _GstSdiMuxClass GstSdiMuxClass;
struct _GstSdiMux
{
GstElement base_sdimux;
GstPad *srcpad;
GstPad *sinkpad;
};
struct _GstSdiMuxClass
{
GstElementClass base_sdimux_class;
};
GType gst_sdi_mux_get_type (void);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment