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/video/capture/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 (EndsWith(device_name_
, suffix
, true)) // |true| means case-sensitive.
19 return device_name_
+ suffix
;
22 VideoCaptureDevice::Name::Name() {}
24 VideoCaptureDevice::Name::Name(const std::string
& name
, const std::string
& id
)
25 : device_name_(name
), unique_id_(id
) {}
28 VideoCaptureDevice::Name::Name(const std::string
& name
,
29 const std::string
& id
,
30 const CaptureApiType api_type
)
33 capture_api_class_(api_type
),
34 capabilities_id_(id
) {}
37 #if defined(OS_MACOSX)
38 VideoCaptureDevice::Name::Name(const std::string
& name
,
39 const std::string
& id
,
40 const CaptureApiType api_type
)
43 capture_api_class_(api_type
),
44 transport_type_(OTHER_TRANSPORT
),
45 is_blacklisted_(false) {}
47 VideoCaptureDevice::Name::Name(const std::string
& name
,
48 const std::string
& id
,
49 const CaptureApiType api_type
,
50 const TransportType transport_type
)
53 capture_api_class_(api_type
),
54 transport_type_(transport_type
),
55 is_blacklisted_(false) {}
58 VideoCaptureDevice::Name::~Name() {}
61 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
62 switch(capture_api_type()) {
63 case MEDIA_FOUNDATION
:
64 return "Media Foundation";
67 case DIRECT_SHOW_WDM_CROSSBAR
:
68 return "Direct Show WDM Crossbar";
70 NOTREACHED() << "Unknown Video Capture API type!";
74 #elif defined(OS_MACOSX)
75 const char* VideoCaptureDevice::Name::GetCaptureApiTypeString() const {
76 switch(capture_api_type()) {
78 return "AV Foundation";
84 NOTREACHED() << "Unknown Video Capture API type!";
90 VideoCaptureDevice::~VideoCaptureDevice() {}
92 int VideoCaptureDevice::GetPowerLineFrequencyForLocation() const {
93 std::string current_country
= base::CountryCodeForCurrentTimezone();
94 if (current_country
.empty())
96 // Sorted out list of countries with 60Hz power line frequency, from
97 // http://en.wikipedia.org/wiki/Mains_electricity_by_country
98 const char* countries_using_60Hz
[] = {
99 "AI", "AO", "AS", "AW", "AZ", "BM", "BR", "BS", "BZ", "CA", "CO",
100 "CR", "CU", "DO", "EC", "FM", "GT", "GU", "GY", "HN", "HT", "JP",
101 "KN", "KR", "KY", "MS", "MX", "NI", "PA", "PE", "PF", "PH", "PR",
102 "PW", "SA", "SR", "SV", "TT", "TW", "UM", "US", "VG", "VI", "VE"};
103 const char** countries_using_60Hz_end
=
104 countries_using_60Hz
+ arraysize(countries_using_60Hz
);
105 if (std::find(countries_using_60Hz
, countries_using_60Hz_end
,
106 current_country
) == countries_using_60Hz_end
) {
107 return kPowerLine50Hz
;
109 return kPowerLine60Hz
;
112 bool VideoCaptureDevice::InitializeImageCapture(
113 const ImageCaptureFormat
& image_format
,
114 scoped_ptr
<ImageClient
> client
) {