| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 jni->DeleteGlobalRef(application_context_); | 26 jni->DeleteGlobalRef(application_context_); |
| 27 } | 27 } |
| 28 application_context_ = NewGlobalRef(jni, appliction_context); | 28 application_context_ = NewGlobalRef(jni, appliction_context); |
| 29 | 29 |
| 30 return 0; | 30 return 0; |
| 31 } | 31 } |
| 32 | 32 |
| 33 AndroidVideoCapturerJni::AndroidVideoCapturerJni( | 33 AndroidVideoCapturerJni::AndroidVideoCapturerJni( |
| 34 JNIEnv* jni, | 34 JNIEnv* jni, |
| 35 jobject j_video_capturer, | 35 jobject j_video_capturer, |
| 36 jobject j_surface_texture_helper) | 36 jobject j_egl_context) |
| 37 : j_video_capturer_(jni, j_video_capturer), | 37 : j_video_capturer_(jni, j_video_capturer), |
| 38 j_video_capturer_class_( | 38 j_video_capturer_class_( |
| 39 jni, FindClass(jni, "org/webrtc/VideoCapturer")), | 39 jni, FindClass(jni, "org/webrtc/VideoCapturer")), |
| 40 j_observer_class_( | 40 j_observer_class_( |
| 41 jni, | 41 jni, |
| 42 FindClass(jni, | 42 FindClass(jni, |
| 43 "org/webrtc/VideoCapturer$NativeObserver")), | 43 "org/webrtc/VideoCapturer$NativeObserver")), |
| 44 surface_texture_helper_(new rtc::RefCountedObject<SurfaceTextureHelper>( | 44 surface_texture_helper_(new rtc::RefCountedObject<SurfaceTextureHelper>( |
| 45 jni, j_surface_texture_helper)), | 45 jni, j_egl_context)), |
| 46 capturer_(nullptr) { | 46 capturer_(nullptr) { |
| 47 LOG(LS_INFO) << "AndroidVideoCapturerJni ctor"; | 47 LOG(LS_INFO) << "AndroidVideoCapturerJni ctor"; |
| 48 thread_checker_.DetachFromThread(); | 48 thread_checker_.DetachFromThread(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 AndroidVideoCapturerJni::~AndroidVideoCapturerJni() { | 51 AndroidVideoCapturerJni::~AndroidVideoCapturerJni() { |
| 52 LOG(LS_INFO) << "AndroidVideoCapturerJni dtor"; | 52 LOG(LS_INFO) << "AndroidVideoCapturerJni dtor"; |
| 53 jni()->CallVoidMethod( | 53 jni()->CallVoidMethod( |
| 54 *j_video_capturer_, | 54 *j_video_capturer_, |
| 55 GetMethodID(jni(), *j_video_capturer_class_, "dispose", "()V")); | 55 GetMethodID(jni(), *j_video_capturer_class_, "dispose", "()V")); |
| 56 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.dispose()"; | 56 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.dispose()"; |
| 57 jni()->CallVoidMethod( |
| 58 surface_texture_helper_->GetJavaSurfaceTextureHelper(), |
| 59 GetMethodID(jni(), FindClass(jni(), "org/webrtc/SurfaceTextureHelper"), |
| 60 "dispose", "()V")); |
| 61 CHECK_EXCEPTION(jni()) << "error during SurfaceTextureHelper.dispose()"; |
| 57 } | 62 } |
| 58 | 63 |
| 59 void AndroidVideoCapturerJni::Start(int width, int height, int framerate, | 64 void AndroidVideoCapturerJni::Start(int width, int height, int framerate, |
| 60 webrtc::AndroidVideoCapturer* capturer) { | 65 webrtc::AndroidVideoCapturer* capturer) { |
| 61 LOG(LS_INFO) << "AndroidVideoCapturerJni start"; | 66 LOG(LS_INFO) << "AndroidVideoCapturerJni start"; |
| 62 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 63 { | 68 { |
| 64 rtc::CritScope cs(&capturer_lock_); | 69 rtc::CritScope cs(&capturer_lock_); |
| 65 RTC_CHECK(capturer_ == nullptr); | 70 RTC_CHECK(capturer_ == nullptr); |
| 66 RTC_CHECK(invoker_.get() == nullptr); | 71 RTC_CHECK(invoker_.get() == nullptr); |
| 67 capturer_ = capturer; | 72 capturer_ = capturer; |
| 68 invoker_.reset(new rtc::GuardedAsyncInvoker()); | 73 invoker_.reset(new rtc::GuardedAsyncInvoker()); |
| 69 } | 74 } |
| 70 jobject j_frame_observer = | 75 jobject j_frame_observer = |
| 71 jni()->NewObject(*j_observer_class_, | 76 jni()->NewObject(*j_observer_class_, |
| 72 GetMethodID(jni(), *j_observer_class_, "<init>", "(J)V"), | 77 GetMethodID(jni(), *j_observer_class_, "<init>", "(J)V"), |
| 73 jlongFromPointer(this)); | 78 jlongFromPointer(this)); |
| 74 CHECK_EXCEPTION(jni()) << "error during NewObject"; | 79 CHECK_EXCEPTION(jni()) << "error during NewObject"; |
| 75 | 80 |
| 76 jmethodID m = GetMethodID( | 81 jmethodID m = GetMethodID( |
| 77 jni(), *j_video_capturer_class_, "startCapture", | 82 jni(), *j_video_capturer_class_, "startCapture", |
| 78 "(IIILandroid/content/Context;" | 83 "(IIILorg/webrtc/SurfaceTextureHelper;Landroid/content/Context;" |
| 79 "Lorg/webrtc/VideoCapturer$CapturerObserver;)V"); | 84 "Lorg/webrtc/VideoCapturer$CapturerObserver;)V"); |
| 80 jni()->CallVoidMethod(*j_video_capturer_, | 85 jni()->CallVoidMethod(*j_video_capturer_, |
| 81 m, width, height, | 86 m, width, height, |
| 82 framerate, | 87 framerate, |
| 88 surface_texture_helper_->GetJavaSurfaceTextureHelper(), |
| 83 application_context_, | 89 application_context_, |
| 84 j_frame_observer); | 90 j_frame_observer); |
| 85 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.startCapture"; | 91 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.startCapture"; |
| 86 } | 92 } |
| 87 | 93 |
| 88 void AndroidVideoCapturerJni::Stop() { | 94 void AndroidVideoCapturerJni::Stop() { |
| 89 LOG(LS_INFO) << "AndroidVideoCapturerJni stop"; | 95 LOG(LS_INFO) << "AndroidVideoCapturerJni stop"; |
| 90 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 96 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 { | 97 { |
| 92 rtc::CritScope cs(&capturer_lock_); | 98 rtc::CritScope cs(&capturer_lock_); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 239 |
| 234 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) | 240 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) |
| 235 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, | 241 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, |
| 236 jint j_fps) { | 242 jint j_fps) { |
| 237 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; | 243 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; |
| 238 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( | 244 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( |
| 239 j_width, j_height, j_fps); | 245 j_width, j_height, j_fps); |
| 240 } | 246 } |
| 241 | 247 |
| 242 } // namespace webrtc_jni | 248 } // namespace webrtc_jni |
| OLD | NEW |