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

Side by Side Diff: webrtc/api/java/jni/androidvideocapturer_jni.cc

Issue 1987663002: android: Don't do a thread jump for incoming frames. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Clarified comment. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = 175 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer =
176 buffer_pool_.CreateBuffer(width, height); 176 buffer_pool_.CreateBuffer(width, height);
177 libyuv::NV21ToI420( 177 libyuv::NV21ToI420(
178 y_plane, width, 178 y_plane, width,
179 vu_plane, width, 179 vu_plane, width,
180 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane), 180 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane),
181 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane), 181 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane),
182 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane), 182 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane),
183 width, height); 183 width, height);
184 AsyncCapturerInvoke("OnIncomingFrame", 184
185 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 185 rtc::CritScope cs(&capturer_lock_);
186 buffer, rotation, timestamp_ns); 186 if (!capturer_) {
187 LOG(LS_WARNING) << "OnMemoryBufferFrame() called for closed capturer.";
188 return;
189 }
190 capturer_->OnIncomingFrame(buffer, rotation, timestamp_ns);
187 } 191 }
188 192
189 void AndroidVideoCapturerJni::OnTextureFrame(int width, 193 void AndroidVideoCapturerJni::OnTextureFrame(int width,
190 int height, 194 int height,
191 int rotation, 195 int rotation,
192 int64_t timestamp_ns, 196 int64_t timestamp_ns,
193 const NativeHandleImpl& handle) { 197 const NativeHandleImpl& handle) {
194 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( 198 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
195 surface_texture_helper_->CreateTextureFrame(width, height, handle)); 199 surface_texture_helper_->CreateTextureFrame(width, height, handle));
196 200
197 AsyncCapturerInvoke("OnIncomingFrame", 201 rtc::CritScope cs(&capturer_lock_);
198 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 202 if (!capturer_) {
199 buffer, rotation, timestamp_ns); 203 LOG(LS_WARNING) << "OnTextureFrame() called for closed capturer.";
204 return;
205 }
206 capturer_->OnIncomingFrame(buffer, rotation, timestamp_ns);
200 } 207 }
201 208
202 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width, 209 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
203 int height, 210 int height,
204 int fps) { 211 int fps) {
205 AsyncCapturerInvoke("OnOutputFormatRequest", 212 AsyncCapturerInvoke("OnOutputFormatRequest",
206 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest, 213 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
207 width, height, fps); 214 width, height, fps);
208 } 215 }
209 216
(...skipping 29 matching lines...) Expand all
239 246
240 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) 247 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest)
241 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 248 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
242 jint j_fps) { 249 jint j_fps) {
243 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 250 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
244 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 251 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
245 j_width, j_height, j_fps); 252 j_width, j_height, j_fps);
246 } 253 }
247 254
248 } // namespace webrtc_jni 255 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698