basertppay: allow subclasses to influence RTP time

Allow subclasses to use the OFFSET field on RTP buffers to influence the way in
which RTP timestamps are generated. Usually timestamps are created from the
GStreamer timestamps on the buffer, which could result in imperfect RTP
timestamps.
This commit is contained in:
Wim Taymans 2009-09-02 19:47:26 +02:00
parent 5a479669d4
commit 3a4edea56d

View file

@ -621,6 +621,7 @@ typedef struct
guint8 pt;
GstCaps *caps;
GstClockTime timestamp;
guint64 offset;
guint32 rtptime;
} HeaderData;
@ -628,9 +629,10 @@ static GstBufferListItem
find_timestamp (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
{
data->timestamp = GST_BUFFER_TIMESTAMP (*buffer);
data->offset = GST_BUFFER_OFFSET (*buffer);
/* stop when we find a timestamp */
if (data->timestamp != -1)
/* stop when we find a timestamp and duration */
if (data->timestamp != -1 && data->offset != -1)
return GST_BUFFER_LIST_END;
else
return GST_BUFFER_LIST_CONTINUE;
@ -644,6 +646,7 @@ set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
gst_rtp_buffer_set_seq (*buffer, data->seqnum);
gst_rtp_buffer_set_timestamp (*buffer, data->rtptime);
gst_buffer_set_caps (*buffer, data->caps);
/* increment the seqnum for each buffer */
data->seqnum++;
return GST_BUFFER_LIST_SKIP_GROUP;
@ -681,12 +684,17 @@ gst_basertppayload_prepare_push (GstBaseRTPPayload * payload,
(GstBufferListFunc) find_timestamp, &data);
} else {
data.timestamp = GST_BUFFER_TIMESTAMP (GST_BUFFER_CAST (obj));
data.offset = GST_BUFFER_OFFSET (GST_BUFFER_CAST (obj));
}
/* convert to RTP time */
if (GST_CLOCK_TIME_IS_VALID (data.timestamp)) {
if (data.offset != GST_BUFFER_OFFSET_NONE) {
/* if we have an offset, use that for making an RTP timestamp */
data.rtptime = payload->ts_base + data.offset;
} else if (GST_CLOCK_TIME_IS_VALID (data.timestamp)) {
gint64 rtime;
/* no offset, use the gstreamer timestamp */
rtime = gst_segment_to_running_time (&payload->segment, GST_FORMAT_TIME,
data.timestamp);