Commit 14c39daf authored by François Grisez's avatar François Grisez

Implement AMediaFormat_toString().

parent 2ccf1fe8
......@@ -83,6 +83,8 @@ struct AMediaFormat {
jmethodID getInteger;
jmethodID setString;
jmethodID containsKey;
jmethodID toString;
std::string description;
};
int handle_java_exception() {
......@@ -589,6 +591,7 @@ bool AMediaFormat_loadMethodID(AMediaFormat * format) {
success &= _getMethodID(env, mediaFormatClass, "getInteger", "(Ljava/lang/String;)I", &(format->getInteger));
success &= _getMethodID(env, mediaFormatClass, "setString", "(Ljava/lang/String;Ljava/lang/String;)V", &(format->setString));
success &= _getMethodID(env, mediaFormatClass, "containsKey", "(Ljava/lang/String;)Z", &(format->containsKey));
success &= _getMethodID(env, mediaFormatClass, "toString", "()Ljava/lang/String;", &(format->toString));
if(!success) {
ms_error("%s(): one method or field could not be found", __FUNCTION__);
goto error;
......@@ -634,6 +637,17 @@ media_status_t AMediaFormat_delete(AMediaFormat* format) {
return AMEDIA_OK;
}
const char *AMediaFormat_toString(AMediaFormat *format) {
JNIEnv *env = ms_get_jni_env();
jstring jdescription = static_cast<jstring>(env->CallObjectMethod(format->jformat, format->toString));
if (handle_java_exception() != 0) return nullptr;
const char *description = env->GetStringUTFChars(jdescription, nullptr);
format->description = description;
env->ReleaseStringUTFChars(jdescription, description);
env->DeleteLocalRef(jdescription);
return format->description.c_str();
}
bool AMediaFormat_getInt32(AMediaFormat *format, const char *name, int32_t *out){
JNIEnv *env = ms_get_jni_env();
bool hasValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment