androidmedia: ignore additional camera effects if not present

Fixes https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/283

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1470>
This commit is contained in:
Andrew Branson 2020-07-27 15:45:49 +02:00 committed by GStreamer Merge Bot
parent 2881f6d728
commit 8a51fdbc2c
2 changed files with 131 additions and 98 deletions

View file

@ -963,58 +963,64 @@ _init_classes (void)
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_EMBOSS", gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_EMBOSS",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.EFFECT_EMBOSS))
&android_hardware_camera_parameters.EFFECT_EMBOSS)) goto failed;
goto failed;
Parameters_EFFECT_EMBOSS = Parameters_EFFECT_EMBOSS =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.EFFECT_EMBOSS, NULL); android_hardware_camera_parameters.EFFECT_EMBOSS, NULL);
{ {
jobject local = android_hardware_camera_parameters.EFFECT_EMBOSS; jobject local = android_hardware_camera_parameters.EFFECT_EMBOSS;
android_hardware_camera_parameters.EFFECT_EMBOSS = android_hardware_camera_parameters.EFFECT_EMBOSS =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.EFFECT_EMBOSS = NULL;
} }
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_SKETCH", gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_SKETCH",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.EFFECT_SKETCH))
&android_hardware_camera_parameters.EFFECT_SKETCH)) goto failed;
goto failed;
Parameters_EFFECT_SKETCH = Parameters_EFFECT_SKETCH =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.EFFECT_SKETCH, NULL); android_hardware_camera_parameters.EFFECT_SKETCH, NULL);
{ {
jobject local = android_hardware_camera_parameters.EFFECT_SKETCH; jobject local = android_hardware_camera_parameters.EFFECT_SKETCH;
android_hardware_camera_parameters.EFFECT_SKETCH = android_hardware_camera_parameters.EFFECT_SKETCH =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.EFFECT_SKETCH = NULL;
} }
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_NEON", gst_amc_jni_get_static_field_id (env, &err, klass, "EFFECT_NEON",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.EFFECT_NEON))
&android_hardware_camera_parameters.EFFECT_NEON)) goto failed;
goto failed;
Parameters_EFFECT_NEON = Parameters_EFFECT_NEON =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.EFFECT_NEON, NULL); android_hardware_camera_parameters.EFFECT_NEON, NULL);
{ {
jobject local = android_hardware_camera_parameters.EFFECT_NEON; jobject local = android_hardware_camera_parameters.EFFECT_NEON;
android_hardware_camera_parameters.EFFECT_NEON = android_hardware_camera_parameters.EFFECT_NEON =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.EFFECT_NEON = NULL;
} }
fieldID = fieldID =
@ -1497,77 +1503,85 @@ _init_classes (void)
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_BACKLIGHT", gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_BACKLIGHT",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT))
&android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT)) goto failed;
goto failed;
Parameters_SCENE_MODE_BACKLIGHT = Parameters_SCENE_MODE_BACKLIGHT =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT, NULL); android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT, NULL);
{ {
jobject local = android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT; jobject local = android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT;
android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT = android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT = NULL;
} }
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_FLOWERS", gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_FLOWERS",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.SCENE_MODE_FLOWERS))
&android_hardware_camera_parameters.SCENE_MODE_FLOWERS)) goto failed;
goto failed;
Parameters_SCENE_MODE_FLOWERS = Parameters_SCENE_MODE_FLOWERS =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.SCENE_MODE_FLOWERS, NULL); android_hardware_camera_parameters.SCENE_MODE_FLOWERS, NULL);
{ {
jobject local = android_hardware_camera_parameters.SCENE_MODE_FLOWERS; jobject local = android_hardware_camera_parameters.SCENE_MODE_FLOWERS;
android_hardware_camera_parameters.SCENE_MODE_FLOWERS = android_hardware_camera_parameters.SCENE_MODE_FLOWERS =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.SCENE_MODE_FLOWERS = NULL;
} }
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_AR", gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_AR",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.SCENE_MODE_AR))
&android_hardware_camera_parameters.SCENE_MODE_AR)) goto failed;
goto failed;
Parameters_SCENE_MODE_AR = Parameters_SCENE_MODE_AR =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.SCENE_MODE_AR, NULL); android_hardware_camera_parameters.SCENE_MODE_AR, NULL);
{ {
jobject local = android_hardware_camera_parameters.SCENE_MODE_AR; jobject local = android_hardware_camera_parameters.SCENE_MODE_AR;
android_hardware_camera_parameters.SCENE_MODE_AR = android_hardware_camera_parameters.SCENE_MODE_AR =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.SCENE_MODE_AR = NULL;
} }
fieldID = fieldID =
gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_HDR", gst_amc_jni_get_static_field_id (env, &err, klass, "SCENE_MODE_HDR",
"Ljava/lang/String;"); "Ljava/lang/String;");
if (!fieldID) if (fieldID) {
goto failed; if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID,
if (!gst_amc_jni_get_static_object_field (env, &err, klass, fieldID, &android_hardware_camera_parameters.SCENE_MODE_HDR))
&android_hardware_camera_parameters.SCENE_MODE_HDR)) goto failed;
goto failed;
Parameters_SCENE_MODE_HDR = Parameters_SCENE_MODE_HDR =
(*env)->GetStringUTFChars (env, (*env)->GetStringUTFChars (env,
android_hardware_camera_parameters.SCENE_MODE_HDR, NULL); android_hardware_camera_parameters.SCENE_MODE_HDR, NULL);
{ {
jobject local = android_hardware_camera_parameters.SCENE_MODE_HDR; jobject local = android_hardware_camera_parameters.SCENE_MODE_HDR;
android_hardware_camera_parameters.SCENE_MODE_HDR = android_hardware_camera_parameters.SCENE_MODE_HDR =
gst_amc_jni_object_make_global (env, local); gst_amc_jni_object_make_global (env, local);
}
} else {
android_hardware_camera_parameters.SCENE_MODE_HDR = NULL;
} }
fieldID = fieldID =
@ -2965,13 +2979,16 @@ _color_effect_to_gchar (JNIEnv * env, jstring color_effect)
else if (java_lang_string_equals (env, color_effect, else if (java_lang_string_equals (env, color_effect,
android_hardware_camera_parameters.EFFECT_AQUA)) android_hardware_camera_parameters.EFFECT_AQUA))
return Parameters_EFFECT_AQUA; return Parameters_EFFECT_AQUA;
else if (java_lang_string_equals (env, color_effect, else if (android_hardware_camera_parameters.EFFECT_EMBOSS != NULL &&
java_lang_string_equals (env, color_effect,
android_hardware_camera_parameters.EFFECT_EMBOSS)) android_hardware_camera_parameters.EFFECT_EMBOSS))
return Parameters_EFFECT_EMBOSS; return Parameters_EFFECT_EMBOSS;
else if (java_lang_string_equals (env, color_effect, else if (android_hardware_camera_parameters.EFFECT_SKETCH != NULL &&
java_lang_string_equals (env, color_effect,
android_hardware_camera_parameters.EFFECT_SKETCH)) android_hardware_camera_parameters.EFFECT_SKETCH))
return Parameters_EFFECT_SKETCH; return Parameters_EFFECT_SKETCH;
else if (java_lang_string_equals (env, color_effect, else if (android_hardware_camera_parameters.EFFECT_NEON != NULL &&
java_lang_string_equals (env, color_effect,
android_hardware_camera_parameters.EFFECT_NEON)) android_hardware_camera_parameters.EFFECT_NEON))
return Parameters_EFFECT_NEON; return Parameters_EFFECT_NEON;
@ -3002,11 +3019,14 @@ _color_effect_to_jstring (const gchar * color_effect)
return android_hardware_camera_parameters.EFFECT_BLACKBOARD; return android_hardware_camera_parameters.EFFECT_BLACKBOARD;
else if (!g_strcmp0 (color_effect, Parameters_EFFECT_AQUA)) else if (!g_strcmp0 (color_effect, Parameters_EFFECT_AQUA))
return android_hardware_camera_parameters.EFFECT_AQUA; return android_hardware_camera_parameters.EFFECT_AQUA;
else if (!g_strcmp0 (color_effect, Parameters_EFFECT_EMBOSS)) else if (android_hardware_camera_parameters.EFFECT_EMBOSS != NULL
&& !g_strcmp0 (color_effect, Parameters_EFFECT_EMBOSS))
return android_hardware_camera_parameters.EFFECT_EMBOSS; return android_hardware_camera_parameters.EFFECT_EMBOSS;
else if (!g_strcmp0 (color_effect, Parameters_EFFECT_SKETCH)) else if (android_hardware_camera_parameters.EFFECT_SKETCH != NULL
&& !g_strcmp0 (color_effect, Parameters_EFFECT_SKETCH))
return android_hardware_camera_parameters.EFFECT_SKETCH; return android_hardware_camera_parameters.EFFECT_SKETCH;
else if (!g_strcmp0 (color_effect, Parameters_EFFECT_NEON)) else if (android_hardware_camera_parameters.EFFECT_NEON != NULL
&& !g_strcmp0 (color_effect, Parameters_EFFECT_NEON))
return android_hardware_camera_parameters.EFFECT_NEON; return android_hardware_camera_parameters.EFFECT_NEON;
return NULL; return NULL;
@ -3151,16 +3171,20 @@ _scene_mode_to_gchar (JNIEnv * env, jstring scene_mode)
else if (java_lang_string_equals (env, scene_mode, else if (java_lang_string_equals (env, scene_mode,
android_hardware_camera_parameters.SCENE_MODE_BARCODE)) android_hardware_camera_parameters.SCENE_MODE_BARCODE))
return Parameters_SCENE_MODE_BARCODE; return Parameters_SCENE_MODE_BARCODE;
else if (java_lang_string_equals (env, scene_mode, else if (android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT != NULL &&
java_lang_string_equals (env, scene_mode,
android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT)) android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT))
return Parameters_SCENE_MODE_BACKLIGHT; return Parameters_SCENE_MODE_BACKLIGHT;
else if (java_lang_string_equals (env, scene_mode, else if (android_hardware_camera_parameters.SCENE_MODE_FLOWERS != NULL &&
java_lang_string_equals (env, scene_mode,
android_hardware_camera_parameters.SCENE_MODE_FLOWERS)) android_hardware_camera_parameters.SCENE_MODE_FLOWERS))
return Parameters_SCENE_MODE_FLOWERS; return Parameters_SCENE_MODE_FLOWERS;
else if (java_lang_string_equals (env, scene_mode, else if (android_hardware_camera_parameters.SCENE_MODE_AR != NULL &&
java_lang_string_equals (env, scene_mode,
android_hardware_camera_parameters.SCENE_MODE_AR)) android_hardware_camera_parameters.SCENE_MODE_AR))
return Parameters_SCENE_MODE_AR; return Parameters_SCENE_MODE_AR;
else if (java_lang_string_equals (env, scene_mode, else if (android_hardware_camera_parameters.SCENE_MODE_HDR != NULL &&
java_lang_string_equals (env, scene_mode,
android_hardware_camera_parameters.SCENE_MODE_HDR)) android_hardware_camera_parameters.SCENE_MODE_HDR))
return Parameters_SCENE_MODE_HDR; return Parameters_SCENE_MODE_HDR;
@ -3205,13 +3229,17 @@ _scene_mode_to_jstring (const gchar * scene_mode)
return android_hardware_camera_parameters.SCENE_MODE_CANDLELIGHT; return android_hardware_camera_parameters.SCENE_MODE_CANDLELIGHT;
else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_BARCODE)) else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_BARCODE))
return android_hardware_camera_parameters.SCENE_MODE_BARCODE; return android_hardware_camera_parameters.SCENE_MODE_BARCODE;
else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_BACKLIGHT)) else if (android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT != NULL
&& !g_strcmp0 (scene_mode, Parameters_SCENE_MODE_BACKLIGHT))
return android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT; return android_hardware_camera_parameters.SCENE_MODE_BACKLIGHT;
else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_FLOWERS)) else if (android_hardware_camera_parameters.SCENE_MODE_FLOWERS != NULL
&& !g_strcmp0 (scene_mode, Parameters_SCENE_MODE_FLOWERS))
return android_hardware_camera_parameters.SCENE_MODE_FLOWERS; return android_hardware_camera_parameters.SCENE_MODE_FLOWERS;
else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_AR)) else if (android_hardware_camera_parameters.SCENE_MODE_AR != NULL
&& !g_strcmp0 (scene_mode, Parameters_SCENE_MODE_AR))
return android_hardware_camera_parameters.SCENE_MODE_AR; return android_hardware_camera_parameters.SCENE_MODE_AR;
else if (!g_strcmp0 (scene_mode, Parameters_SCENE_MODE_HDR)) else if (android_hardware_camera_parameters.SCENE_MODE_HDR != NULL
&& !g_strcmp0 (scene_mode, Parameters_SCENE_MODE_HDR))
return android_hardware_camera_parameters.SCENE_MODE_HDR; return android_hardware_camera_parameters.SCENE_MODE_HDR;
return NULL; return NULL;

