static gboolean gst_vaapidecode_ensure_allowed_sinkpad_caps (GstVaapiDecode * decode) { GstCaps *caps, *allowed_sinkpad_caps; GArray *profiles; guint i; profiles = gst_vaapi_display_get_decode_profiles (GST_VAAPI_PLUGIN_BASE_DISPLAY (decode)); if (!profiles) goto error_no_profiles; allowed_sinkpad_caps = gst_caps_new_empty (); if (!allowed_sinkpad_caps) goto error_no_memory; for (i = 0; i < profiles->len; i++) { const GstVaapiProfile profile = g_array_index (profiles, GstVaapiProfile, i); const gchar *media_type_name; const gchar *profile_name; GstStructure *structure; media_type_name = gst_vaapi_profile_get_media_type_name (profile); if (!media_type_name) continue; caps = gst_caps_from_string (media_type_name); if (!caps) continue; structure = gst_caps_get_structure (caps, 0); profile_name = gst_vaapi_profile_get_name (profile); if (profile_name) gst_structure_set (structure, "profile", G_TYPE_STRING, profile_name, NULL); allowed_sinkpad_caps = gst_caps_merge (allowed_sinkpad_caps, caps); } decode->allowed_sinkpad_caps = gst_caps_simplify (allowed_sinkpad_caps); g_array_unref (profiles); return TRUE; /* ERRORS */ error_no_profiles: { GST_ERROR ("failed to retrieve VA decode profiles"); return FALSE; } error_no_memory: { GST_ERROR ("failed to allocate allowed-caps set"); g_array_unref (profiles); return FALSE; } }
static gboolean gst_vaapidecode_ensure_allowed_sinkpad_caps (GstVaapiDecode * decode) { GstCaps *caps, *allowed_sinkpad_caps; GArray *profiles; guint i; gboolean base_only = FALSE; gboolean have_high = FALSE; gboolean have_mvc = FALSE; gboolean have_svc = FALSE; profiles = gst_vaapi_display_get_decode_profiles (GST_VAAPI_PLUGIN_BASE_DISPLAY (decode)); if (!profiles) goto error_no_profiles; allowed_sinkpad_caps = gst_caps_new_empty (); if (!allowed_sinkpad_caps) goto error_no_memory; if (g_object_class_find_property (G_OBJECT_GET_CLASS (decode), "base-only")) { g_object_get (decode, "base-only", &base_only, NULL); } for (i = 0; i < profiles->len; i++) { const GstVaapiProfile profile = g_array_index (profiles, GstVaapiProfile, i); const gchar *media_type_name; const gchar *profile_name; GstStructure *structure; media_type_name = gst_vaapi_profile_get_media_type_name (profile); if (!media_type_name) continue; caps = gst_caps_from_string (media_type_name); if (!caps) continue; structure = gst_caps_get_structure (caps, 0); profile_name = gst_vaapi_profile_get_name (profile); if (profile_name) gst_structure_set (structure, "profile", G_TYPE_STRING, profile_name, NULL); allowed_sinkpad_caps = gst_caps_merge (allowed_sinkpad_caps, caps); have_mvc |= is_mvc_profile (profile); have_svc |= is_svc_profile (profile); have_high |= profile == GST_VAAPI_PROFILE_H264_HIGH; } if (have_high) { allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "progressive-high"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "constrained-high"); } if (base_only && (!have_mvc || !have_svc) && have_high) { if (!have_mvc) { GST_DEBUG ("base_only: force adding MVC profiles in caps"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "multiview-high"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "stereo-high"); } if (!have_svc) { GST_DEBUG ("base_only: force adding SVC profiles in caps"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "scalable-constrained-baseline"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "scalable-baseline"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "scalable-high-intra"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "scalable-constrained-high"); allowed_sinkpad_caps = add_h264_profile_in_caps (allowed_sinkpad_caps, "scalable-high"); } } decode->allowed_sinkpad_caps = gst_caps_simplify (allowed_sinkpad_caps); g_array_unref (profiles); return TRUE; /* ERRORS */ error_no_profiles: { GST_ERROR ("failed to retrieve VA decode profiles"); return FALSE; } error_no_memory: { GST_ERROR ("failed to allocate allowed-caps set"); g_array_unref (profiles); return FALSE; } }