| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "content/public/renderer/content_renderer_client.h" | 9 #include "content/public/renderer/content_renderer_client.h" |
| 10 #include "content/renderer/media/render_media_client.h" | 10 #include "content/renderer/media/render_media_client.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 EXPECT_TRUE(ContainsWidevine(key_systems_properties)); | 174 EXPECT_TRUE(ContainsWidevine(key_systems_properties)); |
| 175 | 175 |
| 176 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); | 176 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); |
| 177 tick_clock->Advance(base::TimeDelta::FromMilliseconds(1000)); | 177 tick_clock->Advance(base::TimeDelta::FromMilliseconds(1000)); |
| 178 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); | 178 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); |
| 179 tick_clock->Advance(base::TimeDelta::FromMilliseconds(1000)); | 179 tick_clock->Advance(base::TimeDelta::FromMilliseconds(1000)); |
| 180 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); | 180 EXPECT_FALSE(render_media_client_->IsKeySystemsUpdateNeeded()); |
| 181 #endif | 181 #endif |
| 182 } | 182 } |
| 183 | 183 |
| 184 TEST_F(RenderMediaClientTest, IsSupportedVideoConfigBasics) { | |
| 185 // Default to common 709. | |
| 186 const media::VideoColorSpace kColorSpace = media::VideoColorSpace::BT709(); | |
| 187 | |
| 188 // Some codecs do not have a notion of level. | |
| 189 const int kUnspecifiedLevel = 0; | |
| 190 | |
| 191 // Expect support for baseline configuration of known codecs. | |
| 192 EXPECT_TRUE(render_media_client_->IsSupportedVideoConfig( | |
| 193 {media::kCodecH264, media::H264PROFILE_BASELINE, 1, kColorSpace})); | |
| 194 EXPECT_TRUE(render_media_client_->IsSupportedVideoConfig( | |
| 195 {media::kCodecVP8, media::VP8PROFILE_ANY, kUnspecifiedLevel, | |
| 196 kColorSpace})); | |
| 197 EXPECT_TRUE(render_media_client_->IsSupportedVideoConfig( | |
| 198 {media::kCodecVP9, media::VP9PROFILE_PROFILE0, kUnspecifiedLevel, | |
| 199 kColorSpace})); | |
| 200 EXPECT_TRUE(render_media_client_->IsSupportedVideoConfig( | |
| 201 {media::kCodecTheora, media::VIDEO_CODEC_PROFILE_UNKNOWN, | |
| 202 kUnspecifiedLevel, kColorSpace})); | |
| 203 | |
| 204 // Expect non-support for the following. | |
| 205 EXPECT_FALSE(render_media_client_->IsSupportedVideoConfig( | |
| 206 {media::kUnknownVideoCodec, media::VIDEO_CODEC_PROFILE_UNKNOWN, | |
| 207 kUnspecifiedLevel, kColorSpace})); | |
| 208 EXPECT_FALSE(render_media_client_->IsSupportedVideoConfig( | |
| 209 {media::kCodecVC1, media::VIDEO_CODEC_PROFILE_UNKNOWN, kUnspecifiedLevel, | |
| 210 kColorSpace})); | |
| 211 EXPECT_FALSE(render_media_client_->IsSupportedVideoConfig( | |
| 212 {media::kCodecMPEG2, media::VIDEO_CODEC_PROFILE_UNKNOWN, | |
| 213 kUnspecifiedLevel, kColorSpace})); | |
| 214 EXPECT_FALSE(render_media_client_->IsSupportedVideoConfig( | |
| 215 {media::kCodecMPEG4, media::VIDEO_CODEC_PROFILE_UNKNOWN, | |
| 216 kUnspecifiedLevel, kColorSpace})); | |
| 217 EXPECT_FALSE(render_media_client_->IsSupportedVideoConfig( | |
| 218 {media::kCodecHEVC, media::VIDEO_CODEC_PROFILE_UNKNOWN, kUnspecifiedLevel, | |
| 219 kColorSpace})); | |
| 220 } | |
| 221 | |
| 222 TEST_F(RenderMediaClientTest, IsSupportedVideoConfig_VP9TransferFunctions) { | |
| 223 size_t num_found = 0; | |
| 224 // TODO(hubbe): Verify support for HDR codecs when color management enabled. | |
| 225 const std::set<media::VideoColorSpace::TransferID> kSupportedTransfers = { | |
| 226 media::VideoColorSpace::TransferID::GAMMA22, | |
| 227 media::VideoColorSpace::TransferID::UNSPECIFIED, | |
| 228 media::VideoColorSpace::TransferID::BT709, | |
| 229 media::VideoColorSpace::TransferID::SMPTE170M, | |
| 230 media::VideoColorSpace::TransferID::BT2020_10, | |
| 231 media::VideoColorSpace::TransferID::BT2020_12, | |
| 232 media::VideoColorSpace::TransferID::IEC61966_2_1, | |
| 233 }; | |
| 234 | |
| 235 for (int i = 0; i <= (1 << (8 * sizeof(media::VideoColorSpace::TransferID))); | |
| 236 i++) { | |
| 237 media::VideoColorSpace color_space = media::VideoColorSpace::BT709(); | |
| 238 color_space.transfer = media::VideoColorSpace::GetTransferID(i); | |
| 239 bool found = kSupportedTransfers.find(color_space.transfer) != | |
| 240 kSupportedTransfers.end(); | |
| 241 if (found) | |
| 242 num_found++; | |
| 243 EXPECT_EQ(found, render_media_client_->IsSupportedVideoConfig( | |
| 244 {media::kCodecVP9, media::VP9PROFILE_PROFILE0, 1, | |
| 245 color_space})); | |
| 246 } | |
| 247 EXPECT_EQ(kSupportedTransfers.size(), num_found); | |
| 248 } | |
| 249 | |
| 250 TEST_F(RenderMediaClientTest, IsSupportedVideoConfig_VP9Primaries) { | |
| 251 size_t num_found = 0; | |
| 252 // TODO(hubbe): Verify support for HDR codecs when color management enabled. | |
| 253 const std::set<media::VideoColorSpace::PrimaryID> kSupportedPrimaries = { | |
| 254 media::VideoColorSpace::PrimaryID::BT709, | |
| 255 media::VideoColorSpace::PrimaryID::UNSPECIFIED, | |
| 256 media::VideoColorSpace::PrimaryID::BT470M, | |
| 257 media::VideoColorSpace::PrimaryID::BT470BG, | |
| 258 media::VideoColorSpace::PrimaryID::SMPTE170M, | |
| 259 }; | |
| 260 | |
| 261 for (int i = 0; i <= (1 << (8 * sizeof(media::VideoColorSpace::PrimaryID))); | |
| 262 i++) { | |
| 263 media::VideoColorSpace color_space = media::VideoColorSpace::BT709(); | |
| 264 color_space.primaries = media::VideoColorSpace::GetPrimaryID(i); | |
| 265 bool found = kSupportedPrimaries.find(color_space.primaries) != | |
| 266 kSupportedPrimaries.end(); | |
| 267 if (found) | |
| 268 num_found++; | |
| 269 EXPECT_EQ(found, render_media_client_->IsSupportedVideoConfig( | |
| 270 {media::kCodecVP9, media::VP9PROFILE_PROFILE0, 1, | |
| 271 color_space})); | |
| 272 } | |
| 273 EXPECT_EQ(kSupportedPrimaries.size(), num_found); | |
| 274 } | |
| 275 | |
| 276 TEST_F(RenderMediaClientTest, IsSupportedVideoConfig_VP9Matrix) { | |
| 277 size_t num_found = 0; | |
| 278 // TODO(hubbe): Verify support for HDR codecs when color management enabled. | |
| 279 const std::set<media::VideoColorSpace::MatrixID> kSupportedMatrix = { | |
| 280 media::VideoColorSpace::MatrixID::BT709, | |
| 281 media::VideoColorSpace::MatrixID::UNSPECIFIED, | |
| 282 media::VideoColorSpace::MatrixID::BT470BG, | |
| 283 media::VideoColorSpace::MatrixID::SMPTE170M, | |
| 284 media::VideoColorSpace::MatrixID::BT2020_NCL, | |
| 285 }; | |
| 286 | |
| 287 for (int i = 0; i <= (1 << (8 * sizeof(media::VideoColorSpace::MatrixID))); | |
| 288 i++) { | |
| 289 media::VideoColorSpace color_space = media::VideoColorSpace::BT709(); | |
| 290 color_space.matrix = media::VideoColorSpace::GetMatrixID(i); | |
| 291 bool found = | |
| 292 kSupportedMatrix.find(color_space.matrix) != kSupportedMatrix.end(); | |
| 293 if (found) | |
| 294 num_found++; | |
| 295 EXPECT_EQ(found, render_media_client_->IsSupportedVideoConfig( | |
| 296 {media::kCodecVP9, media::VP9PROFILE_PROFILE0, 1, | |
| 297 color_space})); | |
| 298 } | |
| 299 EXPECT_EQ(kSupportedMatrix.size(), num_found); | |
| 300 } | |
| 301 | |
| 302 } // namespace content | 184 } // namespace content |
| OLD | NEW |