diff options
author | Thiago Santos <thiagoss@embedded.ufcg.edu.br> | 2009-07-31 00:19:19 -0300 |
---|---|---|
committer | Thiago Santos <thiagoss@embedded.ufcg.edu.br> | 2009-07-31 00:19:19 -0300 |
commit | 88e399aac25eb982511ab0d30505ed89bcfde011 (patch) | |
tree | 9a1cb905f37122246cd74994eaedfd3c7d6658a6 | |
parent | 7583bf6813501a071700522c8bb227afdb4471af (diff) | |
download | gstreamer-plugins-bad-88e399aac25eb982511ab0d30505ed89bcfde011.tar.gz |
rtpasfpay: set padding field to 0 on rtp asf packets
The ASF RTP spec demands that packets have their padding removed
and the padding size field set to 0 for packets when puting them
inside the RTP packets
-rw-r--r-- | gst/asfmux/gstasfobjects.c | 10 | ||||
-rw-r--r-- | gst/asfmux/gstasfobjects.h | 6 | ||||
-rw-r--r-- | gst/asfmux/gstrtpasfpay.c | 25 |
3 files changed, 40 insertions, 1 deletions
diff --git a/gst/asfmux/gstasfobjects.c b/gst/asfmux/gstasfobjects.c index 27c71f5ea..c0b63ae0d 100644 --- a/gst/asfmux/gstasfobjects.c +++ b/gst/asfmux/gstasfobjects.c @@ -521,6 +521,7 @@ gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet, GstByteReader *reader; gboolean ret = TRUE; guint8 first; + guint8 err_length = 0; /* length of the error fields */ guint8 aux; guint8 packet_len_type; guint8 padding_len_type; @@ -543,6 +544,7 @@ gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet, if (first & 0x80) { /* error correction present */ guint8 err_cor_len; + err_length += 1; GST_DEBUG ("Packet contains error correction"); if (first & 0x60) { GST_ERROR ("Error correction data length should be " @@ -550,9 +552,12 @@ gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet, return FALSE; } err_cor_len = (first & 0x0F); + err_length += err_cor_len; GST_DEBUG ("Error correction data length: %d", (gint) err_cor_len); if (!gst_byte_reader_skip (reader, err_cor_len)) goto error; + + /* put payload parsing info first byte in aux var */ if (!gst_byte_reader_get_uint8 (reader, &aux)) goto error; } else { @@ -631,6 +636,11 @@ gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet, packet->send_time = send_time; packet->duration = duration; packet->has_keyframe = has_keyframe; + packet->multiple_payloads = mult_payloads ? TRUE : FALSE; + packet->padd_field_type = padding_len_type; + packet->packet_field_type = packet_len_type; + packet->seq_field_type = seq_len_type; + packet->err_cor_len = err_length; gst_byte_reader_free (reader); return ret; diff --git a/gst/asfmux/gstasfobjects.h b/gst/asfmux/gstasfobjects.h index f91e1e11b..302c42c6c 100644 --- a/gst/asfmux/gstasfobjects.h +++ b/gst/asfmux/gstasfobjects.h @@ -46,6 +46,12 @@ typedef struct _GstAsfFileInfo typedef struct _GstAsfPacketInfo { + guint8 err_cor_len; + gboolean multiple_payloads; + guint8 padd_field_type; + guint8 packet_field_type; + guint8 seq_field_type; + guint32 packet_size; guint32 padding; guint32 send_time; diff --git a/gst/asfmux/gstrtpasfpay.c b/gst/asfmux/gstrtpasfpay.c index 7c57984f8..ffcfd85ab 100644 --- a/gst/asfmux/gstrtpasfpay.c +++ b/gst/asfmux/gstrtpasfpay.c @@ -154,7 +154,30 @@ gst_rtp_asf_pay_handle_packet (GstRtpAsfPay * rtpasfpay, GstBuffer * buffer) ", padding: %" G_GUINT32_FORMAT, packetinfo->packet_size, packetinfo->padding); - /* FIXME - should update the padding field to 0 */ + /* update padding field to 0 */ + if (packetinfo->padding > 0) { + GstAsfPacketInfo info; + /* find padding field offset */ + guint offset = packetinfo->err_cor_len + 2 + + gst_asf_get_var_size_field_len (packetinfo->packet_field_type) + + gst_asf_get_var_size_field_len (packetinfo->seq_field_type); + buffer = gst_buffer_make_writable (buffer); + switch (packetinfo->padd_field_type) { + case ASF_FIELD_TYPE_DWORD: + GST_WRITE_UINT32_LE (&(GST_BUFFER_DATA (buffer)[offset]), 0); + break; + case ASF_FIELD_TYPE_WORD: + GST_WRITE_UINT16_LE (&(GST_BUFFER_DATA (buffer)[offset]), 0); + break; + case ASF_FIELD_TYPE_BYTE: + GST_BUFFER_DATA (buffer)[offset] = 0; + break; + case ASF_FIELD_TYPE_NONE: + default: + break; + } + gst_asf_parse_packet (buffer, &info, FALSE); + } packet_util_size = packetinfo->packet_size - packetinfo->padding; packet_offset = 0; |