1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/capture/video/video_capture_device.h"
7 #include "base/i18n/timezone.h"
8 #include "base/strings/string_util.h"
12 const std::string
VideoCaptureDevice::Name::GetNameAndModel() const {
13 const std::string model_id
= GetModel();
16 const std::string suffix
= " (" + model_id
+ ")";
17 if (base::EndsWith(device_name_
, suffix
, base::CompareCase::SENSITIVE
))
19 return device_name_
+ suffix
;
22 VideoCaptureDevice::Name::Name() {
25 VideoCaptureDevice::Name::Name(const std::string
& name
, const std::string
& id
)
26 : device_name_(name
), unique_id_(id
) {
30 VideoCaptureDevice::Name::Name(const std::string
& name
,
31 const std::string
& id
,
32 const CaptureApiType api_type
)
33 : device_name_(name
), unique_id_(id
), capture_api_class_(api_type
) {
36 VideoCaptureDevice::Name::Name(const std::string
& name
,
37 const std::string
& id
,
38 const CaptureApiType api_type
)
41 capture_api_class_(api_type
),
42 capabilities_id_(id
) {
44 #elif defined(OS_MACOSX)
45 VideoCaptureDevice::Name::Name(const std::string
& name
,
46 const std::string
& id
,
47 const CaptureApiType api_type
)
50 capture_api_class_(api_type
),
51 transport_type_(OTHER_TRANSPORT
),
52 is_blacklisted_(false) {
55 VideoCaptureDevice::Name::Name(const std::string
& name
,
56 const std::string
& id
,
57 const CaptureApiType api_type
,
58 const TransportType transport_type
)
61 capture_api_class_(api_type
),
62 transport_type_(transport_type
),
63 is_blacklisted_(false) {
65 #elif defined(ANDROID)
66 VideoCaptureDevice::Name::Name(const std::string
& name
,
67 const std::string
& id
,
68 const CaptureApiType api_type
)
69 : device_name_(name
), unique_id_(id
), capture_api_class_(api_type
) {
73 VideoCaptureDevice::Name::~Name() {
77 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
78 switch (capture_api_type()) {
79 case V4L2_SINGLE_PLANE
:
81 case V4L2_MULTI_PLANE
:
84 NOTREACHED() << "Unknown Video Capture API type!";
89 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
90 switch (capture_api_type()) {
91 case MEDIA_FOUNDATION
:
92 return "Media Foundation";
96 NOTREACHED() << "Unknown Video Capture API type!";
100 #elif defined(OS_MACOSX)
101 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
102 switch (capture_api_type()) {
104 return "AV Foundation";
110 NOTREACHED() << "Unknown Video Capture API type!";
111 return "Unknown API";
114 #elif defined(OS_ANDROID)
115 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
116 switch (capture_api_type()) {
118 return "Camera API1";
120 return "Camera API2 Legacy";
122 return "Camera API2 Full";
124 return "Camera API2 Limited";
127 case API_TYPE_UNKNOWN
:
129 NOTREACHED() << "Unknown Video Capture API type!";
130 return "Unknown API";
135 VideoCaptureDevice::Client::Buffer::~Buffer() {
138 VideoCaptureDevice::~VideoCaptureDevice() {
141 int VideoCaptureDevice::GetPowerLineFrequencyForLocation() const {
142 std::string current_country
= base::CountryCodeForCurrentTimezone();
143 if (current_country
.empty())
145 // Sorted out list of countries with 60Hz power line frequency, from
146 // http://en.wikipedia.org/wiki/Mains_electricity_by_country
147 const char* countries_using_60Hz
[] = {
148 "AI", "AO", "AS", "AW", "AZ", "BM", "BR", "BS", "BZ", "CA", "CO",
149 "CR", "CU", "DO", "EC", "FM", "GT", "GU", "GY", "HN", "HT", "JP",
150 "KN", "KR", "KY", "MS", "MX", "NI", "PA", "PE", "PF", "PH", "PR",
151 "PW", "SA", "SR", "SV", "TT", "TW", "UM", "US", "VG", "VI", "VE"};
152 const char** countries_using_60Hz_end
=
153 countries_using_60Hz
+ arraysize(countries_using_60Hz
);
154 if (std::find(countries_using_60Hz
, countries_using_60Hz_end
,
155 current_country
) == countries_using_60Hz_end
) {
156 return kPowerLine50Hz
;
158 return kPowerLine60Hz
;