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

Side by Side Diff: media/video/capture/android/video_capture_device_android.cc

Issue 17846002: Refactor the VideoCaptureDevice::Name struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « media/media.gyp ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 int num_cameras = Java_ChromiumCameraInfo_getNumberOfCameras(env); 45 int num_cameras = Java_ChromiumCameraInfo_getNumberOfCameras(env);
46 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras; 46 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras;
47 if (num_cameras <= 0) 47 if (num_cameras <= 0)
48 return; 48 return;
49 49
50 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { 50 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) {
51 ScopedJavaLocalRef<jobject> ci = 51 ScopedJavaLocalRef<jobject> ci =
52 Java_ChromiumCameraInfo_getAt(env, camera_id); 52 Java_ChromiumCameraInfo_getAt(env, camera_id);
53 53
54 Name name; 54 Name name(
55 name.unique_id = base::StringPrintf( 55 base::android::ConvertJavaStringToUTF8(
56 "%d", Java_ChromiumCameraInfo_getId(env, ci.obj())); 56 Java_ChromiumCameraInfo_getDeviceName(env, ci.obj())),
57 name.device_name = base::android::ConvertJavaStringToUTF8( 57 base::StringPrintf("%d", Java_ChromiumCameraInfo_getId(env, ci.obj())));
58 Java_ChromiumCameraInfo_getDeviceName(env, ci.obj()));
59 device_names->push_back(name); 58 device_names->push_back(name);
60 59
61 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: camera device_name=" 60 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: camera device_name="
62 << name.device_name 61 << name.name()
63 << ", unique_id=" 62 << ", unique_id="
64 << name.unique_id 63 << name.id()
65 << ", orientation " 64 << ", orientation "
66 << Java_ChromiumCameraInfo_getOrientation(env, ci.obj()); 65 << Java_ChromiumCameraInfo_getOrientation(env, ci.obj());
67 } 66 }
68 } 67 }
69 68
70 // static 69 // static
71 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 70 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
72 return VideoCaptureDeviceAndroid::Create(device_name); 71 return VideoCaptureDeviceAndroid::Create(device_name);
73 } 72 }
74 73
(...skipping 17 matching lines...) Expand all
92 device_name_(device_name), 91 device_name_(device_name),
93 current_settings_() { 92 current_settings_() {
94 } 93 }
95 94
96 VideoCaptureDeviceAndroid::~VideoCaptureDeviceAndroid() { 95 VideoCaptureDeviceAndroid::~VideoCaptureDeviceAndroid() {
97 DeAllocate(); 96 DeAllocate();
98 } 97 }
99 98
100 bool VideoCaptureDeviceAndroid::Init() { 99 bool VideoCaptureDeviceAndroid::Init() {
101 int id; 100 int id;
102 if (!base::StringToInt(device_name_.unique_id, &id)) 101 if (!base::StringToInt(device_name_.id(), &id))
103 return false; 102 return false;
104 103
105 JNIEnv* env = AttachCurrentThread(); 104 JNIEnv* env = AttachCurrentThread();
106 105
107 j_capture_.Reset(Java_VideoCapture_createVideoCapture( 106 j_capture_.Reset(Java_VideoCapture_createVideoCapture(
108 env, base::android::GetApplicationContext(), id, 107 env, base::android::GetApplicationContext(), id,
109 reinterpret_cast<jint>(this))); 108 reinterpret_cast<jint>(this)));
110 109
111 return true; 110 return true;
112 } 111 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { 254 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) {
256 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; 255 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason;
257 { 256 {
258 base::AutoLock lock(lock_); 257 base::AutoLock lock(lock_);
259 state_ = kError; 258 state_ = kError;
260 } 259 }
261 observer_->OnError(); 260 observer_->OnError();
262 } 261 }
263 262
264 } // namespace media 263 } // namespace media
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698