mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1033885 - add MediaStreamError interface. r=jesup,bz
This commit is contained in:
parent
d3aef91306
commit
d7d2397713
57
dom/media/MediaStreamError.cpp
Normal file
57
dom/media/MediaStreamError.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaStreamError.h"
|
||||
#include "mozilla/dom/MediaStreamErrorBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MediaStreamError::MediaStreamError(
|
||||
nsPIDOMWindow* aParent,
|
||||
const nsAString& aName,
|
||||
const nsAString& aMessage,
|
||||
const nsAString& aConstraintName)
|
||||
: mParent(aParent)
|
||||
, mName(aName)
|
||||
, mMessage(aMessage)
|
||||
, mConstraintName(aConstraintName) {}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaStreamError, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaStreamError)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaStreamError)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamError)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
JSObject*
|
||||
MediaStreamError::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return MediaStreamErrorBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamError::GetName(nsAString& aName) const
|
||||
{
|
||||
aName = mName;
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamError::GetMessage(nsAString& aMessage) const
|
||||
{
|
||||
aMessage = mMessage;
|
||||
}
|
||||
|
||||
void
|
||||
MediaStreamError::GetConstraintName(nsAString& aConstraintName) const
|
||||
{
|
||||
aConstraintName = mConstraintName;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
57
dom/media/MediaStreamError.h
Normal file
57
dom/media/MediaStreamError.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MediaStreamError_h
|
||||
#define mozilla_dom_MediaStreamError_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsRefPtr.h"
|
||||
|
||||
#if defined(XP_WIN) && defined(GetMessage)
|
||||
#undef GetMessage
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaStreamError : public nsISupports, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
MediaStreamError(nsPIDOMWindow* aParent,
|
||||
const nsAString& aName,
|
||||
const nsAString& aMessage,
|
||||
const nsAString& aConstraintName);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamError)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
void GetName(nsAString& aName) const;
|
||||
void GetMessage(nsAString& aMessage) const;
|
||||
void GetConstraintName(nsAString& aConstraintName) const;
|
||||
|
||||
private:
|
||||
virtual ~MediaStreamError() {}
|
||||
|
||||
nsRefPtr<nsPIDOMWindow> mParent;
|
||||
const nsString mName;
|
||||
const nsString mMessage;
|
||||
const nsString mConstraintName;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
@ -143,6 +143,7 @@ EXPORTS.mozilla.dom += [
|
||||
'AudioTrack.h',
|
||||
'AudioTrackList.h',
|
||||
'GetUserMediaRequest.h',
|
||||
'MediaStreamError.h',
|
||||
'MediaStreamTrack.h',
|
||||
'TextTrack.h',
|
||||
'TextTrackCue.h',
|
||||
@ -181,6 +182,7 @@ UNIFIED_SOURCES += [
|
||||
'MediaRecorder.cpp',
|
||||
'MediaResource.cpp',
|
||||
'MediaShutdownManager.cpp',
|
||||
'MediaStreamError.cpp',
|
||||
'MediaStreamGraph.cpp',
|
||||
'MediaStreamTrack.cpp',
|
||||
'MediaTaskQueue.cpp',
|
||||
|
@ -23,6 +23,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// Undo the windows.h damage
|
||||
#if defined(XP_WIN) && defined(GetMessage)
|
||||
#undef GetMessage
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
21
dom/webidl/MediaStreamError.webidl
Normal file
21
dom/webidl/MediaStreamError.webidl
Normal file
@ -0,0 +1,21 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStreamError
|
||||
*/
|
||||
|
||||
// The future of MediaStreamError is uncertain.
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=26776
|
||||
|
||||
// TODO: This is an 'exception', not an interface, by virtue of needing to be
|
||||
// passed as a promise rejection-reason. Revisit if DOMException grows a customArg
|
||||
|
||||
[ExceptionClass, NoInterfaceObject]
|
||||
interface MediaStreamError {
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute DOMString? message;
|
||||
readonly attribute DOMString? constraintName;
|
||||
};
|
@ -264,6 +264,7 @@ WEBIDL_FILES = [
|
||||
'MediaStream.webidl',
|
||||
'MediaStreamAudioDestinationNode.webidl',
|
||||
'MediaStreamAudioSourceNode.webidl',
|
||||
'MediaStreamError.webidl',
|
||||
'MediaStreamTrack.webidl',
|
||||
'MediaTrackConstraintSet.webidl',
|
||||
'MenuBoxObject.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user