gst/rtp/: Use is_filled to both check MTU and max-ptime of base class.

Original commit message from CVS:
* gst/rtp/TODO:
* gst/rtp/gstrtpdec.c: (gst_rtpdec_getcaps):
* gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_class_init),
(gst_rtpmp4venc_parse_data), (gst_rtpmp4venc_handle_buffer),
(gst_rtpmp4venc_set_property):
* gst/rtp/gstrtpmp4venc.h:
* gst/rtp/gstrtpmpaenc.c: (gst_rtpmpaenc_handle_buffer):
* gst/rtp/gstrtpmpaenc.h:
Use is_filled to both check MTU and max-ptime of base class.
This commit is contained in:
Wim Taymans 2005-09-22 14:13:36 +00:00
parent 4aac63130a
commit 7067b806e0
12 changed files with 73 additions and 37 deletions

View file

@ -1,3 +1,15 @@
2005-09-22 Wim Taymans <wim@fluendo.com>
* gst/rtp/TODO:
* gst/rtp/gstrtpdec.c: (gst_rtpdec_getcaps):
* gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_class_init),
(gst_rtpmp4venc_parse_data), (gst_rtpmp4venc_handle_buffer),
(gst_rtpmp4venc_set_property):
* gst/rtp/gstrtpmp4venc.h:
* gst/rtp/gstrtpmpaenc.c: (gst_rtpmpaenc_handle_buffer):
* gst/rtp/gstrtpmpaenc.h:
Use is_filled to both check MTU and max-ptime of base class.
2005-09-22 Wim Taymans <wim@fluendo.com> 2005-09-22 Wim Taymans <wim@fluendo.com>
* gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_class_init), * gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_class_init),

View file

@ -1,26 +1,14 @@
*GstRtpRecv:
*gstrtprecv.c
*For Sequencing:
* timestamp
* algorithm
*For Video:
* payload_t
* sequence number should not start at 0, but randomly
* MPEG4 header * MPEG4 header
- ffmpeg mpeg4 decoder gives error message when sending only the config - ffmpeg mpeg4 decoder gives error message when sending only the config
string, parsing is OK, error just means no picture was found in the string, parsing is OK, error just means no picture was found in the
stream. stream.
* compare H263 encoders and H263+ * compare H263 encoders and H263+
* better RTP packetizing for h263 * better RTP packetizing for h263
* bitrate tuning in ffmpeg * bitrate tuning in ffmpeg
- fixed the qmax values so we can quantize more.
* make ffmpeg negotiate only with accepted framerates * make ffmpeg negotiate only with accepted framerates

View file

@ -183,12 +183,18 @@ gst_rtpdec_getcaps (GstPad * pad)
{ {
GstRTPDec *src; GstRTPDec *src;
GstPad *other; GstPad *other;
GstCaps *caps;
src = GST_RTPDEC (GST_PAD_PARENT (pad)); src = GST_RTPDEC (GST_PAD_PARENT (pad));
other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp; other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp;
return gst_pad_peer_get_caps (other); caps = gst_pad_peer_get_caps (other);
if (caps == NULL)
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
return caps;
} }
static GstFlowReturn static GstFlowReturn

View file

@ -183,12 +183,18 @@ gst_rtpdec_getcaps (GstPad * pad)
{ {
GstRTPDec *src; GstRTPDec *src;
GstPad *other; GstPad *other;
GstCaps *caps;
src = GST_RTPDEC (GST_PAD_PARENT (pad)); src = GST_RTPDEC (GST_PAD_PARENT (pad));
other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp; other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp;
return gst_pad_peer_get_caps (other); caps = gst_pad_peer_get_caps (other);
if (caps == NULL)
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
return caps;
} }
static GstFlowReturn static GstFlowReturn

View file

