Android: Generate JNI code for RtpReceiver and PeerConnection.Observer

Bug: webrtc:8278
Change-Id: Ief62c37dd6820c2eb1ce94e37e0a61dd8726caae
Reviewed-on: https://webrtc-review.googlesource.com/28621
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21035}
This commit is contained in:
Magnus Jedvert
2017-12-04 13:43:27 +01:00
committed by Commit Bot
parent cb666f5e03
commit ba700f642b
14 changed files with 250 additions and 272 deletions

View File

@ -155,14 +155,22 @@ class ScopedGlobalRef {
public:
ScopedGlobalRef(JNIEnv* jni, T obj)
: obj_(static_cast<T>(jni->NewGlobalRef(obj))) {}
ScopedGlobalRef(ScopedGlobalRef&& other) : obj_(other.obj_) {
other.obj_ = nullptr;
}
~ScopedGlobalRef() {
DeleteGlobalRef(AttachCurrentThreadIfNeeded(), obj_);
if (obj_) {
DeleteGlobalRef(AttachCurrentThreadIfNeeded(), obj_);
}
}
T operator*() const {
return obj_;
}
private:
T obj_;
RTC_DISALLOW_COPY_AND_ASSIGN(ScopedGlobalRef);
};
// Provides a convenient way to iterate over a Java Iterable using the