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

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

Issue 2019423006: Adding more detail to MessageQueue::Dispatch logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 jmethodID m = GetMethodID(jni(), *j_video_capturer_class_, 103 jmethodID m = GetMethodID(jni(), *j_video_capturer_class_,
104 "stopCapture", "()V"); 104 "stopCapture", "()V");
105 jni()->CallVoidMethod(*j_video_capturer_, m); 105 jni()->CallVoidMethod(*j_video_capturer_, m);
106 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.stopCapture"; 106 CHECK_EXCEPTION(jni()) << "error during VideoCapturer.stopCapture";
107 LOG(LS_INFO) << "AndroidVideoCapturerJni stop done"; 107 LOG(LS_INFO) << "AndroidVideoCapturerJni stop done";
108 } 108 }
109 109
110 template <typename... Args> 110 template <typename... Args>
111 void AndroidVideoCapturerJni::AsyncCapturerInvoke( 111 void AndroidVideoCapturerJni::AsyncCapturerInvoke(
112 const char* method_name, 112 const rtc::Location& posted_from,
113 void (webrtc::AndroidVideoCapturer::*method)(Args...), 113 void (webrtc::AndroidVideoCapturer::*method)(Args...),
114 typename Identity<Args>::type... args) { 114 typename Identity<Args>::type... args) {
115 rtc::CritScope cs(&capturer_lock_); 115 rtc::CritScope cs(&capturer_lock_);
116 if (!invoker_) { 116 if (!invoker_) {
117 LOG(LS_WARNING) << method_name << "() called for closed capturer."; 117 LOG(LS_WARNING) << posted_from.function_name()
118 << "() called for closed capturer.";
118 return; 119 return;
119 } 120 }
120 invoker_->AsyncInvoke<void>(rtc::Bind(method, capturer_, args...)); 121 invoker_->AsyncInvoke<void>(posted_from,
122 rtc::Bind(method, capturer_, args...));
121 } 123 }
122 124
123 std::vector<cricket::VideoFormat> 125 std::vector<cricket::VideoFormat>
124 AndroidVideoCapturerJni::GetSupportedFormats() { 126 AndroidVideoCapturerJni::GetSupportedFormats() {
125 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 127 JNIEnv* jni = AttachCurrentThreadIfNeeded();
126 jobject j_list_of_formats = jni->CallObjectMethod( 128 jobject j_list_of_formats = jni->CallObjectMethod(
127 *j_video_capturer_, 129 *j_video_capturer_,
128 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats", 130 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats",
129 "()Ljava/util/List;")); 131 "()Ljava/util/List;"));
130 CHECK_EXCEPTION(jni) << "error during getSupportedFormats"; 132 CHECK_EXCEPTION(jni) << "error during getSupportedFormats";
(...skipping 20 matching lines...) Expand all
151 formats.emplace_back(GetIntField(jni, j_format, j_width_field), 153 formats.emplace_back(GetIntField(jni, j_format, j_width_field),
152 GetIntField(jni, j_format, j_height_field), 154 GetIntField(jni, j_format, j_height_field),
153 frame_interval, cricket::FOURCC_NV21); 155 frame_interval, cricket::FOURCC_NV21);
154 } 156 }
155 CHECK_EXCEPTION(jni) << "error while extracting formats"; 157 CHECK_EXCEPTION(jni) << "error while extracting formats";
156 return formats; 158 return formats;
157 } 159 }
158 160
159 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) { 161 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
160 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success; 162 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success;
161 AsyncCapturerInvoke("OnCapturerStarted", 163 AsyncCapturerInvoke(
162 &webrtc::AndroidVideoCapturer::OnCapturerStarted, 164 FROM_HERE, &webrtc::AndroidVideoCapturer::OnCapturerStarted, success);
163 success);
164 } 165 }
165 166
166 void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame, 167 void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
167 int length, 168 int length,
168 int width, 169 int width,
169 int height, 170 int height,
170 int rotation, 171 int rotation,
171 int64_t timestamp_ns) { 172 int64_t timestamp_ns) {
172 const uint8_t* y_plane = static_cast<uint8_t*>(video_frame); 173 const uint8_t* y_plane = static_cast<uint8_t*>(video_frame);
173 const uint8_t* vu_plane = y_plane + width * height; 174 const uint8_t* vu_plane = y_plane + width * height;
174 175
175 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer = 176 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer =
176 buffer_pool_.CreateBuffer(width, height); 177 buffer_pool_.CreateBuffer(width, height);
177 libyuv::NV21ToI420( 178 libyuv::NV21ToI420(
178 y_plane, width, 179 y_plane, width,
179 vu_plane, width, 180 vu_plane, width,
180 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane), 181 buffer->MutableData(webrtc::kYPlane), buffer->stride(webrtc::kYPlane),
181 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane), 182 buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane),
182 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane), 183 buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane),
183 width, height); 184 width, height);
184 AsyncCapturerInvoke("OnIncomingFrame", 185 AsyncCapturerInvoke(FROM_HERE, &webrtc::AndroidVideoCapturer::OnIncomingFrame,
185 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
186 buffer, rotation, timestamp_ns); 186 buffer, rotation, timestamp_ns);
187 } 187 }
188 188
189 void AndroidVideoCapturerJni::OnTextureFrame(int width, 189 void AndroidVideoCapturerJni::OnTextureFrame(int width,
190 int height, 190 int height,
191 int rotation, 191 int rotation,
192 int64_t timestamp_ns, 192 int64_t timestamp_ns,
193 const NativeHandleImpl& handle) { 193 const NativeHandleImpl& handle) {
194 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( 194 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
195 surface_texture_helper_->CreateTextureFrame(width, height, handle)); 195 surface_texture_helper_->CreateTextureFrame(width, height, handle));
196 196
197 AsyncCapturerInvoke("OnIncomingFrame", 197 AsyncCapturerInvoke(FROM_HERE, &webrtc::AndroidVideoCapturer::OnIncomingFrame,
198 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
199 buffer, rotation, timestamp_ns); 198 buffer, rotation, timestamp_ns);
200 } 199 }
201 200
202 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width, 201 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
203 int height, 202 int height,
204 int fps) { 203 int fps) {
205 AsyncCapturerInvoke("OnOutputFormatRequest", 204 AsyncCapturerInvoke(FROM_HERE,
206 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest, 205 &webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
207 width, height, fps); 206 width, height, fps);
208 } 207 }
209 208
210 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); } 209 JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); }
211 210
212 JOW(void, 211 JOW(void,
213 VideoCapturer_00024NativeObserver_nativeOnByteBufferFrameCaptured) 212 VideoCapturer_00024NativeObserver_nativeOnByteBufferFrameCaptured)
214 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length, 213 (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length,
215 jint width, jint height, jint rotation, jlong timestamp) { 214 jint width, jint height, jint rotation, jlong timestamp) {
(...skipping 23 matching lines...) Expand all
239 238
240 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) 239 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest)
241 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 240 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
242 jint j_fps) { 241 jint j_fps) {
243 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 242 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
244 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 243 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
245 j_width, j_height, j_fps); 244 j_width, j_height, j_fps);
246 } 245 }
247 246
248 } // namespace webrtc_jni 247 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698