diff --git a/sys/androidmedia/gstamc.c b/sys/androidmedia/gstamc.c index e94dad8835..7c0552bd28 100644 --- a/sys/androidmedia/gstamc.c +++ b/sys/androidmedia/gstamc.c @@ -83,6 +83,7 @@ static struct jclass klass; jmethodID create_audio_format; jmethodID create_video_format; + jmethodID to_string; jmethodID contains_key; jmethodID get_float; jmethodID set_float; @@ -866,6 +867,44 @@ gst_amc_format_free (GstAmcFormat * format) g_slice_free (GstAmcFormat, format); } +gchar * +gst_amc_format_to_string (GstAmcFormat * format) +{ + JNIEnv *env; + jstring v_str = NULL; + const gchar *v = NULL; + gchar *ret = NULL; + + g_return_val_if_fail (format != NULL, FALSE); + + env = gst_amc_get_jni_env (); + + v_str = + (*env)->CallObjectMethod (env, format->object, media_format.to_string); + if ((*env)->ExceptionCheck (env)) { + GST_ERROR ("Failed to call Java method"); + (*env)->ExceptionClear (env); + goto done; + } + + v = (*env)->GetStringUTFChars (env, v_str, NULL); + if (!v) { + GST_ERROR ("Failed to convert string to UTF8"); + (*env)->ExceptionClear (env); + goto done; + } + + ret = g_strdup (v); + +done: + if (v) + (*env)->ReleaseStringUTFChars (env, v_str, v); + if (v_str) + (*env)->DeleteLocalRef (env, v_str); + + return ret; +} + gboolean gst_amc_format_contains_key (GstAmcFormat * format, const gchar * key) { @@ -1375,6 +1414,9 @@ get_java_classes (void) media_format.create_video_format = (*env)->GetStaticMethodID (env, media_format.klass, "createVideoFormat", "(Ljava/lang/String;II)Landroid/media/MediaFormat;"); + media_format.to_string = + (*env)->GetMethodID (env, media_format.klass, "toString", + "()Ljava/lang/String;"); media_format.contains_key = (*env)->GetMethodID (env, media_format.klass, "containsKey", "(Ljava/lang/String;)Z"); diff --git a/sys/androidmedia/gstamc.h b/sys/androidmedia/gstamc.h index 32c601c9fa..4b8a513112 100644 --- a/sys/androidmedia/gstamc.h +++ b/sys/androidmedia/gstamc.h @@ -105,6 +105,8 @@ GstAmcFormat * gst_amc_format_new_audio (const gchar *mime, gint sample_rate, gi GstAmcFormat * gst_amc_format_new_video (const gchar *mime, gint width, gint height); void gst_amc_format_free (GstAmcFormat * format); +gchar * gst_amc_format_to_string (GstAmcFormat * format); + gboolean gst_amc_format_contains_key (GstAmcFormat *format, const gchar *key); gboolean gst_amc_format_get_float (GstAmcFormat *format, const gchar *key, gfloat *value); diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c index 2fbf6ffee5..249cb385a2 100644 --- a/sys/androidmedia/gstamcvideodec.c +++ b/sys/androidmedia/gstamcvideodec.c @@ -741,6 +741,7 @@ retry: } case INFO_OUTPUT_FORMAT_CHANGED:{ GstAmcFormat *format; + gchar *format_string; GST_DEBUG_OBJECT (self, "Output format has changed"); @@ -748,6 +749,10 @@ retry: if (!format) goto format_error; + format_string = gst_amc_format_to_string (format); + GST_DEBUG_OBJECT (self, "Got new output format: %s", format_string); + g_free (format_string); + if (!gst_amc_video_dec_set_src_caps (self, format)) { gst_amc_format_free (format); goto format_error; @@ -1025,6 +1030,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, const gchar *mime; gboolean is_format_change = FALSE; gboolean needs_disable = FALSE; + gchar *format_string; self = GST_AMC_VIDEO_DEC (decoder); @@ -1078,6 +1084,10 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder, if (self->codec_data) gst_amc_format_set_buffer (format, "csd-0", self->codec_data); + format_string = gst_amc_format_to_string (format); + GST_DEBUG_OBJECT (self, "Configuring codec with format: %s", format_string); + g_free (format_string); + /* FIXME: Flags? */ if (!gst_amc_codec_configure (self->codec, format, 0)) { GST_ERROR_OBJECT (self, "Failed to configure codec");