View file

@ -84,6 +84,8 @@ extern const gchar *Parameters_EFFECT_POSTERIZE;
extern const gchar *Parameters_EFFECT_WHITEBOARD; extern const gchar *Parameters_EFFECT_WHITEBOARD;
extern const gchar *Parameters_EFFECT_BLACKBOARD; extern const gchar *Parameters_EFFECT_BLACKBOARD;
extern const gchar *Parameters_EFFECT_AQUA; extern const gchar *Parameters_EFFECT_AQUA;
/* EMBOSS, SKETCH and NEON are not standard Android API
* but are available only on some Qualcomm devices */
extern const gchar *Parameters_EFFECT_EMBOSS; extern const gchar *Parameters_EFFECT_EMBOSS;
extern const gchar *Parameters_EFFECT_SKETCH; extern const gchar *Parameters_EFFECT_SKETCH;
extern const gchar *Parameters_EFFECT_NEON; extern const gchar *Parameters_EFFECT_NEON;
@ -112,9 +114,12 @@ extern const gchar *Parameters_SCENE_MODE_SPORTS;
extern const gchar *Parameters_SCENE_MODE_PARTY; extern const gchar *Parameters_SCENE_MODE_PARTY;
extern const gchar *Parameters_SCENE_MODE_CANDLELIGHT; extern const gchar *Parameters_SCENE_MODE_CANDLELIGHT;
extern const gchar *Parameters_SCENE_MODE_BARCODE; extern const gchar *Parameters_SCENE_MODE_BARCODE;
/* BACKLIGHT, FLOWERS and AR are not standard Android API
* but are available only on some Qualcomm devices. */
extern const gchar *Parameters_SCENE_MODE_BACKLIGHT; extern const gchar *Parameters_SCENE_MODE_BACKLIGHT;
extern const gchar *Parameters_SCENE_MODE_FLOWERS; extern const gchar *Parameters_SCENE_MODE_FLOWERS;
extern const gchar *Parameters_SCENE_MODE_AR; extern const gchar *Parameters_SCENE_MODE_AR;
/* HDR is available in API 17+ (Android 4.2) */
extern const gchar *Parameters_SCENE_MODE_HDR; extern const gchar *Parameters_SCENE_MODE_HDR;
extern const gchar *Parameters_FOCUS_MODE_AUTO; extern const gchar *Parameters_FOCUS_MODE_AUTO;
extern const gchar *Parameters_FOCUS_MODE_INFINITY; extern const gchar *Parameters_FOCUS_MODE_INFINITY;