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" | |
9 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia Configuration.h" | |
7 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia DecodingAbility.h" | 10 #include "third_party/WebKit/public/platform/modules/media_capabilities/WebMedia DecodingAbility.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::query( | 19 void WebMediaCapabilitiesClientImpl::query( |
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::WebMediaDecodingAbility> ability( | 22 std::unique_ptr<blink::WebMediaDecodingAbility> ability( |
21 new blink::WebMediaDecodingAbility()); | 23 new blink::WebMediaDecodingAbility()); |
22 ability->supported = true; | 24 |
23 ability->smooth = true; | 25 SupportsType audio_support = IsSupported; |
24 ability->powerEfficient = true; | 26 SupportsType video_support = IsSupported; |
27 | |
28 if (configuration.audioConfiguration.has_value()) { | |
29 const blink::WebAudioConfiguration& audio_config = | |
30 configuration.audioConfiguration.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_EQ(codec_vector.size(), 1U); | |
mlamouri (slow - plz ping)
2017/04/10 12:31:50
Maybe we should do this check on the Blink side by
chcunningham
2017/04/20 21:48:10
I think we should do this check in blink, but we c
| |
37 | |
38 audio_support = | |
39 IsSupportedMediaFormat(audio_config.mimeType.ascii(), codec_vector); | |
40 } | |
41 | |
42 if (configuration.videoConfiguration.has_value()) { | |
43 const blink::WebVideoConfiguration& video_config = | |
44 configuration.videoConfiguration.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_EQ(codec_vector.size(), 1U); | |
51 | |
52 video_support = | |
53 IsSupportedMediaFormat(video_config.mimeType.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 ability->supported = audio_support == video_support == IsSupported; | |
64 | |
65 if (ability->supported) { | |
66 // TODO(chcunningham, mlamouri): real implementation for these. | |
67 ability->smooth = true; | |
68 ability->powerEfficient = true; | |
69 } else { | |
70 ability->smooth = false; | |
71 ability->powerEfficient = false; | |
72 } | |
73 | |
25 callbacks->onSuccess(std::move(ability)); | 74 callbacks->onSuccess(std::move(ability)); |
26 } | 75 } |
27 | 76 |
28 } // namespace media | 77 } // namespace media |
OLD | NEW |