diff options
-rw-r--r-- | gst/videoparsers/gstvc1parse.c | 41 | ||||
-rw-r--r-- | gst/videoparsers/gstvc1parse.h | 2 |
2 files changed, 39 insertions, 4 deletions
diff --git a/gst/videoparsers/gstvc1parse.c b/gst/videoparsers/gstvc1parse.c index 406365975..02e2d0fad 100644 --- a/gst/videoparsers/gstvc1parse.c +++ b/gst/videoparsers/gstvc1parse.c @@ -115,6 +115,16 @@ static const struct "frame-layer", VC1_STREAM_FORMAT_FRAME_LAYER} }; +static const struct +{ + gchar str[5]; + GstVC1ParseFormat en; +} parse_formats[] = { + { + "WMV3", GST_VC1_PARSE_FORMAT_WMV3}, { + "WVC1", GST_VC1_PARSE_FORMAT_WVC1} +}; + static const gchar * stream_format_to_string (VC1StreamFormat stream_format) { @@ -151,6 +161,12 @@ header_format_from_string (const gchar * header_format) return -1; } +static const gchar * +parse_format_to_string (GstVC1ParseFormat format) +{ + return parse_formats[format].str; +} + static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, @@ -300,7 +316,9 @@ gst_vc1_parse_stop (GstBaseParse * parse) static gboolean gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) { + GstCaps *in_caps; GstCaps *allowed_caps; + GstCaps *tmp; /* Negotiate with downstream here */ GST_DEBUG_OBJECT (vc1parse, "Renegotiating"); @@ -314,9 +332,25 @@ gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) GST_DEBUG_OBJECT (vc1parse, "Downstream allowed caps: %" GST_PTR_FORMAT, allowed_caps); - allowed_caps = gst_caps_make_writable (allowed_caps); - allowed_caps = gst_caps_truncate (allowed_caps); - s = gst_caps_get_structure (allowed_caps, 0); + /* Downstream element can have differents caps according to wmv format + * so intersect to select the good caps */ + in_caps = gst_caps_new_simple ("video/x-wmv", + "format", G_TYPE_STRING, parse_format_to_string (vc1parse->format), + NULL); + + tmp = gst_caps_intersect_full (allowed_caps, in_caps, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (in_caps); + + if (gst_caps_is_empty (tmp)) { + GST_ERROR_OBJECT (vc1parse, "Empty caps, downstream doesn't support %s", + parse_format_to_string (vc1parse->format)); + gst_caps_unref (tmp); + return FALSE; + } + + tmp = gst_caps_make_writable (tmp); + s = gst_caps_get_structure (tmp, 0); /* If already fixed this does nothing */ gst_structure_fixate_field_string (s, "header-format", "asf"); @@ -343,6 +377,7 @@ gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) vc1parse->output_stream_format = stream_format_from_string (stream_format); } + gst_caps_unref (tmp); } else if (gst_caps_is_empty (allowed_caps)) { GST_ERROR_OBJECT (vc1parse, "Empty caps"); gst_caps_unref (allowed_caps); diff --git a/gst/videoparsers/gstvc1parse.h b/gst/videoparsers/gstvc1parse.h index 6d97ec843..28c3c4f01 100644 --- a/gst/videoparsers/gstvc1parse.h +++ b/gst/videoparsers/gstvc1parse.h @@ -56,7 +56,7 @@ typedef enum { } VC1StreamFormat; typedef enum { - GST_VC1_PARSE_FORMAT_WMV3, + GST_VC1_PARSE_FORMAT_WMV3 = 0, GST_VC1_PARSE_FORMAT_WVC1 } GstVC1ParseFormat; |