Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 105 } |
| 106 | 106 |
| 107 ~MediaInternalsVideoCaptureDeviceTest() override { | 107 ~MediaInternalsVideoCaptureDeviceTest() override { |
| 108 media_internals_->RemoveUpdateCallback(update_cb_); | 108 media_internals_->RemoveUpdateCallback(update_cb_); |
| 109 } | 109 } |
| 110 | 110 |
| 111 protected: | 111 protected: |
| 112 MediaInternals::UpdateCallback update_cb_; | 112 MediaInternals::UpdateCallback update_cb_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // TODO(chfremer): Consider removing this. This test seem be | |
| 116 // a duplicate implementation of the functionality under test. | |
| 117 // https://crbug.com/630694 | |
| 115 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ | 118 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ |
| 116 defined(OS_ANDROID) | 119 defined(OS_ANDROID) |
| 117 TEST_F(MediaInternalsVideoCaptureDeviceTest, | 120 TEST_F(MediaInternalsVideoCaptureDeviceTest, |
| 118 AllCaptureApiTypesHaveProperStringRepresentation) { | 121 AllCaptureApiTypesHaveProperStringRepresentation) { |
| 119 typedef media::VideoCaptureDevice::Name VideoCaptureDeviceName; | 122 using VideoCaptureApi = media::VideoCaptureApi; |
| 120 typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string> | 123 typedef std::map<VideoCaptureApi, std::string> CaptureApiTypeStringMap; |
| 121 CaptureApiTypeStringMap; | |
| 122 CaptureApiTypeStringMap m; | 124 CaptureApiTypeStringMap m; |
| 123 #if defined(OS_LINUX) | 125 m[VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; |
| 124 m[VideoCaptureDeviceName::V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; | 126 m[VideoCaptureApi::WINDOWS_MEDIA_FOUNDATION] = "Media Foundation"; |
| 125 #elif defined(OS_WIN) | 127 m[VideoCaptureApi::WINDOWS_DIRECT_SHOW] = "Direct Show"; |
| 126 m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "Media Foundation"; | 128 m[VideoCaptureApi::MACOSX_AVFOUNDATION] = "AV Foundation"; |
| 127 m[VideoCaptureDeviceName::DIRECT_SHOW] = "Direct Show"; | 129 m[VideoCaptureApi::MACOSX_DECKLINK] = "DeckLink"; |
| 128 #elif defined(OS_MACOSX) | 130 m[VideoCaptureApi::ANDROID_API1] = "Camera API1"; |
| 129 m[VideoCaptureDeviceName::AVFOUNDATION] = "AV Foundation"; | 131 m[VideoCaptureApi::ANDROID_API2_LEGACY] = "Camera API2 Legacy"; |
| 130 m[VideoCaptureDeviceName::DECKLINK] = "DeckLink"; | 132 m[VideoCaptureApi::ANDROID_API2_FULL] = "Camera API2 Full"; |
| 131 #elif defined(OS_ANDROID) | 133 m[VideoCaptureApi::ANDROID_API2_LIMITED] = "Camera API2 Limited"; |
| 132 m[VideoCaptureDeviceName::API1] = "Camera API1"; | 134 m[VideoCaptureApi::ANDROID_TANGO] = "Tango API"; |
| 133 m[VideoCaptureDeviceName::API2_LEGACY] = "Camera API2 Legacy"; | 135 EXPECT_EQ(static_cast<size_t>(VideoCaptureApi::UNKNOWN), m.size()); |
| 134 m[VideoCaptureDeviceName::API2_FULL] = "Camera API2 Full"; | |
| 135 m[VideoCaptureDeviceName::API2_LIMITED] = "Camera API2 Limited"; | |
| 136 m[VideoCaptureDeviceName::TANGO] = "Tango API"; | |
| 137 #endif | |
| 138 EXPECT_EQ(media::VideoCaptureDevice::Name::API_TYPE_UNKNOWN, m.size()); | |
| 139 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) { | 136 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) { |
|
mcasas
2016/07/30 00:06:11
nit: for (const auto& capture_api : m) ...
chfremer
2016/08/01 18:53:12
Done.
| |
| 140 const VideoCaptureDeviceName device_name("dummy", "dummy", it->first); | 137 media::VideoCaptureDeviceDescriptor descriptor; |
| 141 EXPECT_EQ(it->second, device_name.GetCaptureApiTypeString()); | 138 descriptor.capture_api = it->first; |
| 139 EXPECT_EQ(it->second, descriptor.GetCaptureApiTypeString()); | |
|
mcasas
2016/07/30 00:06:11
EXPECT_STREQ ...?
chfremer
2016/08/01 18:53:12
Done.
| |
| 142 } | 140 } |
| 143 } | 141 } |
| 144 #endif | 142 #endif |
| 145 | 143 |
| 146 TEST_F(MediaInternalsVideoCaptureDeviceTest, | 144 TEST_F(MediaInternalsVideoCaptureDeviceTest, |
| 147 VideoCaptureFormatStringIsInExpectedFormat) { | 145 VideoCaptureFormatStringIsInExpectedFormat) { |
| 148 // Since media internals will send video capture capabilities to JavaScript in | 146 // Since media internals will send video capture capabilities to JavaScript in |
| 149 // an expected format and there are no public methods for accessing the | 147 // an expected format and there are no public methods for accessing the |
| 150 // resolutions, frame rates or pixel formats, this test checks that the format | 148 // resolutions, frame rates or pixel formats, this test checks that the format |
| 151 // has not changed. If the test fails because of the changed format, it should | 149 // has not changed. If the test fails because of the changed format, it should |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 170 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { | 168 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { |
| 171 const int kWidth = 1280; | 169 const int kWidth = 1280; |
| 172 const int kHeight = 720; | 170 const int kHeight = 720; |
| 173 const float kFrameRate = 30.0f; | 171 const float kFrameRate = 30.0f; |
| 174 const media::VideoPixelFormat kPixelFormat = | 172 const media::VideoPixelFormat kPixelFormat = |
| 175 media::PIXEL_FORMAT_I420; | 173 media::PIXEL_FORMAT_I420; |
| 176 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, | 174 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, |
| 177 kFrameRate, kPixelFormat); | 175 kFrameRate, kPixelFormat); |
| 178 media::VideoCaptureFormats formats{}; | 176 media::VideoCaptureFormats formats{}; |
| 179 formats.push_back(format_hd); | 177 formats.push_back(format_hd); |
| 180 const media::VideoCaptureDeviceInfo device_info( | 178 VideoCaptureDeviceInfo device_info; |
| 179 device_info.supported_formats = formats; | |
| 180 device_info.descriptor.device_id = "dummy"; | |
| 181 device_info.descriptor.display_name = "dummy"; | |
| 181 #if defined(OS_MACOSX) | 182 #if defined(OS_MACOSX) |
| 182 media::VideoCaptureDevice::Name( | 183 device_info.descriptor.capture_api = |
| 183 "dummy", "dummy", media::VideoCaptureDevice::Name::AVFOUNDATION), | 184 media::VideoCaptureApi::MACOSX_AVFOUNDATION; |
| 184 #elif defined(OS_WIN) | 185 #elif defined(OS_WIN) |
| 185 media::VideoCaptureDevice::Name("dummy", "dummy", | 186 device_info.descriptor.capture_api = |
| 186 media::VideoCaptureDevice::Name::DIRECT_SHOW), | 187 media::VideoCaptureApi::WINDOWS_DIRECT_SHOW; |
| 187 #elif defined(OS_LINUX) | 188 #elif defined(OS_LINUX) |
| 188 media::VideoCaptureDevice::Name( | 189 device_info.descriptor.device_id = "/dev/dummy"; |
| 189 "dummy", "/dev/dummy", | 190 device_info.descriptor.capture_api = |
| 190 media::VideoCaptureDevice::Name::V4L2_SINGLE_PLANE), | 191 media::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE; |
| 191 #elif defined(OS_ANDROID) | 192 #elif defined(OS_ANDROID) |
| 192 media::VideoCaptureDevice::Name("dummy", "dummy", | 193 device_info.descriptor.capture_api = |
| 193 media::VideoCaptureDevice::Name::API2_LEGACY), | 194 media::VideoCaptureApi::ANDROID_API2_LEGACY; |
| 194 #else | |
| 195 media::VideoCaptureDevice::Name("dummy", "dummy"), | |
| 196 #endif | 195 #endif |
| 197 formats); | 196 VideoCaptureDeviceInfos device_infos{}; |
| 198 media::VideoCaptureDeviceInfos device_infos{}; | |
| 199 device_infos.push_back(device_info); | 197 device_infos.push_back(device_info); |
| 200 | 198 |
| 201 // When updating video capture capabilities, the update will serialize | 199 // When updating video capture capabilities, the update will serialize |
| 202 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will | 200 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will |
| 203 // deserialize the first object in the array. This means we have to have | 201 // deserialize the first object in the array. This means we have to have |
| 204 // exactly one device_info in the |device_infos|. | 202 // exactly one device_info in the |device_infos|. |
| 205 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); | 203 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); |
| 206 | 204 |
| 207 #if defined(OS_LINUX) | 205 #if defined(OS_LINUX) |
| 208 ExpectString("id", "/dev/dummy"); | 206 ExpectString("id", "/dev/dummy"); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 ExpectStatus("closed"); | 304 ExpectStatus("closed"); |
| 307 } | 305 } |
| 308 | 306 |
| 309 INSTANTIATE_TEST_CASE_P( | 307 INSTANTIATE_TEST_CASE_P( |
| 310 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( | 308 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( |
| 311 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, | 309 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, |
| 312 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, | 310 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, |
| 313 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); | 311 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); |
| 314 | 312 |
| 315 } // namespace content | 313 } // namespace content |
| OLD | NEW |