mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
dvb: port to 0.11
This commit is contained in:
parent
5de9be0fdd
commit
c6ec4439f2
3 changed files with 59 additions and 82 deletions
|
@ -303,7 +303,7 @@ GST_PLUGINS_NONPORTED=" adpcmdec adpcmenc aiff asfmux \
|
|||
patchdetect pcapparse pnm rawparse real removesilence rtpmux rtpvp8 scaletempo \
|
||||
sdi segmentclip siren speed subenc stereo tta videofilters \
|
||||
videomaxrate videomeasure videoparsers videosignal vmnc y4m \
|
||||
decklink dvb fbdev linsys shm vcd \
|
||||
decklink fbdev linsys shm vcd \
|
||||
voaacenc apexsink bz2 camerabin2 cdaudio celt cog curl dc1394 dirac directfb dts resindvd \
|
||||
faac gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \
|
||||
musepack musicbrainz nas neon ofa rsvg schro sdl sndfile soundtouch timidity \
|
||||
|
|
|
@ -99,21 +99,21 @@ static void dvb_base_bin_get_property (GObject * object, guint prop_id,
|
|||
static void dvb_base_bin_dispose (GObject * object);
|
||||
static void dvb_base_bin_finalize (GObject * object);
|
||||
|
||||
static gboolean dvb_base_bin_ts_pad_probe_cb (GstPad * pad,
|
||||
GstBuffer * buf, gpointer user_data);
|
||||
static GstProbeReturn dvb_base_bin_ts_pad_probe_cb (GstPad * pad,
|
||||
GstProbeType type, gpointer data, gpointer user_data);
|
||||
static GstStateChangeReturn dvb_base_bin_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
static void dvb_base_bin_handle_message (GstBin * bin, GstMessage * message);
|
||||
static void dvb_base_bin_pat_info_cb (DvbBaseBin * dvbbasebin,
|
||||
GstStructure * pat);
|
||||
const GstStructure * pat);
|
||||
static void dvb_base_bin_pmt_info_cb (DvbBaseBin * dvbbasebin,
|
||||
GstStructure * pmt);
|
||||
const GstStructure * pmt);
|
||||
static void dvb_base_bin_pad_added_cb (GstElement * mpegtsparse,
|
||||
GstPad * pad, DvbBaseBin * dvbbasebin);
|
||||
static void dvb_base_bin_pad_removed_cb (GstElement * mpegtsparse,
|
||||
GstPad * pad, DvbBaseBin * dvbbasebin);
|
||||
static GstPad *dvb_base_bin_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * name);
|
||||
GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
|
||||
static void dvb_base_bin_release_pad (GstElement * element, GstPad * pad);
|
||||
static void dvb_base_bin_rebuild_filter (DvbBaseBin * dvbbasebin);
|
||||
|
||||
|
@ -122,18 +122,6 @@ static void dvb_base_bin_uri_handler_init (gpointer g_iface,
|
|||
|
||||
static void dvb_base_bin_program_destroy (gpointer data);
|
||||
|
||||
static void
|
||||
dvb_base_bin_setup_interfaces (GType type)
|
||||
{
|
||||
static const GInterfaceInfo urihandler_info = {
|
||||
dvb_base_bin_uri_handler_init,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
|
||||
}
|
||||
|
||||
static DvbBaseBinStream *
|
||||
dvb_base_bin_add_stream (DvbBaseBin * dvbbasebin, guint16 pid)
|
||||
{
|
||||
|
@ -187,27 +175,10 @@ dvb_base_bin_get_program (DvbBaseBin * dvbbasebin, gint program_number)
|
|||
static guint signals [LAST_SIGNAL] = { 0 };
|
||||
*/
|
||||
|
||||
GST_BOILERPLATE_FULL (DvbBaseBin, dvb_base_bin, GstBin, GST_TYPE_BIN,
|
||||
dvb_base_bin_setup_interfaces);
|
||||
|
||||
static void
|
||||
dvb_base_bin_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
element_class->request_new_pad = dvb_base_bin_request_new_pad;
|
||||
element_class->release_pad = dvb_base_bin_release_pad;
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&program_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "DVB bin",
|
||||
"Source/Bin/Video",
|
||||
"Access descramble and split DVB streams",
|
||||
"Alessandro Decina <alessandro@nnva.org>");
|
||||
}
|
||||
#define dvb_base_bin_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (DvbBaseBin, dvb_base_bin, GST_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
|
||||
dvb_base_bin_uri_handler_init));
|
||||
|
||||
static void
|
||||
dvb_base_bin_class_init (DvbBaseBinClass * klass)
|
||||
|
@ -247,6 +218,18 @@ dvb_base_bin_class_init (DvbBaseBinClass * klass)
|
|||
|
||||
element_class = GST_ELEMENT_CLASS (klass);
|
||||
element_class->change_state = dvb_base_bin_change_state;
|
||||
element_class->request_new_pad = dvb_base_bin_request_new_pad;
|
||||
element_class->release_pad = dvb_base_bin_release_pad;
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&program_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "DVB bin",
|
||||
"Source/Bin/Video",
|
||||
"Access descramble and split DVB streams",
|
||||
"Alessandro Decina <alessandro@nnva.org>");
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (klass);
|
||||
gobject_class->set_property = dvb_base_bin_set_property;
|
||||
|
@ -311,6 +294,7 @@ dvb_base_bin_class_init (DvbBaseBinClass * klass)
|
|||
g_param_spec_string ("program-numbers",
|
||||
"Program Numbers",
|
||||
"Colon separated list of programs", "", G_PARAM_READWRITE));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -332,7 +316,7 @@ dvb_base_bin_reset (DvbBaseBin * dvbbasebin)
|
|||
static gint16 initial_pids[] = { 0, 1, 0x10, 0x11, 0x12, 0x14, -1 };
|
||||
|
||||
static void
|
||||
dvb_base_bin_init (DvbBaseBin * dvbbasebin, DvbBaseBinClass * klass)
|
||||
dvb_base_bin_init (DvbBaseBin * dvbbasebin)
|
||||
{
|
||||
DvbBaseBinStream *stream;
|
||||
int i;
|
||||
|
@ -473,7 +457,7 @@ dvb_base_bin_get_property (GObject * object, guint prop_id,
|
|||
|
||||
static GstPad *
|
||||
dvb_base_bin_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * name)
|
||||
GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
|
||||
{
|
||||
GstPad *pad;
|
||||
GstPad *ghost;
|
||||
|
@ -543,8 +527,9 @@ dvb_base_bin_reset_pmtlist (DvbBaseBin * dvbbasebin)
|
|||
dvbbasebin->pmtlist_changed = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dvb_base_bin_ts_pad_probe_cb (GstPad * pad, GstBuffer * buf, gpointer user_data)
|
||||
static GstProbeReturn
|
||||
dvb_base_bin_ts_pad_probe_cb (GstPad * pad, GstProbeType type,
|
||||
gpointer data, gpointer user_data)
|
||||
{
|
||||
DvbBaseBin *dvbbasebin = GST_DVB_BASE_BIN (user_data);
|
||||
|
||||
|
@ -561,7 +546,7 @@ dvb_base_bin_ts_pad_probe_cb (GstPad * pad, GstBuffer * buf, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return GST_PROBE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -579,8 +564,8 @@ dvb_base_bin_init_cam (DvbBaseBin * dvbbasebin)
|
|||
/* HACK: poll the cam in a buffer probe */
|
||||
dvbbasebin->ts_pad =
|
||||
gst_element_get_request_pad (dvbbasebin->mpegtsparse, "src%d");
|
||||
gst_pad_add_buffer_probe (dvbbasebin->ts_pad,
|
||||
G_CALLBACK (dvb_base_bin_ts_pad_probe_cb), dvbbasebin);
|
||||
gst_pad_add_probe (dvbbasebin->ts_pad, GST_PROBE_TYPE_BLOCK,
|
||||
dvb_base_bin_ts_pad_probe_cb, dvbbasebin, NULL);
|
||||
} else {
|
||||
GST_ERROR_OBJECT (dvbbasebin, "could not open %s", ca_file);
|
||||
cam_device_free (dvbbasebin->hwcam);
|
||||
|
@ -797,12 +782,13 @@ dvb_base_bin_handle_message (GstBin * bin, GstMessage * message)
|
|||
|
||||
if (message->type == GST_MESSAGE_ELEMENT &&
|
||||
GST_ELEMENT (message->src) == GST_ELEMENT (dvbbasebin->mpegtsparse)) {
|
||||
const gchar *structure_name = gst_structure_get_name (message->structure);
|
||||
const GstStructure *s = gst_message_get_structure (message);
|
||||
const gchar *structure_name = gst_structure_get_name (s);
|
||||
|
||||
if (strcmp (structure_name, "pat") == 0)
|
||||
dvb_base_bin_pat_info_cb (dvbbasebin, message->structure);
|
||||
dvb_base_bin_pat_info_cb (dvbbasebin, s);
|
||||
else if (strcmp (structure_name, "pmt") == 0)
|
||||
dvb_base_bin_pmt_info_cb (dvbbasebin, message->structure);
|
||||
dvb_base_bin_pmt_info_cb (dvbbasebin, s);
|
||||
|
||||
/*else if (strcmp (structure_name, "nit") == 0)
|
||||
dvb_base_bin_nit_info_cb (dvbbasebin, message->structure);
|
||||
|
@ -822,7 +808,8 @@ dvb_base_bin_handle_message (GstBin * bin, GstMessage * message)
|
|||
|
||||
|
||||
static void
|
||||
dvb_base_bin_pat_info_cb (DvbBaseBin * dvbbasebin, GstStructure * pat_info)
|
||||
dvb_base_bin_pat_info_cb (DvbBaseBin * dvbbasebin,
|
||||
const GstStructure * pat_info)
|
||||
{
|
||||
DvbBaseBinProgram *program;
|
||||
DvbBaseBinStream *stream;
|
||||
|
@ -870,7 +857,7 @@ dvb_base_bin_pat_info_cb (DvbBaseBin * dvbbasebin, GstStructure * pat_info)
|
|||
}
|
||||
|
||||
static void
|
||||
dvb_base_bin_pmt_info_cb (DvbBaseBin * dvbbasebin, GstStructure * pmt)
|
||||
dvb_base_bin_pmt_info_cb (DvbBaseBin * dvbbasebin, const GstStructure * pmt)
|
||||
{
|
||||
DvbBaseBinProgram *program;
|
||||
guint program_number;
|
||||
|
@ -965,13 +952,13 @@ dvb_base_bin_pad_removed_cb (GstElement * mpegtsparse,
|
|||
}
|
||||
|
||||
static guint
|
||||
dvb_base_bin_uri_get_type (void)
|
||||
dvb_base_bin_uri_get_type (GType type)
|
||||
{
|
||||
return GST_URI_SRC;
|
||||
}
|
||||
|
||||
static gchar **
|
||||
dvb_base_bin_uri_get_protocols (void)
|
||||
dvb_base_bin_uri_get_protocols (GType type)
|
||||
{
|
||||
static gchar *protocols[] = { (char *) "dvb", NULL };
|
||||
|
||||
|
|
|
@ -305,24 +305,8 @@ static GstStaticPadTemplate ts_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
******************************
|
||||
*/
|
||||
|
||||
GST_BOILERPLATE (GstDvbSrc, gst_dvbsrc, GstPushSrc, GST_TYPE_PUSH_SRC);
|
||||
|
||||
static void
|
||||
gst_dvbsrc_base_init (gpointer gclass)
|
||||
{
|
||||
GstDvbSrcClass *klass = (GstDvbSrcClass *) gclass;
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&ts_src_factory));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "DVB Source",
|
||||
"Source/Video",
|
||||
"Digital Video Broadcast Source",
|
||||
"P2P-VCR, C-Lab, University of Paderborn,"
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
}
|
||||
|
||||
#define gst_dvbsrc_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstDvbSrc, gst_dvbsrc, GST_TYPE_PUSH_SRC);
|
||||
|
||||
/* initialize the plugin's class */
|
||||
static void
|
||||
|
@ -343,6 +327,16 @@ gst_dvbsrc_class_init (GstDvbSrcClass * klass)
|
|||
gobject_class->finalize = gst_dvbsrc_finalize;
|
||||
|
||||
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_dvbsrc_change_state);
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&ts_src_factory));
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class, "DVB Source",
|
||||
"Source/Video",
|
||||
"Digital Video Broadcast Source",
|
||||
"P2P-VCR, C-Lab, University of Paderborn,"
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_dvbsrc_start);
|
||||
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_dvbsrc_stop);
|
||||
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_dvbsrc_unlock);
|
||||
|
@ -459,7 +453,7 @@ gst_dvbsrc_class_init (GstDvbSrcClass * klass)
|
|||
* initialize structure
|
||||
*/
|
||||
static void
|
||||
gst_dvbsrc_init (GstDvbSrc * object, GstDvbSrcClass * klass)
|
||||
gst_dvbsrc_init (GstDvbSrc * object)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -907,12 +901,14 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
|
|||
gint ret_val = 0;
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (size);
|
||||
GstClockTime timeout = object->timeout * GST_USECOND;
|
||||
guint8 *data;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
|
||||
|
||||
if (object->fd_dvr < 0)
|
||||
return NULL;
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
while (count < size) {
|
||||
ret_val = gst_poll_wait (object->poll, timeout);
|
||||
GST_LOG_OBJECT (object, "select returned %d", ret_val);
|
||||
|
@ -927,8 +923,7 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
|
|||
gst_message_new_element (GST_OBJECT (object),
|
||||
gst_structure_empty_new ("dvb-read-failure")));
|
||||
} else {
|
||||
int nread =
|
||||
read (object->fd_dvr, GST_BUFFER_DATA (buf) + count, size - count);
|
||||
int nread = read (object->fd_dvr, data + count, size - count);
|
||||
|
||||
if (G_UNLIKELY (nread < 0)) {
|
||||
GST_WARNING_OBJECT
|
||||
|
@ -942,19 +937,20 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
|
|||
count = count + nread;
|
||||
}
|
||||
}
|
||||
|
||||
GST_BUFFER_SIZE (buf) = count;
|
||||
gst_buffer_unmap (buf, data, count);
|
||||
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
||||
return buf;
|
||||
|
||||
stopped:
|
||||
GST_DEBUG_OBJECT (object, "stop called");
|
||||
gst_buffer_unmap (buf, data, 0);
|
||||
gst_buffer_unref (buf);
|
||||
return NULL;
|
||||
|
||||
select_error:
|
||||
GST_ELEMENT_ERROR (object, RESOURCE, READ, (NULL),
|
||||
("select error %d: %s (%d)", ret_val, g_strerror (errno), errno));
|
||||
gst_buffer_unmap (buf, data, 0);
|
||||
gst_buffer_unref (buf);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -981,13 +977,7 @@ gst_dvbsrc_create (GstPushSrc * element, GstBuffer ** buf)
|
|||
GST_DEBUG_OBJECT (object, "Reading from DVR device");
|
||||
*buf = gst_dvbsrc_read_device (object, buffer_size);
|
||||
if (*buf != NULL) {
|
||||
GstCaps *caps;
|
||||
|
||||
retval = GST_FLOW_OK;
|
||||
|
||||
caps = gst_pad_get_caps (GST_BASE_SRC_PAD (object));
|
||||
gst_buffer_set_caps (*buf, caps);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
if (object->stats_interval != 0 &&
|
||||
|
|
Loading…
Reference in a new issue