| 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/capture/video/android/video_capture_device_android.h" | 5 #include "media/capture/video/android/video_capture_device_android.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using base::android::JavaRef; | 24 using base::android::JavaRef; |
| 25 using base::android::ScopedJavaLocalRef; | 25 using base::android::ScopedJavaLocalRef; |
| 26 | 26 |
| 27 namespace media { | 27 namespace media { |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 bool VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(JNIEnv* env) { | 30 bool VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(JNIEnv* env) { |
| 31 return RegisterNativesImpl(env); | 31 return RegisterNativesImpl(env); |
| 32 } | 32 } |
| 33 | 33 |
| 34 const std::string VideoCaptureDevice::Name::GetModel() const { | 34 VideoCaptureDeviceAndroid::VideoCaptureDeviceAndroid( |
| 35 // Android cameras are not typically USB devices, and this method is currently | 35 const VideoCaptureDeviceDescriptor& device_descriptor) |
| 36 // only used for USB model identifiers, so this implementation just indicates | 36 : state_(kIdle), |
| 37 // an unknown device model. | 37 got_first_frame_(false), |
| 38 return ""; | 38 device_descriptor_(device_descriptor) {} |
| 39 } | |
| 40 | |
| 41 VideoCaptureDeviceAndroid::VideoCaptureDeviceAndroid(const Name& device_name) | |
| 42 : state_(kIdle), got_first_frame_(false), device_name_(device_name) { | |
| 43 } | |
| 44 | 39 |
| 45 VideoCaptureDeviceAndroid::~VideoCaptureDeviceAndroid() { | 40 VideoCaptureDeviceAndroid::~VideoCaptureDeviceAndroid() { |
| 46 StopAndDeAllocate(); | 41 StopAndDeAllocate(); |
| 47 } | 42 } |
| 48 | 43 |
| 49 bool VideoCaptureDeviceAndroid::Init() { | 44 bool VideoCaptureDeviceAndroid::Init() { |
| 50 int id; | 45 int id; |
| 51 if (!base::StringToInt(device_name_.id(), &id)) | 46 if (!base::StringToInt(device_descriptor_.device_id, &id)) |
| 52 return false; | 47 return false; |
| 53 | 48 |
| 54 j_capture_.Reset(VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( | 49 j_capture_.Reset(VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( |
| 55 id, reinterpret_cast<intptr_t>(this))); | 50 id, reinterpret_cast<intptr_t>(this))); |
| 56 return true; | 51 return true; |
| 57 } | 52 } |
| 58 | 53 |
| 59 void VideoCaptureDeviceAndroid::AllocateAndStart( | 54 void VideoCaptureDeviceAndroid::AllocateAndStart( |
| 60 const VideoCaptureParams& params, | 55 const VideoCaptureParams& params, |
| 61 std::unique_ptr<Client> client) { | 56 std::unique_ptr<Client> client) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 const tracked_objects::Location& from_here, | 363 const tracked_objects::Location& from_here, |
| 369 const std::string& reason) { | 364 const std::string& reason) { |
| 370 { | 365 { |
| 371 base::AutoLock lock(lock_); | 366 base::AutoLock lock(lock_); |
| 372 state_ = kError; | 367 state_ = kError; |
| 373 } | 368 } |
| 374 client_->OnError(from_here, reason); | 369 client_->OnError(from_here, reason); |
| 375 } | 370 } |
| 376 | 371 |
| 377 } // namespace media | 372 } // namespace media |
| OLD | NEW |