@ -346,6 +346,7 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
guint8 *data; guint8 *data;
gboolean flush; gboolean flush;
gint strip; gint strip;
GstClockTime duration;
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
@ -353,11 +354,13 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
size = GST_BUFFER_SIZE (buffer); size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer); data = GST_BUFFER_DATA (buffer);
duration = GST_BUFFER_DURATION (buffer);
avail = gst_adapter_available (rtpmp4venc->adapter); avail = gst_adapter_available (rtpmp4venc->adapter);
/* empty buffer, take timestamp */ /* empty buffer, take timestamp */
if (avail == 0) { if (avail == 0) {
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
} }
/* parse incomming data and see if we need to start a new RTP /* parse incomming data and see if we need to start a new RTP
@ -382,23 +385,24 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
/* if we need to flush, do so now */ /* if we need to flush, do so now */
if (flush) { if (flush) {
ret = gst_rtpmp4venc_flush (rtpmp4venc); ret = gst_rtpmp4venc_flush (rtpmp4venc);
avail = 0;
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
avail = 0;
} }
avail = gst_adapter_available (rtpmp4venc->adapter);
/* get packet length of data and see if we exceeded MTU. */ /* get packet length of data and see if we exceeded MTU. */
packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0); packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0);
if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) { if (gst_basertppayload_is_filled (basepayload,
packet_len, rtpmp4venc->duration + duration)) {
ret = gst_rtpmp4venc_flush (rtpmp4venc); ret = gst_rtpmp4venc_flush (rtpmp4venc);
avail = 0;
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
} }
/* push new data */ /* push new data */
gst_adapter_push (rtpmp4venc->adapter, buffer); gst_adapter_push (rtpmp4venc->adapter, buffer);
rtpmp4venc->duration += duration;
return ret; return ret;
} }

View file

@ -46,6 +46,7 @@ struct _GstRtpMP4VEnc
GstAdapter *adapter; GstAdapter *adapter;
GstClockTime first_ts; GstClockTime first_ts;
GstClockTime duration;
gint rate; gint rate;
gint profile; gint profile;

View file

@ -346,6 +346,7 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
guint8 *data; guint8 *data;
gboolean flush; gboolean flush;
gint strip; gint strip;
GstClockTime duration;
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
@ -353,11 +354,13 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
size = GST_BUFFER_SIZE (buffer); size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer); data = GST_BUFFER_DATA (buffer);
duration = GST_BUFFER_DURATION (buffer);
avail = gst_adapter_available (rtpmp4venc->adapter); avail = gst_adapter_available (rtpmp4venc->adapter);
/* empty buffer, take timestamp */ /* empty buffer, take timestamp */
if (avail == 0) { if (avail == 0) {
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
} }
/* parse incomming data and see if we need to start a new RTP /* parse incomming data and see if we need to start a new RTP
@ -382,23 +385,24 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
/* if we need to flush, do so now */ /* if we need to flush, do so now */
if (flush) { if (flush) {
ret = gst_rtpmp4venc_flush (rtpmp4venc); ret = gst_rtpmp4venc_flush (rtpmp4venc);
avail = 0;
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
avail = 0;
} }
avail = gst_adapter_available (rtpmp4venc->adapter);
/* get packet length of data and see if we exceeded MTU. */ /* get packet length of data and see if we exceeded MTU. */
packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0); packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0);
if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) { if (gst_basertppayload_is_filled (basepayload,
packet_len, rtpmp4venc->duration + duration)) {
ret = gst_rtpmp4venc_flush (rtpmp4venc); ret = gst_rtpmp4venc_flush (rtpmp4venc);
avail = 0;
rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer); rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmp4venc->duration = 0;
} }
/* push new data */ /* push new data */
gst_adapter_push (rtpmp4venc->adapter, buffer); gst_adapter_push (rtpmp4venc->adapter, buffer);
rtpmp4venc->duration += duration;
return ret; return ret;
} }

View file

@ -46,6 +46,7 @@ struct _GstRtpMP4VEnc
GstAdapter *adapter; GstAdapter *adapter;
GstClockTime first_ts; GstClockTime first_ts;
GstClockTime duration;
gint rate; gint rate;
gint profile; gint profile;

View file

