amc: Allow registering codecs, camera or sensors if any of the others failed

https://bugzilla.gnome.org/show_bug.cgi?id=774048
This commit is contained in:
Sebastian Dröge 2016-11-07 12:30:20 +02:00
parent 56ee6c4cee
commit e6651a733b

View file

@ -3331,18 +3331,15 @@ register_codecs (GstPlugin * plugin)
} }
static gboolean static gboolean
plugin_init (GstPlugin * plugin) amc_init (GstPlugin * plugin)
{ {
const gchar *ignore; const gchar *ignore;
GST_DEBUG_CATEGORY_INIT (gst_amc_debug, "amc", 0, "android-media-codec");
if (!gst_amc_jni_initialize ())
return FALSE;
gst_plugin_add_dependency_simple (plugin, NULL, "/etc", "media_codecs.xml", gst_plugin_add_dependency_simple (plugin, NULL, "/etc", "media_codecs.xml",
GST_PLUGIN_DEPENDENCY_FLAG_NONE); GST_PLUGIN_DEPENDENCY_FLAG_NONE);
gst_amc_codec_info_quark = g_quark_from_static_string ("gst-amc-codec-info");
if (!get_java_classes ()) if (!get_java_classes ())
return FALSE; return FALSE;
@ -3357,44 +3354,70 @@ plugin_init (GstPlugin * plugin)
if (!scan_codecs (plugin)) if (!scan_codecs (plugin))
return FALSE; return FALSE;
gst_amc_codec_info_quark = g_quark_from_static_string ("gst-amc-codec-info");
if (!register_codecs (plugin)) if (!register_codecs (plugin))
return FALSE; return FALSE;
return TRUE;
}
static gboolean
ahc_init (GstPlugin * plugin)
{
if (!gst_android_graphics_imageformat_init ()) { if (!gst_android_graphics_imageformat_init ()) {
GST_ERROR ("Failed to init android image format"); GST_ERROR ("Failed to init android image format");
goto failed_surfacetexture; return FALSE;
} }
if (!gst_android_hardware_camera_init ()) { if (!gst_android_hardware_camera_init ()) {
goto failed_graphics_imageformat; gst_android_graphics_imageformat_deinit ();
} return FALSE;
if (!gst_android_hardware_sensor_init ()) {
goto failed_hardware_camera;
} }
if (!gst_element_register (plugin, "ahcsrc", GST_RANK_NONE, GST_TYPE_AHC_SRC)) { if (!gst_element_register (plugin, "ahcsrc", GST_RANK_NONE, GST_TYPE_AHC_SRC)) {
GST_ERROR ("Failed to register android camera source"); GST_ERROR ("Failed to register android camera source");
goto failed_hardware_sensor; gst_android_hardware_camera_deinit ();
} gst_android_graphics_imageformat_deinit ();
return FALSE;
if (!gst_element_register (plugin, "ahssrc", GST_RANK_NONE, GST_TYPE_AHS_SRC)) {
GST_ERROR ("Failed to register android sensor source");
goto failed_hardware_sensor;
} }
return TRUE; return TRUE;
}
failed_hardware_sensor: static gboolean
gst_android_hardware_sensor_deinit (); ahs_init (GstPlugin * plugin)
failed_hardware_camera: {
gst_android_hardware_camera_deinit (); if (!gst_android_hardware_sensor_init ())
failed_graphics_imageformat: return FALSE;
gst_android_graphics_imageformat_deinit ();
failed_surfacetexture: if (!gst_element_register (plugin, "ahssrc", GST_RANK_NONE, GST_TYPE_AHS_SRC)) {
return FALSE; GST_ERROR ("Failed to register android sensor source");
gst_android_hardware_sensor_deinit ();
return FALSE;
}
return TRUE;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean init_ok = FALSE;
GST_DEBUG_CATEGORY_INIT (gst_amc_debug, "amc", 0, "android-media-codec");
if (!gst_amc_jni_initialize ())
return FALSE;
if (amc_init (plugin))
init_ok = TRUE;
if (ahc_init (plugin))
init_ok = TRUE;
if (ahs_init (plugin))
init_ok = TRUE;
return init_ok;
} }
void void