Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: webrtc/sdk/android/src/jni/jni_helpers.cc

Issue 3003873002: Bindings for injectable Java video encoders. (Closed)
Patch Set: Fix tests Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/sdk/android/src/jni/jni_helpers.h ('k') | webrtc/sdk/android/src/jni/pc/video_jni.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/android/src/jni/jni_helpers.cc
diff --git a/webrtc/sdk/android/src/jni/jni_helpers.cc b/webrtc/sdk/android/src/jni/jni_helpers.cc
index f6b4b6f6e5a732b97b108bf41b341d9671506826..03847666dad9db5788756b728ed519b74c956712 100644
--- a/webrtc/sdk/android/src/jni/jni_helpers.cc
+++ b/webrtc/sdk/android/src/jni/jni_helpers.cc
@@ -307,6 +307,41 @@ std::string GetJavaEnumName(JNIEnv* jni,
return JavaToStdString(jni, name);
}
+std::map<std::string, std::string> JavaToStdMapStrings(JNIEnv* jni,
+ jobject j_map) {
+ jclass map_class = jni->FindClass("java/util/Map");
+ jclass set_class = jni->FindClass("java/util/Set");
+ jclass iterator_class = jni->FindClass("java/util/Iterator");
+ jclass entry_class = jni->FindClass("java/util/Map$Entry");
+ jmethodID entry_set_method =
+ jni->GetMethodID(map_class, "entrySet", "()Ljava/util/Set;");
+ jmethodID iterator_method =
+ jni->GetMethodID(set_class, "iterator", "()Ljava/util/Iterator;");
+ jmethodID has_next_method =
+ jni->GetMethodID(iterator_class, "hasNext", "()Z");
+ jmethodID next_method =
+ jni->GetMethodID(iterator_class, "next", "()Ljava/lang/Object;");
+ jmethodID get_key_method =
+ jni->GetMethodID(entry_class, "getKey", "()Ljava/lang/Object;");
+ jmethodID get_value_method =
+ jni->GetMethodID(entry_class, "getValue", "()Ljava/lang/Object;");
+
+ jobject j_entry_set = jni->CallObjectMethod(j_map, entry_set_method);
+ jobject j_iterator = jni->CallObjectMethod(j_entry_set, iterator_method);
+
+ std::map<std::string, std::string> result;
+ while (jni->CallBooleanMethod(j_iterator, has_next_method)) {
+ jobject j_entry = jni->CallObjectMethod(j_iterator, next_method);
+ jstring j_key =
+ static_cast<jstring>(jni->CallObjectMethod(j_entry, get_key_method));
+ jstring j_value =
+ static_cast<jstring>(jni->CallObjectMethod(j_entry, get_value_method));
+ result[JavaToStdString(jni, j_key)] = JavaToStdString(jni, j_value);
+ }
+
+ return result;
+}
+
jobject NewGlobalRef(JNIEnv* jni, jobject o) {
jobject ret = jni->NewGlobalRef(o);
CHECK_EXCEPTION(jni) << "error during NewGlobalRef";
« no previous file with comments | « webrtc/sdk/android/src/jni/jni_helpers.h ('k') | webrtc/sdk/android/src/jni/pc/video_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698