| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/media/media_internals.h" | 5 #include "content/browser/media/media_internals.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 ~MediaInternalsVideoCaptureDeviceTest() override { | 104 ~MediaInternalsVideoCaptureDeviceTest() override { |
| 105 media_internals_->RemoveUpdateCallback(update_cb_); | 105 media_internals_->RemoveUpdateCallback(update_cb_); |
| 106 } | 106 } |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 MediaInternals::UpdateCallback update_cb_; | 109 MediaInternals::UpdateCallback update_cb_; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 #if defined(OS_WIN) || defined(OS_MACOSX) | 112 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID) |
| 113 TEST_F(MediaInternalsVideoCaptureDeviceTest, | 113 TEST_F(MediaInternalsVideoCaptureDeviceTest, |
| 114 AllCaptureApiTypesHaveProperStringRepresentation) { | 114 AllCaptureApiTypesHaveProperStringRepresentation) { |
| 115 typedef media::VideoCaptureDevice::Name VideoCaptureDeviceName; | 115 typedef media::VideoCaptureDevice::Name VideoCaptureDeviceName; |
| 116 typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string> | 116 typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string> |
| 117 CaptureApiTypeStringMap; | 117 CaptureApiTypeStringMap; |
| 118 CaptureApiTypeStringMap m; | 118 CaptureApiTypeStringMap m; |
| 119 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
| 120 m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "Media Foundation"; | 120 m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "Media Foundation"; |
| 121 m[VideoCaptureDeviceName::DIRECT_SHOW] = "Direct Show"; | 121 m[VideoCaptureDeviceName::DIRECT_SHOW] = "Direct Show"; |
| 122 m[VideoCaptureDeviceName::DIRECT_SHOW_WDM_CROSSBAR] = | 122 m[VideoCaptureDeviceName::DIRECT_SHOW_WDM_CROSSBAR] = |
| 123 "Direct Show WDM Crossbar"; | 123 "Direct Show WDM Crossbar"; |
| 124 #elif defined(OS_MACOSX) | 124 #elif defined(OS_MACOSX) |
| 125 m[VideoCaptureDeviceName::AVFOUNDATION] = "AV Foundation"; | 125 m[VideoCaptureDeviceName::AVFOUNDATION] = "AV Foundation"; |
| 126 m[VideoCaptureDeviceName::QTKIT] = "QTKit"; | 126 m[VideoCaptureDeviceName::QTKIT] = "QTKit"; |
| 127 m[VideoCaptureDeviceName::DECKLINK] = "DeckLink"; | 127 m[VideoCaptureDeviceName::DECKLINK] = "DeckLink"; |
| 128 #elif defined(OS_ANDROID) |
| 129 m[VideoCaptureDeviceName::API1] = "API1"; |
| 130 m[VideoCaptureDeviceName::API2_LEGACY] = "API2_LEGACY"; |
| 131 m[VideoCaptureDeviceName::API2_FULL] = "API2_FULL"; |
| 132 m[VideoCaptureDeviceName::API2_LIMITED] = "API2_LIMITED"; |
| 133 m[VideoCaptureDeviceName::TANGO] = "TANGO"; |
| 128 #endif | 134 #endif |
| 129 EXPECT_EQ(media::VideoCaptureDevice::Name::API_TYPE_UNKNOWN, m.size()); | 135 EXPECT_EQ(media::VideoCaptureDevice::Name::API_TYPE_UNKNOWN, m.size()); |
| 130 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) { | 136 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) { |
| 131 const VideoCaptureDeviceName device_name("dummy", "dummy", it->first); | 137 const VideoCaptureDeviceName device_name("dummy", "dummy", it->first); |
| 132 EXPECT_EQ(it->second, device_name.GetCaptureApiTypeString()); | 138 EXPECT_EQ(it->second, device_name.GetCaptureApiTypeString()); |
| 133 } | 139 } |
| 134 } | 140 } |
| 135 #endif | 141 #endif |
| 136 | 142 |
| 137 TEST_F(MediaInternalsVideoCaptureDeviceTest, | 143 TEST_F(MediaInternalsVideoCaptureDeviceTest, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 165 kFrameRate, kPixelFormat); | 171 kFrameRate, kPixelFormat); |
| 166 media::VideoCaptureFormats formats{}; | 172 media::VideoCaptureFormats formats{}; |
| 167 formats.push_back(format_hd); | 173 formats.push_back(format_hd); |
| 168 const media::VideoCaptureDeviceInfo device_info( | 174 const media::VideoCaptureDeviceInfo device_info( |
| 169 #if defined(OS_MACOSX) | 175 #if defined(OS_MACOSX) |
| 170 media::VideoCaptureDevice::Name("dummy", "dummy", | 176 media::VideoCaptureDevice::Name("dummy", "dummy", |
| 171 media::VideoCaptureDevice::Name::QTKIT), | 177 media::VideoCaptureDevice::Name::QTKIT), |
| 172 #elif defined(OS_WIN) | 178 #elif defined(OS_WIN) |
| 173 media::VideoCaptureDevice::Name("dummy", "dummy", | 179 media::VideoCaptureDevice::Name("dummy", "dummy", |
| 174 media::VideoCaptureDevice::Name::DIRECT_SHOW), | 180 media::VideoCaptureDevice::Name::DIRECT_SHOW), |
| 181 #elif defined(OS_ANDROID) |
| 182 media::VideoCaptureDevice::Name("dummy", "dummy", |
| 183 media::VideoCaptureDevice::Name::API2_LEGACY), |
| 175 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) | 184 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 176 media::VideoCaptureDevice::Name("dummy", "/dev/dummy"), | 185 media::VideoCaptureDevice::Name("dummy", "/dev/dummy"), |
| 177 #else | 186 #else |
| 178 media::VideoCaptureDevice::Name("dummy", "dummy"), | 187 media::VideoCaptureDevice::Name("dummy", "dummy"), |
| 179 #endif | 188 #endif |
| 180 formats); | 189 formats); |
| 181 media::VideoCaptureDeviceInfos device_infos{}; | 190 media::VideoCaptureDeviceInfos device_infos{}; |
| 182 device_infos.push_back(device_info); | 191 device_infos.push_back(device_info); |
| 183 | 192 |
| 184 // When updating video capture capabilities, the update will serialize | 193 // When updating video capture capabilities, the update will serialize |
| 185 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will | 194 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will |
| 186 // deserialize the first object in the array. This means we have to have | 195 // deserialize the first object in the array. This means we have to have |
| 187 // exactly one device_info in the |device_infos|. | 196 // exactly one device_info in the |device_infos|. |
| 188 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); | 197 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); |
| 189 | 198 |
| 190 #if defined(OS_LINUX) || defined(OS_CHROMEOS) | 199 #if defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 191 ExpectString("id", "/dev/dummy"); | 200 ExpectString("id", "/dev/dummy"); |
| 192 #else | 201 #else |
| 193 ExpectString("id", "dummy"); | 202 ExpectString("id", "dummy"); |
| 194 #endif | 203 #endif |
| 195 ExpectString("name", "dummy"); | 204 ExpectString("name", "dummy"); |
| 196 base::ListValue expected_list; | 205 base::ListValue expected_list; |
| 197 expected_list.AppendString(format_hd.ToString()); | 206 expected_list.AppendString(format_hd.ToString()); |
| 198 ExpectListOfStrings("formats", expected_list); | 207 ExpectListOfStrings("formats", expected_list); |
| 199 #if defined(OS_MACOSX) | 208 #if defined(OS_MACOSX) |
| 200 ExpectString("captureApi", "QTKit"); | 209 ExpectString("captureApi", "QTKit"); |
| 201 #elif defined(OS_WIN) | 210 #elif defined(OS_WIN) |
| 202 ExpectString("captureApi", "Direct Show"); | 211 ExpectString("captureApi", "Direct Show"); |
| 212 #elif defined(OS_ANDROID) |
| 213 ExpectString("captureApi", "API2_LEGACY"); |
| 203 #endif | 214 #endif |
| 204 } | 215 } |
| 205 | 216 |
| 206 class MediaInternalsAudioLogTest | 217 class MediaInternalsAudioLogTest |
| 207 : public MediaInternalsTestBase, | 218 : public MediaInternalsTestBase, |
| 208 public testing::TestWithParam<media::AudioLogFactory::AudioComponent> { | 219 public testing::TestWithParam<media::AudioLogFactory::AudioComponent> { |
| 209 public: | 220 public: |
| 210 MediaInternalsAudioLogTest() : | 221 MediaInternalsAudioLogTest() : |
| 211 update_cb_(base::Bind(&MediaInternalsAudioLogTest::UpdateCallbackImpl, | 222 update_cb_(base::Bind(&MediaInternalsAudioLogTest::UpdateCallbackImpl, |
| 212 base::Unretained(this))), | 223 base::Unretained(this))), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 ExpectStatus("closed"); | 293 ExpectStatus("closed"); |
| 283 } | 294 } |
| 284 | 295 |
| 285 INSTANTIATE_TEST_CASE_P( | 296 INSTANTIATE_TEST_CASE_P( |
| 286 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( | 297 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( |
| 287 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, | 298 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, |
| 288 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, | 299 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, |
| 289 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); | 300 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); |
| 290 | 301 |
| 291 } // namespace content | 302 } // namespace content |
| OLD | NEW |