| 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 VideoCaptureApiType = media::VideoCaptureApiType; |
| 120 typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string> | 123 typedef std::map<VideoCaptureApiType, std::string> CaptureApiTypeStringMap; |
| 121 CaptureApiTypeStringMap; | |
| 122 CaptureApiTypeStringMap m; | 124 CaptureApiTypeStringMap m; |
| 123 #if defined(OS_LINUX) | 125 m[VideoCaptureApiType::LINUX_V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; |
| 124 m[VideoCaptureDeviceName::V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; | 126 m[VideoCaptureApiType::WINDOWS_MEDIA_FOUNDATION] = "Media Foundation"; |
| 125 #elif defined(OS_WIN) | 127 m[VideoCaptureApiType::WINDOWS_DIRECT_SHOW] = "Direct Show"; |
| 126 m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "Media Foundation"; | 128 m[VideoCaptureApiType::MACOSX_AVFOUNDATION] = "AV Foundation"; |
| 127 m[VideoCaptureDeviceName::DIRECT_SHOW] = "Direct Show"; | 129 m[VideoCaptureApiType::MACOSX_DECKLINK] = "DeckLink"; |
| 128 #elif defined(OS_MACOSX) | 130 m[VideoCaptureApiType::ANDROID_API1] = "Camera API1"; |
| 129 m[VideoCaptureDeviceName::AVFOUNDATION] = "AV Foundation"; | 131 m[VideoCaptureApiType::ANDROID_API2_LEGACY] = "Camera API2 Legacy"; |
| 130 m[VideoCaptureDeviceName::DECKLINK] = "DeckLink"; | 132 m[VideoCaptureApiType::ANDROID_API2_FULL] = "Camera API2 Full"; |
| 131 #elif defined(OS_ANDROID) | 133 m[VideoCaptureApiType::ANDROID_API2_LIMITED] = "Camera API2 Limited"; |
| 132 m[VideoCaptureDeviceName::API1] = "Camera API1"; | 134 m[VideoCaptureApiType::ANDROID_TANGO] = "Tango API"; |
| 133 m[VideoCaptureDeviceName::API2_LEGACY] = "Camera API2 Legacy"; | 135 EXPECT_EQ(static_cast<size_t>(VideoCaptureApiType::API_TYPE_UNKNOWN), |
| 134 m[VideoCaptureDeviceName::API2_FULL] = "Camera API2 Full"; | 136 m.size()); |
| 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) { | 137 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) { |
| 140 const VideoCaptureDeviceName device_name("dummy", "dummy", it->first); | 138 media::VideoCaptureDeviceDescriptor descriptor; |
| 141 EXPECT_EQ(it->second, device_name.GetCaptureApiTypeString()); | 139 descriptor.capture_api = it->first; |
| 140 EXPECT_EQ(it->second, descriptor.GetCaptureApiTypeString()); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 #endif | 143 #endif |
| 145 | 144 |
| 146 TEST_F(MediaInternalsVideoCaptureDeviceTest, | 145 TEST_F(MediaInternalsVideoCaptureDeviceTest, |
| 147 VideoCaptureFormatStringIsInExpectedFormat) { | 146 VideoCaptureFormatStringIsInExpectedFormat) { |
| 148 // Since media internals will send video capture capabilities to JavaScript in | 147 // Since media internals will send video capture capabilities to JavaScript in |
| 149 // an expected format and there are no public methods for accessing the | 148 // 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 | 149 // 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 | 150 // has not changed. If the test fails because of the changed format, it should |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { | 169 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { |
| 171 const int kWidth = 1280; | 170 const int kWidth = 1280; |
| 172 const int kHeight = 720; | 171 const int kHeight = 720; |
| 173 const float kFrameRate = 30.0f; | 172 const float kFrameRate = 30.0f; |
| 174 const media::VideoPixelFormat kPixelFormat = | 173 const media::VideoPixelFormat kPixelFormat = |
| 175 media::PIXEL_FORMAT_I420; | 174 media::PIXEL_FORMAT_I420; |
| 176 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, | 175 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, |
| 177 kFrameRate, kPixelFormat); | 176 kFrameRate, kPixelFormat); |
| 178 media::VideoCaptureFormats formats{}; | 177 media::VideoCaptureFormats formats{}; |
| 179 formats.push_back(format_hd); | 178 formats.push_back(format_hd); |
| 180 const media::VideoCaptureDeviceInfo device_info( | 179 VideoCaptureDeviceInfo device_info; |
| 180 device_info.supported_formats = formats; |
| 181 device_info.descriptor.device_id = "dummy"; |
| 182 device_info.descriptor.friendly_name = "dummy"; |
| 181 #if defined(OS_MACOSX) | 183 #if defined(OS_MACOSX) |
| 182 media::VideoCaptureDevice::Name( | 184 device_info.descriptor.capture_api = |
| 183 "dummy", "dummy", media::VideoCaptureDevice::Name::AVFOUNDATION), | 185 media::VideoCaptureApiType::MACOSX_AVFOUNDATION; |
| 184 #elif defined(OS_WIN) | 186 #elif defined(OS_WIN) |
| 185 media::VideoCaptureDevice::Name("dummy", "dummy", | 187 device_info.descriptor.capture_api = |
| 186 media::VideoCaptureDevice::Name::DIRECT_SHOW), | 188 media::VideoCaptureApiType::WINDOWS_DIRECT_SHOW; |
| 187 #elif defined(OS_LINUX) | 189 #elif defined(OS_LINUX) |
| 188 media::VideoCaptureDevice::Name( | 190 device_info.descriptor.device_id = "/dev/dummy"; |
| 189 "dummy", "/dev/dummy", | 191 device_info.descriptor.capture_api = |
| 190 media::VideoCaptureDevice::Name::V4L2_SINGLE_PLANE), | 192 media::VideoCaptureApiType::LINUX_V4L2_SINGLE_PLANE; |
| 191 #elif defined(OS_ANDROID) | 193 #elif defined(OS_ANDROID) |
| 192 media::VideoCaptureDevice::Name("dummy", "dummy", | 194 device_info.descriptor.capture_api = |
| 193 media::VideoCaptureDevice::Name::API2_LEGACY), | 195 media::VideoCaptureApiType::ANDROID_API2_LEGACY; |
| 194 #else | |
| 195 media::VideoCaptureDevice::Name("dummy", "dummy"), | |
| 196 #endif | 196 #endif |
| 197 formats); | |
| 198 media::VideoCaptureDeviceInfos device_infos{}; | 197 media::VideoCaptureDeviceInfos device_infos{}; |
| 199 device_infos.push_back(device_info); | 198 device_infos.push_back(device_info); |
| 200 | 199 |
| 201 // When updating video capture capabilities, the update will serialize | 200 // When updating video capture capabilities, the update will serialize |
| 202 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will | 201 // 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 | 202 // deserialize the first object in the array. This means we have to have |
| 204 // exactly one device_info in the |device_infos|. | 203 // exactly one device_info in the |device_infos|. |
| 205 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); | 204 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); |
| 206 | 205 |
| 207 #if defined(OS_LINUX) | 206 #if defined(OS_LINUX) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 ExpectStatus("closed"); | 305 ExpectStatus("closed"); |
| 307 } | 306 } |
| 308 | 307 |
| 309 INSTANTIATE_TEST_CASE_P( | 308 INSTANTIATE_TEST_CASE_P( |
| 310 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( | 309 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( |
| 311 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, | 310 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, |
| 312 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, | 311 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, |
| 313 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); | 312 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); |
| 314 | 313 |
| 315 } // namespace content | 314 } // namespace content |
| OLD | NEW |