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

Unified Diff: talk/app/webrtc/java/jni/androidvideocapturer_jni.h

Issue 1307973002: AndroidVideoCapturerJni: Fix threading issues (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressing tommi@s comments Created 5 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 | « talk/app/webrtc/androidvideocapturer.cc ('k') | talk/app/webrtc/java/jni/androidvideocapturer_jni.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/java/jni/androidvideocapturer_jni.h
diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.h b/talk/app/webrtc/java/jni/androidvideocapturer_jni.h
index ed3f8d2cc2ac6d66e8f9969824b577cc89205d64..625486fadbbe0a80259fe90d01ff63322730b657 100644
--- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.h
+++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.h
@@ -34,6 +34,7 @@
#include "talk/app/webrtc/androidvideocapturer.h"
#include "talk/app/webrtc/java/jni/jni_helpers.h"
#include "webrtc/base/asyncinvoker.h"
+#include "webrtc/base/criticalsection.h"
#include "webrtc/base/thread_checker.h"
namespace webrtc_jni {
@@ -56,8 +57,6 @@ class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate {
webrtc::AndroidVideoCapturer* capturer) override;
void Stop() override;
- void ReturnBuffer(int64 time_stamp) override;
-
std::string GetSupportedFormats() override;
// Called from VideoCapturerAndroid::NativeObserver on a Java thread.
@@ -75,34 +74,31 @@ protected:
private:
bool Init(jstring device_name);
-
- void OnCapturerStarted_w(bool success);
- void OnCapturerStopped_w();
- void OnIncomingFrame_w(void* video_frame,
- int length,
- int width,
- int height,
- int rotation,
- int64 time_stamp);
- void OnOutputFormatRequest_w(int width, int height, int fps);
- void ReturnBuffer_w(int64 time_stamp);
-
+ void ReturnBuffer(int64 time_stamp);
JNIEnv* jni();
+ // Helper function to make safe asynchronous calls to |capturer_|. The calls
+ // are not guaranteed to be delivered.
+ template <typename... Args>
+ void AsyncCapturerInvoke(
+ const char* method_name,
+ void (webrtc::AndroidVideoCapturer::*method)(Args...),
+ Args... args);
+
const ScopedGlobalRef<jobject> j_capturer_global_;
const ScopedGlobalRef<jclass> j_video_capturer_class_;
const ScopedGlobalRef<jclass> j_observer_class_;
- volatile bool valid_global_refs_;
- jobject j_frame_observer_;
rtc::ThreadChecker thread_checker_;
- rtc::Thread* thread_; // The thread where Start is called on.
// |capturer| is a guaranteed to be a valid pointer between a call to
// AndroidVideoCapturerDelegate::Start
// until AndroidVideoCapturerDelegate::Stop.
- webrtc::AndroidVideoCapturer* capturer_;
- rtc::AsyncInvoker invoker_;
+ rtc::CriticalSection capturer_lock_;
+ webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_);
+ // |invoker_| is used to communicate with |capturer_| on the thread Start() is
+ // called on.
+ rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_);
static jobject application_context_;
« no previous file with comments | « talk/app/webrtc/androidvideocapturer.cc ('k') | talk/app/webrtc/java/jni/androidvideocapturer_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698