rtph264pay: add stream-format and alignment to h264 sink caps

We're happy to accept both byte-stream and avc, advertise
that on the sink caps and fix up _get_caps() function to
not just return "video/x-h264".

https://bugzilla.gnome.org/show_bug.cgi?id=606662
This commit is contained in:
Tim-Philipp Müller 2012-02-08 23:03:28 +00:00
parent 6872b40873
commit 5b25f3737b

View file

@ -45,10 +45,13 @@ GST_DEBUG_CATEGORY_STATIC (rtph264pay_debug);
*/
static GstStaticPadTemplate gst_rtp_h264_pay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-h264")
GST_STATIC_CAPS ("video/x-h264, "
"stream-format = (string) byte-stream, alignment = (string) { nal, au };"
"video/x-h264, "
"stream-format = (string) avc, alignment = (string) au")
);
static GstStaticPadTemplate gst_rtp_h264_pay_src_template =
@ -271,22 +274,29 @@ static const gchar *all_levels[] = {
static GstCaps *
gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
{
GstCaps *template_caps;
GstCaps *allowed_caps;
GstCaps *caps, *icaps;
guint i;
allowed_caps =
gst_pad_peer_get_caps_reffed (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
if (allowed_caps) {
GstCaps *caps = NULL;
guint i;
if (allowed_caps == NULL)
return NULL;
template_caps =
gst_static_pad_template_get_caps (&gst_rtp_h264_pay_sink_template);
if (gst_caps_is_any (allowed_caps)) {
gst_caps_unref (allowed_caps);
goto any;
caps = gst_caps_ref (template_caps);
goto done;
}
if (gst_caps_is_empty (allowed_caps))
return allowed_caps;
if (gst_caps_is_empty (allowed_caps)) {
caps = gst_caps_ref (allowed_caps);
goto done;
}
caps = gst_caps_new_empty ();
@ -357,12 +367,17 @@ gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
gst_caps_merge_structure (caps, new_s);
}
gst_caps_unref (allowed_caps);
return caps;
}
icaps = gst_caps_intersect (caps, template_caps);
gst_caps_unref (caps);
caps = icaps;
any:
return gst_caps_new_simple ("video/x-h264", NULL);
done:
gst_caps_unref (template_caps);
gst_caps_unref (allowed_caps);
GST_LOG_OBJECT (payload, "returning caps %" GST_PTR_FORMAT, caps);
return caps;
}
/* take the currently configured SPS and PPS lists and set them on the caps as