OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/video_capture_device.h" | 5 #include "media/video/capture/video_capture_device.h" |
6 | 6 |
7 #include "base/i18n/timezone.h" | 7 #include "base/i18n/timezone.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 const std::string VideoCaptureDevice::Name::GetNameAndModel() const { | 12 const std::string VideoCaptureDevice::Name::GetNameAndModel() const { |
13 const std::string model_id = GetModel(); | 13 const std::string model_id = GetModel(); |
14 if (model_id.empty()) | 14 if (model_id.empty()) |
15 return device_name_; | 15 return device_name_; |
16 const std::string suffix = " (" + model_id + ")"; | 16 const std::string suffix = " (" + model_id + ")"; |
17 if (EndsWith(device_name_, suffix, true)) // |true| means case-sensitive. | 17 if (EndsWith(device_name_, suffix, true)) // |true| means case-sensitive. |
18 return device_name_; | 18 return device_name_; |
19 return device_name_ + suffix; | 19 return device_name_ + suffix; |
20 } | 20 } |
21 | 21 |
22 VideoCaptureDevice::Name::Name() {} | 22 VideoCaptureDevice::Name::Name() {} |
23 | 23 |
24 VideoCaptureDevice::Name::Name(const std::string& name, const std::string& id) | 24 VideoCaptureDevice::Name::Name(const std::string& name, const std::string& id) |
25 : device_name_(name), unique_id_(id) {} | 25 : device_name_(name), unique_id_(id) {} |
26 | 26 |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 | |
28 VideoCaptureDevice::Name::Name(const std::string& name, | 29 VideoCaptureDevice::Name::Name(const std::string& name, |
29 const std::string& id, | 30 const std::string& id, |
30 const CaptureApiType api_type) | 31 const CaptureApiType api_type) |
31 : device_name_(name), | 32 : device_name_(name), |
32 unique_id_(id), | 33 unique_id_(id), |
33 capture_api_class_(api_type), | 34 capture_api_class_(api_type), |
34 capabilities_id_(id) {} | 35 capabilities_id_(id) {} |
35 #endif | 36 #elif defined(OS_MACOSX) |
36 | |
37 #if defined(OS_MACOSX) | |
38 VideoCaptureDevice::Name::Name(const std::string& name, | 37 VideoCaptureDevice::Name::Name(const std::string& name, |
39 const std::string& id, | 38 const std::string& id, |
40 const CaptureApiType api_type) | 39 const CaptureApiType api_type) |
41 : device_name_(name), | 40 : device_name_(name), |
42 unique_id_(id), | 41 unique_id_(id), |
43 capture_api_class_(api_type), | 42 capture_api_class_(api_type), |
44 transport_type_(OTHER_TRANSPORT), | 43 transport_type_(OTHER_TRANSPORT), |
45 is_blacklisted_(false) {} | 44 is_blacklisted_(false) {} |
46 | 45 |
47 VideoCaptureDevice::Name::Name(const std::string& name, | 46 VideoCaptureDevice::Name::Name(const std::string& name, |
48 const std::string& id, | 47 const std::string& id, |
49 const CaptureApiType api_type, | 48 const CaptureApiType api_type, |
50 const TransportType transport_type) | 49 const TransportType transport_type) |
51 : device_name_(name), | 50 : device_name_(name), |
52 unique_id_(id), | 51 unique_id_(id), |
53 capture_api_class_(api_type), | 52 capture_api_class_(api_type), |
54 transport_type_(transport_type), | 53 transport_type_(transport_type), |
55 is_blacklisted_(false) {} | 54 is_blacklisted_(false) {} |
55 #elif defined(ANDROID) | |
56 VideoCaptureDevice::Name::Name(const std::string& name, | |
57 const std::string& id, | |
58 const CaptureApiType api_type) | |
59 : device_name_(name), | |
60 unique_id_(id), | |
61 capture_api_class_(api_type) {} | |
56 #endif | 62 #endif |
57 | 63 |
58 VideoCaptureDevice::Name::~Name() {} | 64 VideoCaptureDevice::Name::~Name() {} |
59 | 65 |
60 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
61 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const { | 67 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const { |
62 switch(capture_api_type()) { | 68 switch(capture_api_type()) { |
63 case MEDIA_FOUNDATION: | 69 case MEDIA_FOUNDATION: |
64 return "Media Foundation"; | 70 return "Media Foundation"; |
65 case DIRECT_SHOW: | 71 case DIRECT_SHOW: |
(...skipping 12 matching lines...) Expand all Loading... | |
78 return "AV Foundation"; | 84 return "AV Foundation"; |
79 case QTKIT: | 85 case QTKIT: |
80 return "QTKit"; | 86 return "QTKit"; |
81 case DECKLINK: | 87 case DECKLINK: |
82 return "DeckLink"; | 88 return "DeckLink"; |
83 default: | 89 default: |
84 NOTREACHED() << "Unknown Video Capture API type!"; | 90 NOTREACHED() << "Unknown Video Capture API type!"; |
85 return "Unknown API"; | 91 return "Unknown API"; |
86 } | 92 } |
87 } | 93 } |
94 #elif defined(OS_ANDROID) | |
95 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const { | |
96 switch(capture_api_type()) { | |
97 case API1: | |
98 return "API1"; | |
mcasas
2015/03/19 01:55:14
The human readable strings (and their counterparts
emircan
2015/03/19 19:52:23
I see. I am naming them "Camera API2 Full" like sp
| |
99 case API2_FULL: | |
100 return "API2_FULL"; | |
101 case API2_LEGACY: | |
102 return "API2_LEGACY"; | |
103 case API2_LIMITED: | |
104 return "API2_LIMITED"; | |
105 case TANGO: | |
106 return "TANGO"; | |
107 case API_TYPE_UNKNOWN: | |
108 default: | |
109 NOTREACHED() << "Unknown Video Capture API type!"; | |
110 return "Unknown API"; | |
111 } | |
112 } | |
88 #endif | 113 #endif |
89 | 114 |
90 VideoCaptureDevice::~VideoCaptureDevice() {} | 115 VideoCaptureDevice::~VideoCaptureDevice() {} |
91 | 116 |
92 int VideoCaptureDevice::GetPowerLineFrequencyForLocation() const { | 117 int VideoCaptureDevice::GetPowerLineFrequencyForLocation() const { |
93 std::string current_country = base::CountryCodeForCurrentTimezone(); | 118 std::string current_country = base::CountryCodeForCurrentTimezone(); |
94 if (current_country.empty()) | 119 if (current_country.empty()) |
95 return 0; | 120 return 0; |
96 // Sorted out list of countries with 60Hz power line frequency, from | 121 // Sorted out list of countries with 60Hz power line frequency, from |
97 // http://en.wikipedia.org/wiki/Mains_electricity_by_country | 122 // http://en.wikipedia.org/wiki/Mains_electricity_by_country |
98 const char* countries_using_60Hz[] = { | 123 const char* countries_using_60Hz[] = { |
99 "AI", "AO", "AS", "AW", "AZ", "BM", "BR", "BS", "BZ", "CA", "CO", | 124 "AI", "AO", "AS", "AW", "AZ", "BM", "BR", "BS", "BZ", "CA", "CO", |
100 "CR", "CU", "DO", "EC", "FM", "GT", "GU", "GY", "HN", "HT", "JP", | 125 "CR", "CU", "DO", "EC", "FM", "GT", "GU", "GY", "HN", "HT", "JP", |
101 "KN", "KR", "KY", "MS", "MX", "NI", "PA", "PE", "PF", "PH", "PR", | 126 "KN", "KR", "KY", "MS", "MX", "NI", "PA", "PE", "PF", "PH", "PR", |
102 "PW", "SA", "SR", "SV", "TT", "TW", "UM", "US", "VG", "VI", "VE"}; | 127 "PW", "SA", "SR", "SV", "TT", "TW", "UM", "US", "VG", "VI", "VE"}; |
103 const char** countries_using_60Hz_end = | 128 const char** countries_using_60Hz_end = |
104 countries_using_60Hz + arraysize(countries_using_60Hz); | 129 countries_using_60Hz + arraysize(countries_using_60Hz); |
105 if (std::find(countries_using_60Hz, countries_using_60Hz_end, | 130 if (std::find(countries_using_60Hz, countries_using_60Hz_end, |
106 current_country) == countries_using_60Hz_end) { | 131 current_country) == countries_using_60Hz_end) { |
107 return kPowerLine50Hz; | 132 return kPowerLine50Hz; |
108 } | 133 } |
109 return kPowerLine60Hz; | 134 return kPowerLine60Hz; |
110 } | 135 } |
111 | 136 |
112 } // namespace media | 137 } // namespace media |
OLD | NEW |