Bug 1112761 part 1. Replace Pref="media.mediasource.enabled" annotations in IDL with calls to a function which will end up doing something a bit more interesting. r=kinetik a=mse
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -301,16 +301,22 @@ MediaSource::IsTypeSupported(const Globa
{
MOZ_ASSERT(NS_IsMainThread());
nsresult rv = mozilla::IsTypeSupported(aType);
MSE_API("MediaSource::IsTypeSupported(aType=%s)%s",
NS_ConvertUTF16toUTF8(aType).get(), rv == NS_OK ? "" : " [not supported]");
return NS_SUCCEEDED(rv);
}
+/* static */ bool
+MediaSource::Enabled(JSContext* cx, JSObject* aGlobal)
+{
+ return Preferences::GetBool("media.mediasource.enabled");
+}
+
bool
MediaSource::Attach(MediaSourceDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_DEBUG("MediaSource(%p)::Attach(aDecoder=%p) owner=%p", this, aDecoder, aDecoder->GetOwner());
MOZ_ASSERT(aDecoder);
MOZ_ASSERT(aDecoder->GetOwner());
if (mReadyState != MediaSourceReadyState::Closed) {
--- a/dom/media/mediasource/MediaSource.h
+++ b/dom/media/mediasource/MediaSource.h
@@ -55,16 +55,18 @@ public:
double Duration();
void SetDuration(double aDuration, ErrorResult& aRv);
already_AddRefed<SourceBuffer> AddSourceBuffer(const nsAString& aType, ErrorResult& aRv);
void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
+
+ static bool Enabled(JSContext* cx, JSObject* aGlobal);
/** End WebIDL Methods. */
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaSource, DOMEventTargetHelper)
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
nsPIDOMWindow* GetParentObject() const;
--- a/dom/webidl/HTMLVideoElement.webidl
+++ b/dom/webidl/HTMLVideoElement.webidl
@@ -43,11 +43,11 @@ partial interface HTMLVideoElement {
readonly attribute double mozFrameDelay;
// True if the video has an audio track available.
readonly attribute boolean mozHasAudio;
};
// https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#idl-def-HTMLVideoElement
partial interface HTMLVideoElement {
- [Pref="media.mediasource.enabled", NewObject]
+ [Func="mozilla::dom::MediaSource::Enabled", NewObject]
VideoPlaybackQuality getVideoPlaybackQuality();
};
--- a/dom/webidl/MediaSource.webidl
+++ b/dom/webidl/MediaSource.webidl
@@ -16,17 +16,17 @@ enum MediaSourceReadyState {
"ended"
};
enum MediaSourceEndOfStreamError {
"network",
"decode"
};
-[Constructor, Pref="media.mediasource.enabled"]
+[Constructor, Func="mozilla::dom::MediaSource::Enabled"]
interface MediaSource : EventTarget {
readonly attribute SourceBufferList sourceBuffers;
readonly attribute SourceBufferList activeSourceBuffers;
readonly attribute MediaSourceReadyState readyState;
[SetterThrows]
attribute unrestricted double duration;
[NewObject, Throws]
SourceBuffer addSourceBuffer(DOMString type);
--- a/dom/webidl/SourceBuffer.webidl
+++ b/dom/webidl/SourceBuffer.webidl
@@ -10,17 +10,17 @@
* liability, trademark and document use rules apply.
*/
enum SourceBufferAppendMode {
"segments",
"sequence"
};
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
interface SourceBuffer : EventTarget {
[SetterThrows]
attribute SourceBufferAppendMode mode;
readonly attribute boolean updating;
[NewObject, Throws]
readonly attribute TimeRanges buffered;
[SetterThrows]
attribute double timestampOffset;
--- a/dom/webidl/SourceBufferList.webidl
+++ b/dom/webidl/SourceBufferList.webidl
@@ -5,13 +5,13 @@
*
* The origin of this IDL file is
* http://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
interface SourceBufferList : EventTarget {
readonly attribute unsigned long length;
getter SourceBuffer (unsigned long index);
};
--- a/dom/webidl/VideoPlaybackQuality.webidl
+++ b/dom/webidl/VideoPlaybackQuality.webidl
@@ -5,17 +5,17 @@
*
* The origin of this IDL file is
* http://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
interface VideoPlaybackQuality {
readonly attribute DOMHighResTimeStamp creationTime;
readonly attribute unsigned long totalVideoFrames;
readonly attribute unsigned long droppedVideoFrames;
readonly attribute unsigned long corruptedVideoFrames;
// At Risk: readonly attribute double totalFrameDelay;
};