x264enc: Properly set the stream format in setcaps

Do not forget to set the selected format to the options string
when getting it from caps

https://bugzilla.gnome.org/show_bug.cgi?id=655223
This commit is contained in:
Thiago Santos 2011-07-30 18:47:44 -03:00
parent 3f8a245796
commit 19f1c38d4e

View file

@ -1553,20 +1553,21 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
peer_caps = gst_pad_peer_get_caps_reffed (encoder->srcpad); peer_caps = gst_pad_peer_get_caps_reffed (encoder->srcpad);
if (peer_caps) { if (peer_caps) {
gint i; gint i;
gboolean has_profile_or_level = FALSE; gboolean has_profile_or_level_or_format = FALSE;
for (i = 0; i < gst_caps_get_size (peer_caps); i++) { for (i = 0; i < gst_caps_get_size (peer_caps); i++) {
GstStructure *s = gst_caps_get_structure (peer_caps, i); GstStructure *s = gst_caps_get_structure (peer_caps, i);
if (gst_structure_has_name (s, "video/x-h264") && if (gst_structure_has_name (s, "video/x-h264") &&
(gst_structure_has_field (s, "profile") || (gst_structure_has_field (s, "profile") ||
gst_structure_has_field (s, "level"))) { gst_structure_has_field (s, "level") ||
has_profile_or_level = TRUE; gst_structure_has_field (s, "stream-format"))) {
has_profile_or_level_or_format = TRUE;
break; break;
} }
} }
if (has_profile_or_level) { if (has_profile_or_level_or_format) {
template_caps = gst_pad_get_pad_template_caps (encoder->srcpad); template_caps = gst_pad_get_pad_template_caps (encoder->srcpad);
allowed_caps = gst_caps_intersect (peer_caps, template_caps); allowed_caps = gst_caps_intersect (peer_caps, template_caps);
@ -1654,8 +1655,10 @@ gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
if (stream_format) { if (stream_format) {
if (!strcmp (stream_format, "avc")) { if (!strcmp (stream_format, "avc")) {
encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC; encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC;
g_string_append_printf (encoder->option_string, ":annexb=0");
} else if (!strcmp (stream_format, "byte-stream")) { } else if (!strcmp (stream_format, "byte-stream")) {
encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM; encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM;
g_string_append_printf (encoder->option_string, ":annexb=1");
} else { } else {
/* means we have both in caps and _FROM_PROPERTY should be the option */ /* means we have both in caps and _FROM_PROPERTY should be the option */
} }