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

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

Issue 667433003: Fix a crash when cameraInfo is NULL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 2 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
« no previous file with comments | « media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_factory_android.h" 5 #include "media/video/capture/android/video_capture_device_factory_android.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 JNIEnv* env = AttachCurrentThread(); 59 JNIEnv* env = AttachCurrentThread();
60 60
61 int num_cameras = Java_VideoCaptureFactory_getNumberOfCameras( 61 int num_cameras = Java_VideoCaptureFactory_getNumberOfCameras(
62 env, base::android::GetApplicationContext()); 62 env, base::android::GetApplicationContext());
63 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras; 63 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras;
64 if (num_cameras <= 0) 64 if (num_cameras <= 0)
65 return; 65 return;
66 66
67 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { 67 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) {
68 base::android::ScopedJavaLocalRef<jstring> device_name =
69 Java_VideoCaptureFactory_getDeviceName(env, camera_id);
70 if (device_name.obj() == NULL)
71 continue;
72
68 VideoCaptureDevice::Name name( 73 VideoCaptureDevice::Name name(
69 base::android::ConvertJavaStringToUTF8( 74 base::android::ConvertJavaStringToUTF8(device_name),
70 Java_VideoCaptureFactory_getDeviceName(env, camera_id)), 75 base::IntToString(camera_id));
71 base::android::ConvertJavaStringToUTF8(
72 Java_VideoCaptureFactory_getDeviceId(env, camera_id)));
73 device_names->push_back(name); 76 device_names->push_back(name);
74 77
75 DVLOG(1) << "VideoCaptureDeviceFactoryAndroid::GetDeviceNames: camera " 78 DVLOG(1) << "VideoCaptureDeviceFactoryAndroid::GetDeviceNames: camera "
76 << "device_name=" << name.name() << ", unique_id=" << name.id(); 79 << "device_name=" << name.name() << ", unique_id=" << name.id();
77 } 80 }
78 } 81 }
79 82
80 void VideoCaptureDeviceFactoryAndroid::GetDeviceSupportedFormats( 83 void VideoCaptureDeviceFactoryAndroid::GetDeviceSupportedFormats(
81 const VideoCaptureDevice::Name& device, 84 const VideoCaptureDevice::Name& device,
82 VideoCaptureFormats* capture_formats) { 85 VideoCaptureFormats* capture_formats) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 format.obj())), 117 format.obj())),
115 media::Java_VideoCaptureFactory_getCaptureFormatFramerate(env, 118 media::Java_VideoCaptureFactory_getCaptureFormatFramerate(env,
116 format.obj()), 119 format.obj()),
117 pixel_format); 120 pixel_format);
118 capture_formats->push_back(capture_format); 121 capture_formats->push_back(capture_format);
119 DVLOG(1) << device.name() << " " << capture_format.ToString(); 122 DVLOG(1) << device.name() << " " << capture_format.ToString();
120 } 123 }
121 } 124 }
122 125
123 } // namespace media 126 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698