summaryrefslogtreecommitdiff
path: root/gst/realmedia/rdtdepay.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/realmedia/rdtdepay.c')
-rw-r--r--gst/realmedia/rdtdepay.c91
1 files changed, 43 insertions, 48 deletions
diff --git a/gst/realmedia/rdtdepay.c b/gst/realmedia/rdtdepay.c
index c3b679fc..3c97dea2 100644
--- a/gst/realmedia/rdtdepay.c
+++ b/gst/realmedia/rdtdepay.c
@@ -64,38 +64,18 @@ GST_STATIC_PAD_TEMPLATE ("sink",
)
);
-GST_BOILERPLATE (GstRDTDepay, gst_rdt_depay, GstElement, GST_TYPE_ELEMENT);
+#define gst_rdt_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRDTDepay, gst_rdt_depay, GST_TYPE_ELEMENT);
static void gst_rdt_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rdt_depay_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rdt_depay_setcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_rdt_depay_sink_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_rdt_depay_chain (GstPad * pad, GstBuffer * buf);
static void
-gst_rdt_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rdt_depay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rdt_depay_sink_template));
-
- gst_element_class_set_details_simple (element_class, "RDT packet parser",
- "Codec/Depayloader/Network",
- "Extracts RealMedia from RDT packets",
- "Lutz Mueller <lutz at topfrose dot de>, "
- "Wim Taymans <wim@fluendo.com>");
-
- GST_DEBUG_CATEGORY_INIT (rdtdepay_debug, "rdtdepay",
- 0, "Depayloader for RDT RealMedia packets");
-}
-
-static void
gst_rdt_depay_class_init (GstRDTDepayClass * klass)
{
GObjectClass *gobject_class;
@@ -109,16 +89,29 @@ gst_rdt_depay_class_init (GstRDTDepayClass * klass)
gobject_class->finalize = gst_rdt_depay_finalize;
gstelement_class->change_state = gst_rdt_depay_change_state;
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rdt_depay_src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rdt_depay_sink_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "RDT packet parser",
+ "Codec/Depayloader/Network",
+ "Extracts RealMedia from RDT packets",
+ "Lutz Mueller <lutz at topfrose dot de>, "
+ "Wim Taymans <wim@fluendo.com>");
+
+ GST_DEBUG_CATEGORY_INIT (rdtdepay_debug, "rdtdepay",
+ 0, "Depayloader for RDT RealMedia packets");
}
static void
-gst_rdt_depay_init (GstRDTDepay * rdtdepay, GstRDTDepayClass * klass)
+gst_rdt_depay_init (GstRDTDepay * rdtdepay)
{
rdtdepay->sinkpad =
gst_pad_new_from_static_template (&gst_rdt_depay_sink_template, "sink");
gst_pad_set_chain_function (rdtdepay->sinkpad, gst_rdt_depay_chain);
gst_pad_set_event_function (rdtdepay->sinkpad, gst_rdt_depay_sink_event);
- gst_pad_set_setcaps_function (rdtdepay->sinkpad, gst_rdt_depay_setcaps);
gst_element_add_pad (GST_ELEMENT_CAST (rdtdepay), rdtdepay->sinkpad);
rdtdepay->srcpad =
@@ -226,6 +219,15 @@ gst_rdt_depay_sink_event (GstPad * pad, GstEvent * event)
depay = GST_RDT_DEPAY (GST_OBJECT_PARENT (pad));
switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ res = gst_rdt_depay_setcaps (pad, caps);
+ gst_event_unref (event);
+ break;
+ }
case GST_EVENT_FLUSH_STOP:
res = gst_pad_push_event (depay->srcpad, event);
@@ -233,19 +235,9 @@ gst_rdt_depay_sink_event (GstPad * pad, GstEvent * event)
depay->need_newsegment = TRUE;
depay->next_seqnum = -1;
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gboolean update;
- gdouble rate;
- GstFormat fmt;
- gint64 start, stop, position;
-
- gst_event_parse_new_segment (event, &update, &rate, &fmt, &start, &stop,
- &position);
-
- gst_segment_set_newsegment (&depay->segment, update, rate, fmt,
- start, stop, position);
-
+ gst_event_copy_segment (event, &depay->segment);
/* don't pass the event downstream, we generate our own segment
* including the NTP time and other things we receive in caps */
gst_event_unref (event);
@@ -263,19 +255,21 @@ static GstEvent *
create_segment_event (GstRDTDepay * depay, gboolean update,
GstClockTime position)
{
- GstEvent *event;
- GstClockTime stop;
+ GstSegment segment;
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.rate = depay->play_speed;
+ segment.applied_rate = depay->play_scale;
+ segment.start = position;
if (depay->npt_stop != -1)
- stop = depay->npt_stop - depay->npt_start;
+ segment.stop = depay->npt_stop - depay->npt_start;
else
- stop = -1;
+ segment.stop = -1;
- event = gst_event_new_new_segment_full (update, depay->play_speed,
- depay->play_scale, GST_FORMAT_TIME, position, stop,
- position + depay->npt_start);
+ segment.time = position + depay->npt_start;
- return event;
+ return gst_event_new_segment (&segment);
}
static GstFlowReturn
@@ -292,8 +286,6 @@ gst_rdt_depay_push (GstRDTDepay * rdtdepay, GstBuffer * buffer)
rdtdepay->need_newsegment = FALSE;
}
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (rdtdepay->srcpad));
-
if (rdtdepay->discont) {
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
rdtdepay->discont = FALSE;
@@ -319,10 +311,9 @@ gst_rdt_depay_handle_data (GstRDTDepay * rdtdepay, GstClockTime outtime,
guint16 outflags;
/* get pointers to the packet data */
- gst_rdt_packet_data_peek_data (packet, &data, &size);
+ data = gst_rdt_packet_data_map (packet, &size);
outbuf = gst_buffer_new_and_alloc (12 + size);
- outdata = GST_BUFFER_DATA (outbuf);
GST_BUFFER_TIMESTAMP (outbuf) = outtime;
GST_DEBUG_OBJECT (rdtdepay, "have size %u", size);
@@ -372,12 +363,16 @@ gst_rdt_depay_handle_data (GstRDTDepay * rdtdepay, GstClockTime outtime,
else
outflags = 0;
+ outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
GST_WRITE_UINT16_BE (outdata + 0, 0); /* version */
GST_WRITE_UINT16_BE (outdata + 2, size + 12); /* length */
GST_WRITE_UINT16_BE (outdata + 4, stream_id); /* stream */
GST_WRITE_UINT32_BE (outdata + 6, timestamp); /* timestamp */
GST_WRITE_UINT16_BE (outdata + 10, outflags); /* flags */
memcpy (outdata + 12, data, size);
+ gst_buffer_unmap (outbuf, outdata, 12 + size);
+
+ gst_rdt_packet_data_unmap (packet);
GST_DEBUG_OBJECT (rdtdepay, "Pushing packet, outtime %" GST_TIME_FORMAT,
GST_TIME_ARGS (outtime));