@ -225,11 +225,18 @@ gst_rtpmpaenc_handle_buffer (GstBaseRTPPayload * basepayload,
GstFlowReturn ret; GstFlowReturn ret;
guint size, avail; guint size, avail;
guint packet_len; guint packet_len;
GstClockTime duration;
rtpmpaenc = GST_RTP_MPA_ENC (basepayload); rtpmpaenc = GST_RTP_MPA_ENC (basepayload);
size = GST_BUFFER_SIZE (buffer); size = GST_BUFFER_SIZE (buffer);
duration = GST_BUFFER_DURATION (buffer);
avail = gst_adapter_available (rtpmpaenc->adapter); avail = gst_adapter_available (rtpmpaenc->adapter);
if (avail == 0) {
rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmpaenc->duration = 0;
}
/* get packet length of previous data and this new data, /* get packet length of previous data and this new data,
* payload length includes a 4 byte header */ * payload length includes a 4 byte header */
@ -237,18 +244,17 @@ gst_rtpmpaenc_handle_buffer (GstBaseRTPPayload * basepayload,
/* if this buffer is going to overflow the packet, flush what we /* if this buffer is going to overflow the packet, flush what we
* have. */ * have. */
if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmpaenc)) { if (gst_basertppayload_is_filled (basepayload,
packet_len, rtpmpaenc->duration + duration)) {
ret = gst_rtpmpaenc_flush (rtpmpaenc); ret = gst_rtpmpaenc_flush (rtpmpaenc);
avail = 0; rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmpaenc->duration = 0;
} else { } else {
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
} }
gst_adapter_push (rtpmpaenc->adapter, buffer); gst_adapter_push (rtpmpaenc->adapter, buffer);
rtpmpaenc->duration += duration;
if (avail == 0) {
rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
}
return ret; return ret;
} }

View file

@ -46,6 +46,7 @@ struct _GstRtpMPAEnc
GstAdapter *adapter; GstAdapter *adapter;
GstClockTime first_ts; GstClockTime first_ts;
GstClockTime duration;
}; };
struct _GstRtpMPAEncClass struct _GstRtpMPAEncClass

View file

@ -225,11 +225,18 @@ gst_rtpmpaenc_handle_buffer (GstBaseRTPPayload * basepayload,
GstFlowReturn ret; GstFlowReturn ret;
guint size, avail; guint size, avail;
guint packet_len; guint packet_len;
GstClockTime duration;
rtpmpaenc = GST_RTP_MPA_ENC (basepayload); rtpmpaenc = GST_RTP_MPA_ENC (basepayload);
size = GST_BUFFER_SIZE (buffer); size = GST_BUFFER_SIZE (buffer);
duration = GST_BUFFER_DURATION (buffer);
avail = gst_adapter_available (rtpmpaenc->adapter); avail = gst_adapter_available (rtpmpaenc->adapter);
if (avail == 0) {
rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmpaenc->duration = 0;
}
/* get packet length of previous data and this new data, /* get packet length of previous data and this new data,
* payload length includes a 4 byte header */ * payload length includes a 4 byte header */
@ -237,18 +244,17 @@ gst_rtpmpaenc_handle_buffer (GstBaseRTPPayload * basepayload,
/* if this buffer is going to overflow the packet, flush what we /* if this buffer is going to overflow the packet, flush what we
* have. */ * have. */
if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmpaenc)) { if (gst_basertppayload_is_filled (basepayload,
packet_len, rtpmpaenc->duration + duration)) {
ret = gst_rtpmpaenc_flush (rtpmpaenc); ret = gst_rtpmpaenc_flush (rtpmpaenc);
avail = 0; rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtpmpaenc->duration = 0;
} else { } else {
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
} }
gst_adapter_push (rtpmpaenc->adapter, buffer); gst_adapter_push (rtpmpaenc->adapter, buffer);
rtpmpaenc->duration += duration;
if (avail == 0) {
rtpmpaenc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
}
return ret; return ret;
} }

View file

@ -46,6 +46,7 @@ struct _GstRtpMPAEnc
GstAdapter *adapter; GstAdapter *adapter;
GstClockTime first_ts; GstClockTime first_ts;
GstClockTime duration;
}; };
struct _GstRtpMPAEncClass struct _GstRtpMPAEncClass