Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: media/blink/webmediacapabilitiesclient_impl.cc

Issue 2805553004: Wire up MediaCapabilities is_supported to MimeUtil (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/media_capabilities/MediaCapabilities.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediacapabilitiesclient_impl.cc
diff --git a/media/blink/webmediacapabilitiesclient_impl.cc b/media/blink/webmediacapabilitiesclient_impl.cc
index 7bd0fdb5bbab17f34e85b1d7cb28e7e292421142..f361b121c0d5db71c090f9cf3e6cc6343ba4dc6e 100644
--- a/media/blink/webmediacapabilitiesclient_impl.cc
+++ b/media/blink/webmediacapabilitiesclient_impl.cc
@@ -4,7 +4,11 @@
#include "media/blink/webmediacapabilitiesclient_impl.h"
+#include "media/base/mime_util.h"
+#include "third_party/WebKit/public/platform/modules/media_capabilities/WebAudioConfiguration.h"
+#include "third_party/WebKit/public/platform/modules/media_capabilities/WebMediaConfiguration.h"
#include "third_party/WebKit/public/platform/modules/media_capabilities/WebMediaDecodingAbility.h"
+#include "third_party/WebKit/public/platform/modules/media_capabilities/WebVideoConfiguration.h"
namespace media {
@@ -15,13 +19,58 @@ WebMediaCapabilitiesClientImpl::~WebMediaCapabilitiesClientImpl() = default;
void WebMediaCapabilitiesClientImpl::query(
const blink::WebMediaConfiguration& configuration,
std::unique_ptr<blink::WebMediaCapabilitiesQueryCallbacks> callbacks) {
- // TODO(chcunningham, mlamouri): this is a dummy implementation that returns
- // true for all the fields.
std::unique_ptr<blink::WebMediaDecodingAbility> ability(
new blink::WebMediaDecodingAbility());
- ability->supported = true;
- ability->smooth = true;
- ability->powerEfficient = true;
+
+ SupportsType audio_support = IsSupported;
+ SupportsType video_support = IsSupported;
+
+ if (configuration.audioConfiguration.has_value()) {
+ const blink::WebAudioConfiguration& audio_config =
+ configuration.audioConfiguration.value();
+ std::vector<std::string> codec_vector;
+ SplitCodecsToVector(audio_config.codec.ascii(), &codec_vector, false);
+
+ // TODO(chcunningham): Update to throw exception pending outcome of
+ // https://github.com/WICG/media-capabilities/issues/32
+ 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
+
+ audio_support =
+ IsSupportedMediaFormat(audio_config.mimeType.ascii(), codec_vector);
+ }
+
+ if (configuration.videoConfiguration.has_value()) {
+ const blink::WebVideoConfiguration& video_config =
+ configuration.videoConfiguration.value();
+ std::vector<std::string> codec_vector;
+ SplitCodecsToVector(video_config.codec.ascii(), &codec_vector, false);
+
+ // TODO(chcunningham): Update to throw exception pending outcome of
+ // https://github.com/WICG/media-capabilities/issues/32
+ DCHECK_EQ(codec_vector.size(), 1U);
+
+ video_support =
+ IsSupportedMediaFormat(video_config.mimeType.ascii(), codec_vector);
+ }
+
+ // TODO(chcunningham): API should never have to mask uncertainty. Log a metric
+ // for any content type that is "maybe" supported.
+ if (video_support == MayBeSupported)
+ video_support = IsSupported;
+ if (audio_support == MayBeSupported)
+ audio_support = IsSupported;
+
+ ability->supported = audio_support == video_support == IsSupported;
+
+ if (ability->supported) {
+ // TODO(chcunningham, mlamouri): real implementation for these.
+ ability->smooth = true;
+ ability->powerEfficient = true;
+ } else {
+ ability->smooth = false;
+ ability->powerEfficient = false;
+ }
+
callbacks->onSuccess(std::move(ability));
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/media_capabilities/MediaCapabilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698