summaryrefslogtreecommitdiffstats
path: root/gst/rtp
diff options
context:
space:
mode:
authorWai-Ming Ho <waiming at ailuropoda dot net>2009-02-23 15:43:51 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2009-02-23 15:43:51 +0100
commitaeee52be051d7d73cd565e7eaf9b49b84a00c8a2 (patch)
tree291236dda0e1fa1d1df1886f96d867c1daf2c674 /gst/rtp
parentb9adb5846bb4d663928e441cf90e1efb75f36630 (diff)
Always add PPS to the sprop-parameters-set
Rework the parsing code that under certain circumstances dropped the PPS from the sprop-parameters-set. Fixes #572854.
Diffstat (limited to 'gst/rtp')
-rw-r--r--gst/rtp/gstrtph264pay.c118
1 files changed, 50 insertions, 68 deletions
diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c
index f0cd9ee8..8fdd895a 100644
--- a/gst/rtp/gstrtph264pay.c
+++ b/gst/rtp/gstrtph264pay.c
@@ -467,89 +467,71 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
{
guint8 *sps = NULL, *pps = NULL;
guint sps_len = 0, pps_len = 0;
+ guint8 header, type;
+ guint len;
/* default is no update */
*updated = FALSE;
- if (size <= 3) {
- GST_WARNING ("Encoded buffer len %u <= 3", size);
- } else {
- GST_DEBUG ("NAL payload len=%u", size);
+ GST_DEBUG ("NAL payload len=%u", size);
- /* loop through all NAL units and save the locations of any
- * SPS / PPS for later processing. Only the last seen SPS
- * or PPS will be considered */
- while (size > 5) {
- guint8 header, type;
- guint len;
+ len = size;
+ header = data[0];
+ type = header & 0x1f;
- len = next_start_code (data, size);
- header = data[0];
- type = header & 0x1f;
-
- /* keep sps & pps separately so that we can update either one
- * independently */
- if (SPS_TYPE_ID == type) {
- /* encode the entire SPS NAL in base64 */
- GST_DEBUG ("Found SPS %x %x %x Len=%u", (header >> 7),
- (header >> 5) & 3, type, len);
-
- sps = data;
- sps_len = len;
- } else if (PPS_TYPE_ID == type) {
- /* encoder the entire PPS NAL in base64 */
- GST_DEBUG ("Found PPS %x %x %x Len = %u",
- (header >> 7), (header >> 5) & 3, type, len);
-
- pps = data;
- pps_len = len;
- } else {
- GST_DEBUG ("NAL: %x %x %x Len = %u", (header >> 7),
- (header >> 5) & 3, type, len);
- }
+ /* keep sps & pps separately so that we can update either one
+ * independently */
+ if (SPS_TYPE_ID == type) {
+ /* encode the entire SPS NAL in base64 */
+ GST_DEBUG ("Found SPS %x %x %x Len=%u", (header >> 7),
+ (header >> 5) & 3, type, len);
- /* end of loop */
- if (len >= size - 4) {
- break;
- }
+ sps = data;
+ sps_len = len;
+ } else if (PPS_TYPE_ID == type) {
+ /* encoder the entire PPS NAL in base64 */
+ GST_DEBUG ("Found PPS %x %x %x Len = %u",
+ (header >> 7), (header >> 5) & 3, type, len);
- /* next NAL start */
- data += len + 4;
- size -= len + 4;
- }
+ pps = data;
+ pps_len = len;
+ } else {
+ GST_DEBUG ("NAL: %x %x %x Len = %u", (header >> 7),
+ (header >> 5) & 3, type, len);
+ }
- /* If we encountered an SPS and/or a PPS, check if it's the
- * same as the one we have. If not, update our version and
- * set *updated to TRUE
- */
- if (sps_len > 0) {
- if ((payloader->sps_len != sps_len)
- || !is_nal_equal (payloader->sps, sps, sps_len)) {
- payloader->profile = (sps[1] << 16) + (sps[2] << 8) + sps[3];
- GST_DEBUG ("Profile level IDC = %06x", payloader->profile);
+ /* If we encountered an SPS and/or a PPS, check if it's the
+ * same as the one we have. If not, update our version and
+ * set *updated to TRUE
+ */
+ if (sps_len > 0) {
+ if ((payloader->sps_len != sps_len)
+ || !is_nal_equal (payloader->sps, sps, sps_len)) {
+ payloader->profile = (sps[1] << 16) + (sps[2] << 8) + sps[3];
- if (payloader->sps_len)
- g_free (payloader->sps);
+ GST_DEBUG ("Profile level IDC = %06x", payloader->profile);
- payloader->sps = sps_len ? g_new (guint8, sps_len) : NULL;
- memcpy (payloader->sps, sps, sps_len);
- payloader->sps_len = sps_len;
- *updated = TRUE;
- }
+ if (payloader->sps_len)
+ g_free (payloader->sps);
+
+ payloader->sps = sps_len ? g_new (guint8, sps_len) : NULL;
+ memcpy (payloader->sps, sps, sps_len);
+ payloader->sps_len = sps_len;
+ *updated = TRUE;
}
+ }
- if (pps_len > 0) {
- if ((payloader->pps_len != pps_len)
- || !is_nal_equal (payloader->pps, pps, pps_len)) {
- if (payloader->pps_len)
- g_free (payloader->pps);
+ if (pps_len > 0) {
+ if ((payloader->pps_len != pps_len)
+ || !is_nal_equal (payloader->pps, pps, pps_len)) {
+ if (payloader->pps_len)
+ g_free (payloader->pps);
- payloader->pps = pps_len ? g_new (guint8, pps_len) : NULL;
- memcpy (payloader->pps, pps, pps_len);
- payloader->pps_len = pps_len;
- *updated = TRUE;
- }
+ payloader->pps = pps_len ? g_new (guint8, pps_len) : NULL;
+ memcpy (payloader->pps, pps, pps_len);
+ payloader->pps_len = pps_len;
+ *updated = TRUE;
}
}
}