Commit 109cd71c authored by Wim Taymans's avatar Wim Taymans

gst-libs/gst/rtp/: closed #320644.

Original commit message from CVS:
* gst-libs/gst/rtp/gstbasertpdepayload.h:
* gst-libs/gst/rtp/gstbasertppayload.c: (gst_basertppayload_init),
(gst_basertppayload_event), (gst_basertppayload_push),
(gst_basertppayload_change_state):
* gst-libs/gst/rtp/gstbasertppayload.h:
closed #320644.
parent ef53753a
2005-11-30 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/rtp/gstbasertpdepayload.h:
* gst-libs/gst/rtp/gstbasertppayload.c: (gst_basertppayload_init),
(gst_basertppayload_event), (gst_basertppayload_push),
(gst_basertppayload_change_state):
* gst-libs/gst/rtp/gstbasertppayload.h:
closed #320644.
2005-11-30 Julien MOUTTE <julien@moutte.net>
* docs/libs/gst-plugins-base-libs-docs.sgml:
......
......@@ -78,11 +78,11 @@ struct _GstBaseRTPDepayload
*/
GQueue *queue;
GstSegment segment;
gboolean need_newsegment;
/*< private >*/
union {
gboolean need_newsegment;
gpointer _gst_reserved[GST_PADDING-1+1];
};
gpointer _gst_reserved[GST_PADDING];
};
struct _GstBaseRTPDepayloadClass
......
......@@ -59,6 +59,7 @@ static void gst_basertppayload_init (GstBaseRTPPayload * basertppayload,
static void gst_basertppayload_finalize (GObject * object);
static gboolean gst_basertppayload_setcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_basertppayload_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_basertppayload_chain (GstPad * pad,
GstBuffer * buffer);
......@@ -178,6 +179,8 @@ gst_basertppayload_init (GstBaseRTPPayload * basertppayload, gpointer g_class)
basertppayload->sinkpad = gst_pad_new_from_template (templ, "sink");
gst_pad_set_setcaps_function (basertppayload->sinkpad,
gst_basertppayload_setcaps);
gst_pad_set_event_function (basertppayload->sinkpad,
gst_basertppayload_event);
gst_pad_set_chain_function (basertppayload->sinkpad,
gst_basertppayload_chain);
gst_element_add_pad (GST_ELEMENT (basertppayload), basertppayload->sinkpad);
......@@ -231,6 +234,46 @@ gst_basertppayload_setcaps (GstPad * pad, GstCaps * caps)
return ret;
}
static gboolean
gst_basertppayload_event (GstPad * pad, GstEvent * event)
{
GstBaseRTPPayload *basertppayload;
gboolean res;
basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
res = gst_pad_event_default (pad, event);
break;
case GST_EVENT_FLUSH_STOP:
res = gst_pad_event_default (pad, event);
gst_segment_init (&basertppayload->segment, GST_FORMAT_UNDEFINED);
break;
case GST_EVENT_NEWSEGMENT:
{
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 (&basertppayload->segment, update, rate, fmt,
start, stop, position);
}
/* fallthrough */
default:
res = gst_pad_event_default (pad, event);
break;
}
gst_object_unref (basertppayload);
return res;
}
static GstFlowReturn
gst_basertppayload_chain (GstPad * pad, GstBuffer * buffer)
{
......@@ -333,15 +376,23 @@ gst_basertppayload_push (GstBaseRTPPayload * payload, GstBuffer * buffer)
gst_rtpbuffer_set_payload_type (buffer, payload->pt);
/* can warp around, which is perfectly fine */
/* can wrap around, which is perfectly fine */
gst_rtpbuffer_set_seq (buffer, payload->seqnum++);
/* add our random offset to the timestamp */
ts = payload->ts_base;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (GST_CLOCK_TIME_IS_VALID (timestamp))
ts += timestamp * payload->clock_rate / GST_SECOND;
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
gint64 rtime;
rtime =
gst_segment_to_running_time (&payload->segment, GST_FORMAT_TIME,
timestamp);
rtime = gst_util_uint64_scale_int (rtime, payload->clock_rate, GST_SECOND);
ts += rtime;
}
gst_rtpbuffer_set_timestamp (buffer, ts);
payload->timestamp = ts;
......@@ -349,6 +400,9 @@ gst_basertppayload_push (GstBaseRTPPayload * payload, GstBuffer * buffer)
/* set caps */
gst_buffer_set_caps (buffer, GST_PAD_CAPS (payload->srcpad));
GST_DEBUG_OBJECT (payload, "Pushing packet size %d, seq=%d, ts=%u",
GST_BUFFER_SIZE (buffer), payload->seqnum - 1, ts);
res = gst_pad_push (payload->srcpad, buffer);
return res;
......@@ -448,6 +502,7 @@ gst_basertppayload_change_state (GstElement * element,
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_segment_init (&basertppayload->segment, GST_FORMAT_UNDEFINED);
if (basertppayload->seqnum_offset == -1)
basertppayload->seqnum_base =
......
......@@ -50,6 +50,7 @@ struct _GstBaseRTPPayload
{
GstElement element;
/*< private >*/
GstPad *sinkpad;
GstPad *srcpad;
......@@ -74,6 +75,11 @@ struct _GstBaseRTPPayload
guint ssrc;
guint current_ssrc;
guint mtu;
GstSegment segment;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
struct _GstBaseRTPPayloadClass
......@@ -86,6 +92,9 @@ struct _GstBaseRTPPayloadClass
* the RTP buffers */
GstFlowReturn (*handle_buffer) (GstBaseRTPPayload *payload,
GstBuffer *buffer);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_basertppayload_get_type (void);
......
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