| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ? surface_texture_helper_->GetJavaSurfaceTextureHelper() | 82 ? surface_texture_helper_->GetJavaSurfaceTextureHelper() |
| 83 : nullptr, | 83 : nullptr, |
| 84 application_context_, j_frame_observer); | 84 application_context_, j_frame_observer); |
| 85 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.startCapture"; | 85 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.startCapture"; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void AndroidVideoCapturerJni::Stop() { | 88 void AndroidVideoCapturerJni::Stop() { |
| 89 LOG(LS_INFO) << "AndroidVideoCapturerJni stop"; | 89 LOG(LS_INFO) << "AndroidVideoCapturerJni stop"; |
| 90 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 90 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 { | 91 { |
| 92 // TODO(nisse): Consider moving this block until *after* the call to |
| 93 // stopCapturer. stopCapturer should ensure that we get no |
| 94 // more frames, and then we shouldn't need the if (!capturer_) |
| 95 // checks in OnMemoryBufferFrame and OnTextureFrame. |
| 92 rtc::CritScope cs(&capturer_lock_); | 96 rtc::CritScope cs(&capturer_lock_); |
| 93 // Destroying |invoker_| will cancel all pending calls to |capturer_|. | 97 // Destroying |invoker_| will cancel all pending calls to |capturer_|. |
| 94 invoker_ = nullptr; | 98 invoker_ = nullptr; |
| 95 capturer_ = nullptr; | 99 capturer_ = nullptr; |
| 96 } | 100 } |
| 97 jmethodID m = GetMethodID(jni(), *j_video_capturer_class_, | 101 jmethodID m = GetMethodID(jni(), *j_video_capturer_class_, |
| 98 "stopCapture", "()V"); | 102 "stopCapture", "()V"); |
| 99 jni()->CallVoidMethod(*j_video_capturer_, m); | 103 jni()->CallVoidMethod(*j_video_capturer_, m); |
| 100 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.stopCapture"; | 104 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.stopCapture"; |
| 101 LOG(LS_INFO) << "AndroidVideoCapturerJni stop done"; | 105 LOG(LS_INFO) << "AndroidVideoCapturerJni stop done"; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 169 |
| 166 void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame, | 170 void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame, |
| 167 int length, | 171 int length, |
| 168 int width, | 172 int width, |
| 169 int height, | 173 int height, |
| 170 int rotation, | 174 int rotation, |
| 171 int64_t timestamp_ns) { | 175 int64_t timestamp_ns) { |
| 172 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || | 176 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || |
| 173 rotation == 270); | 177 rotation == 270); |
| 174 rtc::CritScope cs(&capturer_lock_); | 178 rtc::CritScope cs(&capturer_lock_); |
| 175 | 179 if (!capturer_) { |
| 180 LOG(LS_WARNING) << "OnMemoryBufferFrame() called for closed capturer."; |
| 181 return; |
| 182 } |
| 176 int adapted_width; | 183 int adapted_width; |
| 177 int adapted_height; | 184 int adapted_height; |
| 178 int crop_width; | 185 int crop_width; |
| 179 int crop_height; | 186 int crop_height; |
| 180 int crop_x; | 187 int crop_x; |
| 181 int crop_y; | 188 int crop_y; |
| 182 | 189 |
| 183 if (!capturer_->AdaptFrame(width, height, timestamp_ns, | 190 if (!capturer_->AdaptFrame(width, height, timestamp_ns, |
| 184 &adapted_width, &adapted_height, | 191 &adapted_width, &adapted_height, |
| 185 &crop_width, &crop_height, &crop_x, &crop_y)) { | 192 &crop_width, &crop_height, &crop_x, &crop_y)) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 252 } |
| 246 | 253 |
| 247 void AndroidVideoCapturerJni::OnTextureFrame(int width, | 254 void AndroidVideoCapturerJni::OnTextureFrame(int width, |
| 248 int height, | 255 int height, |
| 249 int rotation, | 256 int rotation, |
| 250 int64_t timestamp_ns, | 257 int64_t timestamp_ns, |
| 251 const NativeHandleImpl& handle) { | 258 const NativeHandleImpl& handle) { |
| 252 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || | 259 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || |
| 253 rotation == 270); | 260 rotation == 270); |
| 254 rtc::CritScope cs(&capturer_lock_); | 261 rtc::CritScope cs(&capturer_lock_); |
| 255 | 262 if (!capturer_) { |
| 263 LOG(LS_WARNING) << "OnTextureFrame() called for closed capturer."; |
| 264 return; |
| 265 } |
| 256 int adapted_width; | 266 int adapted_width; |
| 257 int adapted_height; | 267 int adapted_height; |
| 258 int crop_width; | 268 int crop_width; |
| 259 int crop_height; | 269 int crop_height; |
| 260 int crop_x; | 270 int crop_x; |
| 261 int crop_y; | 271 int crop_y; |
| 262 | 272 |
| 263 if (!capturer_->AdaptFrame(width, height, timestamp_ns, | 273 if (!capturer_->AdaptFrame(width, height, timestamp_ns, |
| 264 &adapted_width, &adapted_height, | 274 &adapted_width, &adapted_height, |
| 265 &crop_width, &crop_height, &crop_x, &crop_y)) { | 275 &crop_width, &crop_height, &crop_x, &crop_y)) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 344 |
| 335 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) | 345 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) |
| 336 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, | 346 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, |
| 337 jint j_fps) { | 347 jint j_fps) { |
| 338 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; | 348 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; |
| 339 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( | 349 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( |
| 340 j_width, j_height, j_fps); | 350 j_width, j_height, j_fps); |
| 341 } | 351 } |
| 342 | 352 |
| 343 } // namespace webrtc_jni | 353 } // namespace webrtc_jni |
| OLD | NEW |