Commit 36b26b2d authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Media Capabilities: switch MediaCapabilitiesInfo to a dictionary.

This required to create a custom callback class as CallbackPromiseAdapter
does not work well with dictionaries.

This is also updating the media-capabilities.idl file in WPT, based on:
https://raw.githubusercontent.com/tidoust/reffy-reports/master/whatwg/idl/media-capabilities.idl

Bug: 907704
Change-Id: I13bb3c43a7461398f7866f033527bd3ce1bed140
Reviewed-on: https://chromium-review.googlesource.com/c/1347001
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610655}
parent 20930911
...@@ -10,6 +10,7 @@ dictionary MediaConfiguration { ...@@ -10,6 +10,7 @@ dictionary MediaConfiguration {
dictionary MediaDecodingConfiguration : MediaConfiguration { dictionary MediaDecodingConfiguration : MediaConfiguration {
required MediaDecodingType type; required MediaDecodingType type;
MediaCapabilitiesKeySystemConfiguration keySystemConfiguration;
}; };
dictionary MediaEncodingConfiguration : MediaConfiguration { dictionary MediaEncodingConfiguration : MediaConfiguration {
...@@ -41,11 +42,25 @@ dictionary AudioConfiguration { ...@@ -41,11 +42,25 @@ dictionary AudioConfiguration {
unsigned long samplerate; unsigned long samplerate;
}; };
[Exposed=(Window, Worker)] dictionary MediaCapabilitiesKeySystemConfiguration {
interface MediaCapabilitiesInfo { required DOMString keySystem;
readonly attribute boolean supported; DOMString initDataType = "";
readonly attribute boolean smooth; DOMString audioRobustness = "";
readonly attribute boolean powerEfficient; DOMString videoRobustness = "";
MediaKeysRequirement distinctiveIdentifier = "optional";
MediaKeysRequirement persistentState = "optional";
sequence<DOMString> sessionTypes;
};
dictionary MediaCapabilitiesInfo {
required boolean supported;
required boolean smooth;
required boolean powerEfficient;
};
dictionary MediaCapabilitiesDecodingInfo : MediaCapabilitiesInfo {
required MediaKeySystemAccess keySystemAccess;
}; };
[Exposed=Window] [Exposed=Window]
...@@ -60,7 +75,7 @@ partial interface WorkerNavigator { ...@@ -60,7 +75,7 @@ partial interface WorkerNavigator {
[Exposed=(Window, Worker)] [Exposed=(Window, Worker)]
interface MediaCapabilities { interface MediaCapabilities {
[NewObject] Promise<MediaCapabilitiesInfo> decodingInfo(MediaDecodingConfiguration configuration); [NewObject] Promise<MediaCapabilitiesDecodingInfo> decodingInfo(MediaDecodingConfiguration configuration);
[NewObject] Promise<MediaCapabilitiesInfo> encodingInfo(MediaEncodingConfiguration configuration); [NewObject] Promise<MediaCapabilitiesInfo> encodingInfo(MediaEncodingConfiguration configuration);
}; };
......
...@@ -283,9 +283,9 @@ promise_test(t => { ...@@ -283,9 +283,9 @@ promise_test(t => {
video: minimalVideoConfiguration, video: minimalVideoConfiguration,
audio: minimalAudioConfiguration, audio: minimalAudioConfiguration,
}).then(ability => { }).then(ability => {
assert_idl_attribute(ability, 'supported'); assert_equals(typeof ability.supported, "boolean");
assert_idl_attribute(ability, 'smooth'); assert_equals(typeof ability.smooth, "boolean");
assert_idl_attribute(ability, 'powerEfficient'); assert_equals(typeof ability.powerEfficient, "boolean");
}); });
}, "Test that decodingInfo returns a valid MediaCapabilitiesInfo objects"); }, "Test that decodingInfo returns a valid MediaCapabilitiesInfo objects");
......
<!DOCTYPE html> <!DOCTYPE html>
<title>MediaCapabilities.decodingInfo()</title> <title>MediaCapabilities.encodingInfo()</title>
<script src=/resources/testharness.js></script> <script src=/resources/testharness.js></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>
...@@ -283,9 +283,9 @@ promise_test(t => { ...@@ -283,9 +283,9 @@ promise_test(t => {
video: minimalVideoConfiguration, video: minimalVideoConfiguration,
audio: minimalAudioConfiguration, audio: minimalAudioConfiguration,
}).then(ability => { }).then(ability => {
assert_idl_attribute(ability, 'supported'); assert_equals(typeof ability.supported, "boolean");
assert_idl_attribute(ability, 'smooth'); assert_equals(typeof ability.smooth, "boolean");
assert_idl_attribute(ability, 'powerEfficient'); assert_equals(typeof ability.powerEfficient, "boolean");
}); });
}, "Test that encodingInfo returns a valid MediaCapabilitiesInfo objects"); }, "Test that encodingInfo returns a valid MediaCapabilitiesInfo objects");
......
...@@ -16,18 +16,6 @@ FAIL Screen interface: attribute luminance assert_true: The prototype object mus ...@@ -16,18 +16,6 @@ FAIL Screen interface: attribute luminance assert_true: The prototype object mus
PASS Unscopable handled correctly for luminance property on Screen PASS Unscopable handled correctly for luminance property on Screen
FAIL Screen interface: attribute onchange assert_true: The prototype object must have a property "onchange" expected true got false FAIL Screen interface: attribute onchange assert_true: The prototype object must have a property "onchange" expected true got false
PASS Unscopable handled correctly for onchange property on Screen PASS Unscopable handled correctly for onchange property on Screen
PASS MediaCapabilitiesInfo interface: existence and properties of interface object
PASS MediaCapabilitiesInfo interface object length
PASS MediaCapabilitiesInfo interface object name
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object's "constructor" property
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object's @@unscopables property
PASS MediaCapabilitiesInfo interface: attribute supported
PASS Unscopable handled correctly for supported property on MediaCapabilitiesInfo
PASS MediaCapabilitiesInfo interface: attribute smooth
PASS Unscopable handled correctly for smooth property on MediaCapabilitiesInfo
PASS MediaCapabilitiesInfo interface: attribute powerEfficient
PASS Unscopable handled correctly for powerEfficient property on MediaCapabilitiesInfo
PASS MediaCapabilities interface: existence and properties of interface object PASS MediaCapabilities interface: existence and properties of interface object
PASS MediaCapabilities interface object length PASS MediaCapabilities interface object length
PASS MediaCapabilities interface object name PASS MediaCapabilities interface object name
......
This is a testharness.js-based test. This is a testharness.js-based test.
Found 63 tests; 43 PASS, 20 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idlharness PASS idlharness
PASS idl_test setup PASS idl_test setup
PASS Partial interface Navigator: original interface defined PASS Partial interface Navigator: original interface defined
...@@ -7,25 +6,6 @@ PASS Partial interface Navigator: valid exposure set ...@@ -7,25 +6,6 @@ PASS Partial interface Navigator: valid exposure set
PASS Partial interface WorkerNavigator: original interface defined PASS Partial interface WorkerNavigator: original interface defined
PASS Partial interface WorkerNavigator: valid exposure set PASS Partial interface WorkerNavigator: valid exposure set
PASS Partial interface Screen: original interface defined PASS Partial interface Screen: original interface defined
PASS MediaCapabilitiesInfo interface: existence and properties of interface object
PASS MediaCapabilitiesInfo interface object length
PASS MediaCapabilitiesInfo interface object name
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object's "constructor" property
PASS MediaCapabilitiesInfo interface: existence and properties of interface prototype object's @@unscopables property
PASS MediaCapabilitiesInfo interface: attribute supported
PASS MediaCapabilitiesInfo interface: attribute smooth
PASS MediaCapabilitiesInfo interface: attribute powerEfficient
PASS MediaCapabilitiesInfo must be primary interface of decodingInfo
PASS Stringification of decodingInfo
PASS MediaCapabilitiesInfo interface: decodingInfo must inherit property "supported" with the proper type
PASS MediaCapabilitiesInfo interface: decodingInfo must inherit property "smooth" with the proper type
PASS MediaCapabilitiesInfo interface: decodingInfo must inherit property "powerEfficient" with the proper type
PASS MediaCapabilitiesInfo must be primary interface of encodingInfo
PASS Stringification of encodingInfo
PASS MediaCapabilitiesInfo interface: encodingInfo must inherit property "supported" with the proper type
PASS MediaCapabilitiesInfo interface: encodingInfo must inherit property "smooth" with the proper type
PASS MediaCapabilitiesInfo interface: encodingInfo must inherit property "powerEfficient" with the proper type
PASS MediaCapabilities interface: existence and properties of interface object PASS MediaCapabilities interface: existence and properties of interface object
PASS MediaCapabilities interface object length PASS MediaCapabilities interface object length
PASS MediaCapabilities interface object name PASS MediaCapabilities interface object name
......
...@@ -6,26 +6,6 @@ ...@@ -6,26 +6,6 @@
'use strict'; 'use strict';
promise_test(async () => { promise_test(async () => {
try {
const video = {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
};
self.decodingInfo = await navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: video,
});
self.encodingInfo = await navigator.mediaCapabilities.encodingInfo({
type: 'record',
video: video
});
} catch (e) {
// Will be surfaced when encodingInfo/decodingInfo is undefined below.
}
idl_test( idl_test(
['media-capabilities'], ['media-capabilities'],
['html', 'cssom-view'], ['html', 'cssom-view'],
...@@ -37,7 +17,6 @@ promise_test(async () => { ...@@ -37,7 +17,6 @@ promise_test(async () => {
} }
idl_array.add_objects({ idl_array.add_objects({
MediaCapabilities: ['navigator.mediaCapabilities'], MediaCapabilities: ['navigator.mediaCapabilities'],
MediaCapabilitiesInfo: ['decodingInfo', 'encodingInfo'],
Screen: ['screen'], Screen: ['screen'],
ScreenLuminance: ['screen.luminance'], ScreenLuminance: ['screen.luminance'],
}); });
......
This is a testharness.js-based test. This is a testharness.js-based test.
Found 53 tests; 10 PASS, 43 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idlharness PASS idlharness
PASS idl_test setup PASS idl_test setup
PASS Partial interface Navigator: original interface defined PASS Partial interface Navigator: original interface defined
...@@ -7,25 +6,6 @@ PASS Partial interface Navigator: valid exposure set ...@@ -7,25 +6,6 @@ PASS Partial interface Navigator: valid exposure set
PASS Partial interface WorkerNavigator: original interface defined PASS Partial interface WorkerNavigator: original interface defined
PASS Partial interface WorkerNavigator: valid exposure set PASS Partial interface WorkerNavigator: valid exposure set
PASS Partial interface Screen: original interface defined PASS Partial interface Screen: original interface defined
FAIL MediaCapabilitiesInfo interface: existence and properties of interface object assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface object length assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface object name assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: existence and properties of interface prototype object assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: attribute supported assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: attribute smooth assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo interface: attribute powerEfficient assert_own_property: self does not have own property "MediaCapabilitiesInfo" expected property "MediaCapabilitiesInfo" missing
FAIL MediaCapabilitiesInfo must be primary interface of decodingInfo assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: decodingInfo is not defined"
FAIL Stringification of decodingInfo assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: decodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: decodingInfo must inherit property "supported" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: decodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: decodingInfo must inherit property "smooth" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: decodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: decodingInfo must inherit property "powerEfficient" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: decodingInfo is not defined"
FAIL MediaCapabilitiesInfo must be primary interface of encodingInfo assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: encodingInfo is not defined"
FAIL Stringification of encodingInfo assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: encodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: encodingInfo must inherit property "supported" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: encodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: encodingInfo must inherit property "smooth" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: encodingInfo is not defined"
FAIL MediaCapabilitiesInfo interface: encodingInfo must inherit property "powerEfficient" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: encodingInfo is not defined"
FAIL MediaCapabilities interface: existence and properties of interface object assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing FAIL MediaCapabilities interface: existence and properties of interface object assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing
FAIL MediaCapabilities interface object length assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing FAIL MediaCapabilities interface object length assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing
FAIL MediaCapabilities interface object name assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing FAIL MediaCapabilities interface object name assert_own_property: self does not have own property "MediaCapabilities" expected property "MediaCapabilities" missing
......
...@@ -3722,12 +3722,6 @@ interface MediaCapabilities ...@@ -3722,12 +3722,6 @@ interface MediaCapabilities
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
method decodingInfo method decodingInfo
interface MediaCapabilitiesInfo
attribute @@toStringTag
getter powerEfficient
getter smooth
getter supported
method constructor
interface MediaDeviceInfo interface MediaDeviceInfo
attribute @@toStringTag attribute @@toStringTag
getter deviceId getter deviceId
......
...@@ -4283,12 +4283,6 @@ interface MediaCapabilities ...@@ -4283,12 +4283,6 @@ interface MediaCapabilities
method constructor method constructor
method decodingInfo method decodingInfo
method encodingInfo method encodingInfo
interface MediaCapabilitiesInfo
attribute @@toStringTag
getter powerEfficient
getter smooth
getter supported
method constructor
interface MediaDeviceInfo interface MediaDeviceInfo
attribute @@toStringTag attribute @@toStringTag
getter deviceId getter deviceId
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_MEDIA_CAPABILITIES_WEB_MEDIA_CAPABILITIES_INFO_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_MEDIA_CAPABILITIES_WEB_MEDIA_CAPABILITIES_INFO_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_MEDIA_CAPABILITIES_WEB_MEDIA_CAPABILITIES_INFO_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_MEDIA_CAPABILITIES_WEB_MEDIA_CAPABILITIES_INFO_H_
#include <memory>
#include "third_party/blink/public/platform/web_callbacks.h" #include "third_party/blink/public/platform/web_callbacks.h"
namespace blink { namespace blink {
......
...@@ -8,8 +8,8 @@ blink_modules_sources("media_capabilities") { ...@@ -8,8 +8,8 @@ blink_modules_sources("media_capabilities") {
sources = [ sources = [
"media_capabilities.cc", "media_capabilities.cc",
"media_capabilities.h", "media_capabilities.h",
"media_capabilities_info.cc", "media_capabilities_query_callbacks.cc",
"media_capabilities_info.h", "media_capabilities_query_callbacks.h",
"navigator_media_capabilities.cc", "navigator_media_capabilities.cc",
"navigator_media_capabilities.h", "navigator_media_capabilities.h",
] ]
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_media_recorder_handler.h" #include "third_party/blink/public/platform/web_media_recorder_handler.h"
#include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_info.h" #include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_info.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_query_callbacks.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_configuration.h" #include "third_party/blink/renderer/modules/media_capabilities/media_configuration.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_decoding_configuration.h" #include "third_party/blink/renderer/modules/media_capabilities/media_decoding_configuration.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_encoding_configuration.h" #include "third_party/blink/renderer/modules/media_capabilities/media_encoding_configuration.h"
...@@ -246,8 +246,7 @@ ScriptPromise MediaCapabilities::decodingInfo( ...@@ -246,8 +246,7 @@ ScriptPromise MediaCapabilities::decodingInfo(
Platform::Current()->MediaCapabilitiesClient()->DecodingInfo( Platform::Current()->MediaCapabilitiesClient()->DecodingInfo(
ToWebMediaConfiguration(configuration), ToWebMediaConfiguration(configuration),
std::make_unique<CallbackPromiseAdapter<MediaCapabilitiesInfo, void>>( std::make_unique<MediaCapabilitiesQueryCallbacks>(resolver));
resolver));
return promise; return promise;
} }
...@@ -295,8 +294,8 @@ ScriptPromise MediaCapabilities::encodingInfo( ...@@ -295,8 +294,8 @@ ScriptPromise MediaCapabilities::encodingInfo(
handler->EncodingInfo( handler->EncodingInfo(
ToWebMediaConfiguration(configuration), ToWebMediaConfiguration(configuration),
std::make_unique<CallbackPromiseAdapter<MediaCapabilitiesInfo, void>>( std::make_unique<MediaCapabilitiesQueryCallbacks>(resolver));
resolver));
return promise; return promise;
} }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_info.h"
namespace blink {
// static
MediaCapabilitiesInfo* MediaCapabilitiesInfo::Take(
ScriptPromiseResolver*,
std::unique_ptr<WebMediaCapabilitiesInfo> web_media_capabilities_info) {
DCHECK(web_media_capabilities_info);
return new MediaCapabilitiesInfo(std::move(web_media_capabilities_info));
}
bool MediaCapabilitiesInfo::supported() const {
return web_media_capabilities_info_->supported;
}
bool MediaCapabilitiesInfo::smooth() const {
return web_media_capabilities_info_->smooth;
}
bool MediaCapabilitiesInfo::powerEfficient() const {
return web_media_capabilities_info_->power_efficient;
}
MediaCapabilitiesInfo::MediaCapabilitiesInfo(
std::unique_ptr<WebMediaCapabilitiesInfo> web_media_capabilities_info)
: web_media_capabilities_info_(std::move(web_media_capabilities_info)) {}
} // namespace blink
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// https://wicg.github.io/media-capabilities/#mediacapabilitiesinfo // https://wicg.github.io/media-capabilities/#media-capabilities-info
[ dictionary MediaCapabilitiesInfo {
Exposed=Window required boolean supported;
] interface MediaCapabilitiesInfo { required boolean smooth;
[Measure] readonly attribute boolean supported; required boolean powerEfficient;
[Measure] readonly attribute boolean smooth;
[Measure] readonly attribute boolean powerEfficient;
}; };
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_query_callbacks.h"
#include "third_party/blink/renderer/modules/media_capabilities/media_capabilities_info.h"
namespace blink {
MediaCapabilitiesQueryCallbacks::MediaCapabilitiesQueryCallbacks(
ScriptPromiseResolver* resolver)
: resolver_(resolver) {}
MediaCapabilitiesQueryCallbacks::~MediaCapabilitiesQueryCallbacks() = default;
void MediaCapabilitiesQueryCallbacks::OnSuccess(
std::unique_ptr<WebMediaCapabilitiesInfo> result) {
if (!resolver_->GetExecutionContext() ||
resolver_->GetExecutionContext()->IsContextDestroyed()) {
return;
}
Persistent<MediaCapabilitiesInfo> info(MediaCapabilitiesInfo::Create());
info->setSupported(result->supported);
info->setSmooth(result->smooth);
info->setPowerEfficient(result->power_efficient);
resolver_->Resolve(std::move(info));
}
void MediaCapabilitiesQueryCallbacks::OnError() {
NOTREACHED();
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_INFO_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_QUERY_CALLBACKS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_INFO_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_QUERY_CALLBACKS_H_
#include <memory>
#include "third_party/blink/public/platform/modules/media_capabilities/web_media_capabilities_info.h" #include "third_party/blink/public/platform/modules/media_capabilities/web_media_capabilities_info.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
namespace blink { namespace blink {
class ScriptPromiseResolver; class MediaCapabilitiesQueryCallbacks
: public WebMediaCapabilitiesQueryCallbacks {
// Implementation of the MediaCapabilitiesInfo interface.
class MediaCapabilitiesInfo final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public: public:
using WebType = std::unique_ptr<WebMediaCapabilitiesInfo>; explicit MediaCapabilitiesQueryCallbacks(ScriptPromiseResolver* resolver);
static MediaCapabilitiesInfo* Take(ScriptPromiseResolver*,
std::unique_ptr<WebMediaCapabilitiesInfo>);
bool supported() const; ~MediaCapabilitiesQueryCallbacks() override;
bool smooth() const;
bool powerEfficient() const;
private: void OnSuccess(std::unique_ptr<WebMediaCapabilitiesInfo>) override;
MediaCapabilitiesInfo() = delete; void OnError() override;
explicit MediaCapabilitiesInfo(std::unique_ptr<WebMediaCapabilitiesInfo>);
std::unique_ptr<WebMediaCapabilitiesInfo> web_media_capabilities_info_; private:
Persistent<ScriptPromiseResolver> resolver_;
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_INFO_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CAPABILITIES_MEDIA_CAPABILITIES_QUERY_CALLBACKS_H_
...@@ -187,7 +187,6 @@ modules_idl_files = ...@@ -187,7 +187,6 @@ modules_idl_files =
"locks/lock.idl", "locks/lock.idl",
"locks/lock_manager.idl", "locks/lock_manager.idl",
"media_capabilities/media_capabilities.idl", "media_capabilities/media_capabilities.idl",
"media_capabilities/media_capabilities_info.idl",
"mediacapturefromelement/canvas_capture_media_stream_track.idl", "mediacapturefromelement/canvas_capture_media_stream_track.idl",
"mediarecorder/blob_event.idl", "mediarecorder/blob_event.idl",
"mediarecorder/media_recorder.idl", "mediarecorder/media_recorder.idl",
...@@ -559,6 +558,7 @@ modules_dictionary_idl_files = ...@@ -559,6 +558,7 @@ modules_dictionary_idl_files =
"manifest/image_resource.idl", "manifest/image_resource.idl",
"media_capabilities/audio_configuration.idl", "media_capabilities/audio_configuration.idl",
"media_capabilities/media_configuration.idl", "media_capabilities/media_configuration.idl",
"media_capabilities/media_capabilities_info.idl",
"media_capabilities/media_decoding_configuration.idl", "media_capabilities/media_decoding_configuration.idl",
"media_capabilities/media_encoding_configuration.idl", "media_capabilities/media_encoding_configuration.idl",
"media_capabilities/video_configuration.idl", "media_capabilities/video_configuration.idl",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment