rtph264pay: Restructuring to allow for adding optional caps

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=700749
This commit is contained in:
Sebastian Rasmussen 2013-05-20 22:14:44 +02:00 committed by Sebastian Dröge
parent e26b8c2832
commit 61666898cf

View file

@ -344,16 +344,14 @@ done:
/* take the currently configured SPS and PPS lists and set them on the caps as /* take the currently configured SPS and PPS lists and set them on the caps as
* sprop-parameter-sets */ * sprop-parameter-sets */
static gboolean static gchar *
gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload) gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
{ {
GstRtpH264Pay *payloader = GST_RTP_H264_PAY (basepayload); GstRtpH264Pay *payloader = GST_RTP_H264_PAY (basepayload);
gchar *profile;
gchar *set; gchar *set;
GList *walk; GList *walk;
GString *sprops; GString *sprops;
guint count; guint count;
gboolean res;
GstMapInfo map; GstMapInfo map;
sprops = g_string_new (""); sprops = g_string_new ("");
@ -383,19 +381,12 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
count++; count++;
} }
if (G_LIKELY (count)) { if (G_UNLIKELY (count == 0)) {
/* profile is 24 bit. Force it to respect the limit */
profile = g_strdup_printf ("%06x", payloader->profile & 0xffffff);
/* combine into output caps */
res = gst_rtp_base_payload_set_outcaps (basepayload,
"sprop-parameter-sets", G_TYPE_STRING, sprops->str, NULL);
g_free (profile);
} else {
res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
}
g_string_free (sprops, TRUE); g_string_free (sprops, TRUE);
return NULL;
}
return res; return g_string_free (sprops, FALSE);
} }
static GList * static GList *
@ -433,6 +424,8 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
gsize size; gsize size;
GstBuffer *buffer; GstBuffer *buffer;
const gchar *alignment, *stream_format; const gchar *alignment, *stream_format;
gchar *sprops;
gboolean caps_set;
rtph264pay = GST_RTP_H264_PAY (basepayload); rtph264pay = GST_RTP_H264_PAY (basepayload);
@ -558,10 +551,25 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
} }
gst_buffer_unmap (buffer, &map); gst_buffer_unmap (buffer, &map);
/* and update the caps with the collected data */ /* and update the caps with the collected data */
if (!gst_rtp_h264_pay_set_sps_pps (basepayload)) sprops = gst_rtp_h264_pay_set_sps_pps (basepayload);
goto set_sps_pps_failed;
} else { } else {
GST_DEBUG_OBJECT (rtph264pay, "have bytestream h264"); GST_DEBUG_OBJECT (rtph264pay, "have bytestream h264");
sprops = NULL;
}
if (sprops != NULL) {
caps_set = gst_rtp_base_payload_set_outcaps (basepayload,
"sprop-parameter-sets", G_TYPE_STRING, sprops, NULL);
} else {
caps_set = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
}
if (sprops != NULL) {
g_free (sprops);
}
if (!caps_set) {
goto set_caps_failed;
} }
return TRUE; return TRUE;
@ -581,10 +589,10 @@ avcc_error:
GST_ERROR_OBJECT (rtph264pay, "avcC too small "); GST_ERROR_OBJECT (rtph264pay, "avcC too small ");
goto error; goto error;
} }
set_sps_pps_failed: set_caps_failed:
{ {
GST_ERROR_OBJECT (rtph264pay, "failed to set sps/pps"); GST_ERROR_OBJECT (rtph264pay, "failed to set caps");
goto error; return FALSE;
} }
error: error:
{ {