Add an example app for Android native API.
The app is a simple loopback demo demonstrating the usage of Android native API. This is an initial version and I will add support for HW codecs etc. in the future. Bug: webrtc:8769 Change-Id: Ifb6209769dabeb8ca3185b969a1ef8afd6d84390 Reviewed-on: https://webrtc-review.googlesource.com/60540 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22385}
This commit is contained in:
committed by
Commit Bot
parent
0dd7435abc
commit
3e77afd0d2
@ -266,6 +266,17 @@ void JavaMapBuilder::put(const JavaRef<jobject>& key,
|
||||
JNI_Map::Java_Map_put(env_, j_map_, key, value);
|
||||
}
|
||||
|
||||
jlong NativeToJavaPointer(void* ptr) {
|
||||
static_assert(sizeof(intptr_t) <= sizeof(jlong),
|
||||
"Time to rethink the use of jlongs");
|
||||
// Going through intptr_t to be obvious about the definedness of the
|
||||
// conversion from pointer to integral type. intptr_t to jlong is a standard
|
||||
// widening by the static_assert above.
|
||||
jlong ret = reinterpret_cast<intptr_t>(ptr);
|
||||
RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Given a list of jstrings, reinterprets it to a new vector of native strings.
|
||||
std::vector<std::string> JavaToStdVectorStrings(JNIEnv* jni,
|
||||
const JavaRef<jobject>& list) {
|
||||
|
||||
@ -285,6 +285,11 @@ ScopedJavaLocalRef<jobject> NativeToJavaMap(JNIEnv* env,
|
||||
return builder.GetJavaMap();
|
||||
}
|
||||
|
||||
// Return a |jlong| that will correctly convert back to |ptr|. This is needed
|
||||
// because the alternative (of silently passing a 32-bit pointer to a vararg
|
||||
// function expecting a 64-bit param) picks up garbage in the high 32 bits.
|
||||
jlong NativeToJavaPointer(void* ptr);
|
||||
|
||||
// ------------------------
|
||||
// -- Deprecated methods --
|
||||
// ------------------------
|
||||
|
||||
Reference in New Issue
Block a user