androidmedia: Only allow GL output if the decoder has unknown color formats
authorMatthieu Bouron <matthieu.bouron@collabora.com>
Mon, 20 Apr 2015 11:46:58 +0000 (13:46 +0200)
committerMatthew Waters <matthew@centricular.com>
Tue, 20 Oct 2015 17:27:43 +0000 (04:27 +1100)
If GST_AMC_IGNORE_UNKNOWN_COLOR_FORMATS is set to yes, non-GL output
is still allowed.

https://bugzilla.gnome.org/show_bug.cgi?id=731204

sys/androidmedia/gstamc.c
sys/androidmedia/gstamc.h
sys/androidmedia/gstamcvideodec.c

index da1063a..f333820 100644 (file)
@@ -1567,6 +1567,7 @@ scan_codecs (GstPlugin * plugin)
       goto next_codec;
     }
     gst_codec_info->is_encoder = is_encoder;
+    gst_codec_info->gl_output_only = FALSE;
 
     supported_types =
         (*env)->CallObjectMethod (env, codec_info, get_supported_types_id);
@@ -1710,12 +1711,13 @@ scan_codecs (GstPlugin * plugin)
           goto next_supported_type;
         }
 
-        if (!ignore_unknown_color_formats
-            && !accepted_color_formats (gst_codec_type, is_encoder)) {
-          GST_ERROR ("%s %s has unknown color formats, ignoring",
-              gst_codec_type->mime, is_encoder ? "encoder" : "decoder");
-          valid_codec = FALSE;
-          goto next_supported_type;
+        if (!accepted_color_formats (gst_codec_type, is_encoder)) {
+          if (!ignore_unknown_color_formats) {
+            gst_codec_info->gl_output_only = TRUE;
+            GST_WARNING
+                ("%s %s has unknown color formats, only direct rendering will be supported",
+                gst_codec_type->mime, is_encoder ? "encoder" : "decoder");
+          }
         }
       }
 
index 7b0cd9b..a640616 100644 (file)
@@ -53,6 +53,7 @@ struct _GstAmcCodecType {
 struct _GstAmcCodecInfo {
   gchar *name;
   gboolean is_encoder;
+  gboolean gl_output_only;
   GstAmcCodecType *supported_types;
   gint n_supported_types;
 };
index 70371dd..58a4386 100644 (file)
@@ -230,7 +230,11 @@ gst_amc_video_dec_base_init (gpointer g_class)
       gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
       (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, "RGBA"));
 
-  gst_caps_append (all_src_caps, src_caps);
+  if (codec_info->gl_output_only) {
+    gst_caps_unref (src_caps);
+  } else {
+    gst_caps_append (all_src_caps, src_caps);
+  }
 
   /* Add pad templates */
   templ =
@@ -1224,6 +1228,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
     GstVideoCodecState * state)
 {
   GstAmcVideoDec *self;
+  GstAmcVideoDecClass *klass;
   GstAmcFormat *format;
   const gchar *mime;
   gboolean is_format_change = FALSE;
@@ -1235,6 +1240,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
   jobject jsurface = NULL;
 
   self = GST_AMC_VIDEO_DEC (decoder);
+  klass = GST_AMC_VIDEO_DEC_GET_CLASS (self);
 
   GST_DEBUG_OBJECT (self, "Setting new caps %" GST_PTR_FORMAT, state->caps);
 
@@ -1414,6 +1420,12 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
   GST_INFO_OBJECT (self, "GL output: %s",
       self->downstream_supports_gl ? "enabled" : "disabled");
 
+  if (klass->codec_info->gl_output_only && !self->downstream_supports_gl) {
+    GST_ERROR_OBJECT (self,
+        "Codec only supports GL output but downstream does not");
+    return FALSE;
+  }
+
   if (self->downstream_supports_gl && self->surface) {
     jsurface = self->surface->jobject;
   } else if (self->downstream_supports_gl && !self->surface) {