OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/video/capture/android/video_capture_device_android.h" | 5 #include "media/video/capture/android/video_capture_device_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/debug/trace_event.h" | |
13 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
15 #include "jni/VideoCapture_jni.h" | 14 #include "jni/VideoCapture_jni.h" |
16 #include "media/base/video_util.h" | 15 #include "media/base/video_util.h" |
17 | 16 |
18 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
19 using base::android::CheckException; | 18 using base::android::CheckException; |
20 using base::android::GetClass; | 19 using base::android::GetClass; |
21 using base::android::MethodID; | 20 using base::android::MethodID; |
22 using base::android::JavaRef; | 21 using base::android::JavaRef; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 224 |
226 Java_VideoCapture_deallocate(env, j_capture_.obj()); | 225 Java_VideoCapture_deallocate(env, j_capture_.obj()); |
227 } | 226 } |
228 | 227 |
229 void VideoCaptureDeviceAndroid::OnFrameAvailable( | 228 void VideoCaptureDeviceAndroid::OnFrameAvailable( |
230 JNIEnv* env, | 229 JNIEnv* env, |
231 jobject obj, | 230 jobject obj, |
232 jbyteArray data, | 231 jbyteArray data, |
233 jint length, | 232 jint length, |
234 jint rotation) { | 233 jint rotation) { |
235 TRACE_EVENT0("video", "VideoCaptureDeviceAndroid::OnFrameAvailable"); | |
236 DVLOG(3) << "VideoCaptureDeviceAndroid::OnFrameAvailable: length =" << length; | 234 DVLOG(3) << "VideoCaptureDeviceAndroid::OnFrameAvailable: length =" << length; |
237 | 235 |
238 base::AutoLock lock(lock_); | 236 base::AutoLock lock(lock_); |
239 if (state_ != kCapturing || !client_.get()) | 237 if (state_ != kCapturing || !client_.get()) |
240 return; | 238 return; |
241 | 239 |
242 jbyte* buffer = env->GetByteArrayElements(data, NULL); | 240 jbyte* buffer = env->GetByteArrayElements(data, NULL); |
243 if (!buffer) { | 241 if (!buffer) { |
244 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: " | 242 LOG(ERROR) << "VideoCaptureDeviceAndroid::OnFrameAvailable: " |
245 "failed to GetByteArrayElements"; | 243 "failed to GetByteArrayElements"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { | 283 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { |
286 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; | 284 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; |
287 { | 285 { |
288 base::AutoLock lock(lock_); | 286 base::AutoLock lock(lock_); |
289 state_ = kError; | 287 state_ = kError; |
290 } | 288 } |
291 client_->OnError(reason); | 289 client_->OnError(reason); |
292 } | 290 } |
293 | 291 |
294 } // namespace media | 292 } // namespace media |
OLD | NEW |