OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/blink/webmediacapabilitiesclient_impl.h" | 5 #include "media/blink/webmediacapabilitiesclient_impl.h" |
6 | 6 |
| 7 #include "media/base/mime_util.h" |
| 8 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebAudio
Configuration.h" |
7 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia
CapabilitiesInfo.h" | 9 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia
CapabilitiesInfo.h" |
| 10 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia
Configuration.h" |
| 11 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebVideo
Configuration.h" |
8 | 12 |
9 namespace media { | 13 namespace media { |
10 | 14 |
11 WebMediaCapabilitiesClientImpl::WebMediaCapabilitiesClientImpl() = default; | 15 WebMediaCapabilitiesClientImpl::WebMediaCapabilitiesClientImpl() = default; |
12 | 16 |
13 WebMediaCapabilitiesClientImpl::~WebMediaCapabilitiesClientImpl() = default; | 17 WebMediaCapabilitiesClientImpl::~WebMediaCapabilitiesClientImpl() = default; |
14 | 18 |
15 void WebMediaCapabilitiesClientImpl::DecodingInfo( | 19 void WebMediaCapabilitiesClientImpl::DecodingInfo( |
16 const blink::WebMediaConfiguration& configuration, | 20 const blink::WebMediaConfiguration& configuration, |
17 std::unique_ptr<blink::WebMediaCapabilitiesQueryCallbacks> callbacks) { | 21 std::unique_ptr<blink::WebMediaCapabilitiesQueryCallbacks> callbacks) { |
18 // TODO(chcunningham, mlamouri): this is a dummy implementation that returns | |
19 // true for all the fields. | |
20 std::unique_ptr<blink::WebMediaCapabilitiesInfo> info( | 22 std::unique_ptr<blink::WebMediaCapabilitiesInfo> info( |
21 new blink::WebMediaCapabilitiesInfo()); | 23 new blink::WebMediaCapabilitiesInfo()); |
22 info->supported = true; | 24 |
23 info->smooth = true; | 25 SupportsType audio_support = IsSupported; |
24 info->power_efficient = true; | 26 SupportsType video_support = IsSupported; |
| 27 |
| 28 if (configuration.audio_configuration) { |
| 29 const blink::WebAudioConfiguration& audio_config = |
| 30 configuration.audio_configuration.value(); |
| 31 std::vector<std::string> codec_vector; |
| 32 SplitCodecsToVector(audio_config.codec.Ascii(), &codec_vector, false); |
| 33 |
| 34 // TODO(chcunningham): Update to throw exception pending outcome of |
| 35 // https://github.com/WICG/media-capabilities/issues/32 |
| 36 DCHECK_LE(codec_vector.size(), 1U); |
| 37 |
| 38 audio_support = |
| 39 IsSupportedMediaFormat(audio_config.mime_type.Ascii(), codec_vector); |
| 40 } |
| 41 |
| 42 if (configuration.video_configuration) { |
| 43 const blink::WebVideoConfiguration& video_config = |
| 44 configuration.video_configuration.value(); |
| 45 std::vector<std::string> codec_vector; |
| 46 SplitCodecsToVector(video_config.codec.Ascii(), &codec_vector, false); |
| 47 |
| 48 // TODO(chcunningham): Update to throw exception pending outcome of |
| 49 // https://github.com/WICG/media-capabilities/issues/32 |
| 50 DCHECK_LE(codec_vector.size(), 1U); |
| 51 |
| 52 video_support = |
| 53 IsSupportedMediaFormat(video_config.mime_type.Ascii(), codec_vector); |
| 54 } |
| 55 |
| 56 // TODO(chcunningham): API should never have to mask uncertainty. Log a metric |
| 57 // for any content type that is "maybe" supported. |
| 58 if (video_support == MayBeSupported) |
| 59 video_support = IsSupported; |
| 60 if (audio_support == MayBeSupported) |
| 61 audio_support = IsSupported; |
| 62 |
| 63 info->supported = |
| 64 audio_support == IsSupported && video_support == IsSupported; |
| 65 |
| 66 // TODO(chcunningham, mlamouri): real implementation for these. |
| 67 info->smooth = info->power_efficient = info->supported; |
| 68 |
25 callbacks->OnSuccess(std::move(info)); | 69 callbacks->OnSuccess(std::move(info)); |
26 } | 70 } |
27 | 71 |
28 } // namespace media | 72 } // namespace media |
OLD | NEW |