mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset b191be106cae (bug 744896) for B2G ICS Emulator Opt Test failures on a CLOSED TREE
This commit is contained in:
parent
37a86c62b0
commit
380060748f
@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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 "mozilla/dom/AudioTrack.h"
|
||||
#include "mozilla/dom/AudioTrackBinding.h"
|
||||
#include "mozilla/dom/AudioTrackList.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
AudioTrack::AudioTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage,
|
||||
bool aEnabled)
|
||||
: MediaTrack(aId, aKind, aLabel, aLanguage)
|
||||
, mEnabled(aEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
AudioTrack::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return AudioTrackBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void
|
||||
AudioTrack::SetEnabled(bool aEnabled)
|
||||
{
|
||||
SetEnabledInternal(aEnabled, MediaTrack::DEFAULT);
|
||||
}
|
||||
|
||||
void
|
||||
AudioTrack::SetEnabledInternal(bool aEnabled, int aFlags)
|
||||
{
|
||||
if (aEnabled == mEnabled) {
|
||||
return;
|
||||
}
|
||||
mEnabled = aEnabled;
|
||||
|
||||
// If this AudioTrack is no longer in its original AudioTrackList, then
|
||||
// whether it is enabled or not has no effect on its original list.
|
||||
if (!mList) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(aFlags & MediaTrack::FIRE_NO_EVENTS)) {
|
||||
mList->CreateAndDispatchChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} //namespace mozilla
|
@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_AudioTrack_h
|
||||
#define mozilla_dom_AudioTrack_h
|
||||
|
||||
#include "MediaTrack.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AudioTrackList;
|
||||
|
||||
class AudioTrack : public MediaTrack
|
||||
{
|
||||
public:
|
||||
AudioTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage,
|
||||
bool aEnabled);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
virtual AudioTrack* AsAudioTrack() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual void SetEnabledInternal(bool aEnabled, int aFlags) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
bool Enabled() const
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool aEnabled);
|
||||
|
||||
private:
|
||||
bool mEnabled;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AudioTrack_h
|
@ -1,41 +0,0 @@
|
||||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#include "mozilla/dom/AudioTrack.h"
|
||||
#include "mozilla/dom/AudioTrackList.h"
|
||||
#include "mozilla/dom/AudioTrackListBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
AudioTrackList::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return AudioTrackListBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
AudioTrack*
|
||||
AudioTrackList::operator[](uint32_t aIndex)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::operator[](aIndex);
|
||||
return track->AsAudioTrack();
|
||||
}
|
||||
|
||||
AudioTrack*
|
||||
AudioTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::IndexedGetter(aIndex, aFound);
|
||||
return track ? track->AsAudioTrack() : nullptr;
|
||||
}
|
||||
|
||||
AudioTrack*
|
||||
AudioTrackList::GetTrackById(const nsAString& aId)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::GetTrackById(aId);
|
||||
return track ? track->AsAudioTrack() : nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,37 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_AudioTrackList_h
|
||||
#define mozilla_dom_AudioTrackList_h
|
||||
|
||||
#include "MediaTrack.h"
|
||||
#include "MediaTrackList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AudioTrack;
|
||||
|
||||
class AudioTrackList : public MediaTrackList
|
||||
{
|
||||
public:
|
||||
AudioTrackList(nsPIDOMWindow* aOwnerWindow, HTMLMediaElement* aMediaElement)
|
||||
: MediaTrackList(aOwnerWindow, aMediaElement) {}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
AudioTrack* operator[](uint32_t aIndex);
|
||||
|
||||
// WebIDL
|
||||
AudioTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
|
||||
AudioTrack* GetTrackById(const nsAString& aId);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AudioTrackList_h
|
@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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 "MediaTrack.h"
|
||||
#include "MediaTrackList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MediaTrack::MediaTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage)
|
||||
: DOMEventTargetHelper()
|
||||
, mId(aId)
|
||||
, mKind(aKind)
|
||||
, mLabel(aLabel)
|
||||
, mLanguage(aLanguage)
|
||||
{
|
||||
}
|
||||
|
||||
MediaTrack::~MediaTrack()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(MediaTrack, DOMEventTargetHelper, mList)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(MediaTrack, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(MediaTrack, DOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaTrack)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
void
|
||||
MediaTrack::SetTrackList(MediaTrackList* aList)
|
||||
{
|
||||
mList = aList;
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrack::Init(nsPIDOMWindow* aOwnerWindow)
|
||||
{
|
||||
BindToOwner(aOwnerWindow);
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,104 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_MediaTrack_h
|
||||
#define mozilla_dom_MediaTrack_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaTrackList;
|
||||
class VideoTrack;
|
||||
class AudioTrack;
|
||||
|
||||
/**
|
||||
* Base class of AudioTrack and VideoTrack. The AudioTrack and VideoTrack
|
||||
* objects represent specific tracks of a media resource. Each track has aspects
|
||||
* of an identifier, category, label, and language, even if a track is removed
|
||||
* from its corresponding track list, those aspects do not change.
|
||||
*
|
||||
* When fetching the media resource, an audio/video track is created if the
|
||||
* media resource is found to have an audio/video track. When the UA has learned
|
||||
* that an audio/video track has ended, this audio/video track will be removed
|
||||
* from its corresponding track list.
|
||||
*
|
||||
* Although AudioTrack and VideoTrack are not EventTargets, TextTrack is, and
|
||||
* TextTrack inherits from MediaTrack as well (or is going to).
|
||||
*/
|
||||
class MediaTrack : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
MediaTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage);
|
||||
|
||||
virtual ~MediaTrack();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaTrack, DOMEventTargetHelper)
|
||||
|
||||
enum {
|
||||
DEFAULT = 0,
|
||||
FIRE_NO_EVENTS = 1 << 0,
|
||||
};
|
||||
// The default behavior of enabling an audio track or selecting a video track
|
||||
// fires a change event and notifies its media resource about the changes.
|
||||
// It should not fire any events when fetching media resource.
|
||||
virtual void SetEnabledInternal(bool aEnabled, int aFlags) = 0;
|
||||
|
||||
virtual AudioTrack* AsAudioTrack()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual VideoTrack* AsVideoTrack()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const nsString& GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
// WebIDL
|
||||
void GetId(nsAString& aId) const
|
||||
{
|
||||
aId = mId;
|
||||
}
|
||||
void GetKind(nsAString& aKind) const
|
||||
{
|
||||
aKind = mKind;
|
||||
}
|
||||
void GetLabel(nsAString& aLabel) const
|
||||
{
|
||||
aLabel = mLabel;
|
||||
}
|
||||
void GetLanguage(nsAString& aLanguage) const
|
||||
{
|
||||
aLanguage = mLanguage;
|
||||
}
|
||||
|
||||
friend class MediaTrackList;
|
||||
|
||||
protected:
|
||||
void SetTrackList(MediaTrackList* aList);
|
||||
void Init(nsPIDOMWindow* aOwnerWindow);
|
||||
|
||||
nsRefPtr<MediaTrackList> mList;
|
||||
nsString mId;
|
||||
nsString mKind;
|
||||
nsString mLabel;
|
||||
nsString mLanguage;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MediaTrack_h
|
@ -1,118 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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 "MediaTrack.h"
|
||||
#include "MediaTrackList.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/dom/AudioTrack.h"
|
||||
#include "mozilla/dom/VideoTrack.h"
|
||||
#include "mozilla/dom/TrackEvent.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MediaTrackList::MediaTrackList(nsPIDOMWindow* aOwnerWindow,
|
||||
HTMLMediaElement* aMediaElement)
|
||||
: DOMEventTargetHelper(aOwnerWindow)
|
||||
, mMediaElement(aMediaElement)
|
||||
{
|
||||
}
|
||||
|
||||
MediaTrackList::~MediaTrackList()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(MediaTrackList,
|
||||
DOMEventTargetHelper,
|
||||
mTracks,
|
||||
mMediaElement)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(MediaTrackList, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(MediaTrackList, DOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaTrackList)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
MediaTrack*
|
||||
MediaTrackList::operator[](uint32_t aIndex)
|
||||
{
|
||||
return mTracks.ElementAt(aIndex);
|
||||
}
|
||||
|
||||
MediaTrack*
|
||||
MediaTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
aFound = aIndex < mTracks.Length();
|
||||
return aFound ? mTracks[aIndex] : nullptr;
|
||||
}
|
||||
|
||||
MediaTrack*
|
||||
MediaTrackList::GetTrackById(const nsAString& aId)
|
||||
{
|
||||
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
||||
if (aId.Equals(mTracks[i]->GetId())) {
|
||||
return mTracks[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrackList::AddTrack(MediaTrack* aTrack)
|
||||
{
|
||||
mTracks.AppendElement(aTrack);
|
||||
aTrack->Init(GetOwner());
|
||||
aTrack->SetTrackList(this);
|
||||
CreateAndDispatchTrackEventRunner(aTrack, NS_LITERAL_STRING("addtrack"));
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrackList::RemoveTrack(const nsRefPtr<MediaTrack>& aTrack)
|
||||
{
|
||||
mTracks.RemoveElement(aTrack);
|
||||
aTrack->SetTrackList(nullptr);
|
||||
CreateAndDispatchTrackEventRunner(aTrack, NS_LITERAL_STRING("removetrack"));
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrackList::EmptyTracks()
|
||||
{
|
||||
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
||||
mTracks[i]->SetTrackList(nullptr);
|
||||
}
|
||||
mTracks.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrackList::CreateAndDispatchChangeEvent()
|
||||
{
|
||||
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, NS_LITERAL_STRING("change"), false);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
void
|
||||
MediaTrackList::CreateAndDispatchTrackEventRunner(MediaTrack* aTrack,
|
||||
const nsAString& aEventName)
|
||||
{
|
||||
TrackEventInit eventInit;
|
||||
|
||||
if (aTrack->AsAudioTrack()) {
|
||||
eventInit.mTrack.SetValue().SetAsAudioTrack() = aTrack->AsAudioTrack();
|
||||
} else if (aTrack->AsVideoTrack()) {
|
||||
eventInit.mTrack.SetValue().SetAsVideoTrack() = aTrack->AsVideoTrack();
|
||||
}
|
||||
|
||||
nsRefPtr<TrackEvent> event =
|
||||
TrackEvent::Constructor(this, aEventName, eventInit);
|
||||
|
||||
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, event);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,76 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_MediaTrackList_h
|
||||
#define mozilla_dom_MediaTrackList_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HTMLMediaElement;
|
||||
class MediaTrack;
|
||||
class AudioTrackList;
|
||||
class VideoTrackList;
|
||||
|
||||
/**
|
||||
* Base class of AudioTrackList and VideoTrackList. The AudioTrackList and
|
||||
* VideoTrackList objects represent a dynamic list of zero or more audio and
|
||||
* video tracks respectively.
|
||||
*
|
||||
* When a media element is to forget its media-resource-specific tracks, its
|
||||
* audio track list and video track list will be emptied.
|
||||
*/
|
||||
class MediaTrackList : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
MediaTrackList(nsPIDOMWindow* aOwnerWindow, HTMLMediaElement* aMediaElement);
|
||||
virtual ~MediaTrackList();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaTrackList, DOMEventTargetHelper)
|
||||
|
||||
using DOMEventTargetHelper::DispatchTrustedEvent;
|
||||
|
||||
// The return value is non-null, assert an error if aIndex is out of bound
|
||||
// for array mTracks.
|
||||
MediaTrack* operator[](uint32_t aIndex);
|
||||
|
||||
void AddTrack(MediaTrack* aTrack);
|
||||
|
||||
void RemoveTrack(const nsRefPtr<MediaTrack>& aTrack);
|
||||
|
||||
virtual void EmptyTracks();
|
||||
|
||||
void CreateAndDispatchChangeEvent();
|
||||
|
||||
// WebIDL
|
||||
MediaTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
|
||||
MediaTrack* GetTrackById(const nsAString& aId);
|
||||
|
||||
uint32_t Length() const
|
||||
{
|
||||
return mTracks.Length();
|
||||
}
|
||||
|
||||
IMPL_EVENT_HANDLER(change)
|
||||
IMPL_EVENT_HANDLER(addtrack)
|
||||
IMPL_EVENT_HANDLER(removetrack)
|
||||
|
||||
protected:
|
||||
void CreateAndDispatchTrackEventRunner(MediaTrack* aTrack,
|
||||
const nsAString& aEventName);
|
||||
|
||||
nsTArray<nsRefPtr<MediaTrack>> mTracks;
|
||||
nsRefPtr<HTMLMediaElement> mMediaElement;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MediaTrackList_h
|
@ -184,7 +184,9 @@ TextTrackList::CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
|
||||
const nsAString& aEventName)
|
||||
{
|
||||
TrackEventInit eventInit;
|
||||
eventInit.mTrack.SetValue().SetAsTextTrack() = aTrack;
|
||||
eventInit.mBubbles = false;
|
||||
eventInit.mCancelable = false;
|
||||
eventInit.mTrack = aTrack;
|
||||
nsRefPtr<TrackEvent> event =
|
||||
TrackEvent::Constructor(this, aEventName, eventInit);
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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 "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/VideoTrack.h"
|
||||
#include "mozilla/dom/VideoTrackBinding.h"
|
||||
#include "mozilla/dom/VideoTrackList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
VideoTrack::VideoTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage)
|
||||
: MediaTrack(aId, aKind, aLabel, aLanguage)
|
||||
, mSelected(false)
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
VideoTrack::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return VideoTrackBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void VideoTrack::SetSelected(bool aSelected)
|
||||
{
|
||||
SetEnabledInternal(aSelected, MediaTrack::DEFAULT);
|
||||
}
|
||||
|
||||
void
|
||||
VideoTrack::SetEnabledInternal(bool aEnabled, int aFlags)
|
||||
{
|
||||
if (aEnabled == mSelected) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSelected = aEnabled;
|
||||
|
||||
// If this VideoTrack is no longer in its original VideoTrackList, then
|
||||
// whether it is selected or not has no effect on its original list.
|
||||
if (!mList) {
|
||||
return;
|
||||
}
|
||||
|
||||
VideoTrackList& list = static_cast<VideoTrackList&>(*mList);
|
||||
if (mSelected) {
|
||||
uint32_t curIndex = 0;
|
||||
|
||||
// Unselect all video tracks except the current one.
|
||||
for (uint32_t i = 0; i < list.Length(); ++i) {
|
||||
if (list[i] == this) {
|
||||
curIndex = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
VideoTrack* track = list[i];
|
||||
track->SetSelected(false);
|
||||
}
|
||||
|
||||
// Set the index of selected video track to the current's index.
|
||||
list.mSelectedIndex = curIndex;
|
||||
} else {
|
||||
list.mSelectedIndex = -1;
|
||||
}
|
||||
|
||||
// Fire the change event at selection changes on this video track, shall
|
||||
// propose a spec change later.
|
||||
if (!(aFlags & MediaTrack::FIRE_NO_EVENTS)) {
|
||||
list.CreateAndDispatchChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} //namespace mozilla
|
@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_VideoTrack_h
|
||||
#define mozilla_dom_VideoTrack_h
|
||||
|
||||
#include "MediaTrack.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class VideoTrackList;
|
||||
|
||||
class VideoTrack : public MediaTrack
|
||||
{
|
||||
public:
|
||||
VideoTrack(const nsAString& aId,
|
||||
const nsAString& aKind,
|
||||
const nsAString& aLabel,
|
||||
const nsAString& aLanguage);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
virtual VideoTrack* AsVideoTrack() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// When fetching media resource, if no video track is selected by the media
|
||||
// resource, then the first VideoTrack object in the list is set selected as
|
||||
// default. If multiple video tracks are selected by its media resource at
|
||||
// fetching phase, then the first enabled video track is set selected.
|
||||
// aFlags contains FIRE_NO_EVENTS because no events are fired in such cases.
|
||||
virtual void SetEnabledInternal(bool aEnabled, int aFlags) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
bool Selected() const
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
// Either zero or one video track is selected in a list; If the selected track
|
||||
// is in a VideoTrackList, then all the other VideoTrack objects in that list
|
||||
// must be unselected.
|
||||
void SetSelected(bool aSelected);
|
||||
|
||||
private:
|
||||
bool mSelected;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_VideoTrack_h
|
@ -1,48 +0,0 @@
|
||||
/* -*- Mode: C++; 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/. */
|
||||
|
||||
#include "mozilla/dom/VideoTrack.h"
|
||||
#include "mozilla/dom/VideoTrackList.h"
|
||||
#include "mozilla/dom/VideoTrackListBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject*
|
||||
VideoTrackList::WrapObject(JSContext* aCx)
|
||||
{
|
||||
return VideoTrackListBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
VideoTrack*
|
||||
VideoTrackList::operator[](uint32_t aIndex)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::operator[](aIndex);
|
||||
return track->AsVideoTrack();
|
||||
}
|
||||
|
||||
void
|
||||
VideoTrackList::EmptyTracks()
|
||||
{
|
||||
mSelectedIndex = -1;
|
||||
MediaTrackList::EmptyTracks();
|
||||
}
|
||||
|
||||
VideoTrack*
|
||||
VideoTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::IndexedGetter(aIndex, aFound);
|
||||
return track ? track->AsVideoTrack() : nullptr;
|
||||
}
|
||||
|
||||
VideoTrack*
|
||||
VideoTrackList::GetTrackById(const nsAString& aId)
|
||||
{
|
||||
MediaTrack* track = MediaTrackList::GetTrackById(aId);
|
||||
return track ? track->AsVideoTrack() : nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,51 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 et tw=78: */
|
||||
/* 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_VideoTrackList_h
|
||||
#define mozilla_dom_VideoTrackList_h
|
||||
|
||||
#include "MediaTrack.h"
|
||||
#include "MediaTrackList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class VideoTrack;
|
||||
|
||||
class VideoTrackList : public MediaTrackList
|
||||
{
|
||||
public:
|
||||
VideoTrackList(nsPIDOMWindow* aOwnerWindow, HTMLMediaElement* aMediaElement)
|
||||
: MediaTrackList(aOwnerWindow, aMediaElement)
|
||||
, mSelectedIndex(-1)
|
||||
{}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
VideoTrack* operator[](uint32_t aIndex);
|
||||
|
||||
virtual void EmptyTracks() MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
int32_t SelectedIndex() const
|
||||
{
|
||||
return mSelectedIndex;
|
||||
}
|
||||
|
||||
VideoTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
|
||||
VideoTrack* GetTrackById(const nsAString& aId);
|
||||
|
||||
friend class VideoTrack;
|
||||
|
||||
private:
|
||||
int32_t mSelectedIndex;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_VideoTrackList_h
|
@ -91,8 +91,6 @@ EXPORTS += [
|
||||
'MediaSegment.h',
|
||||
'MediaStreamGraph.h',
|
||||
'MediaTaskQueue.h',
|
||||
'MediaTrack.h',
|
||||
'MediaTrackList.h',
|
||||
'MP3FrameParser.h',
|
||||
'nsIDocumentActivity.h',
|
||||
'RtspMediaResource.h',
|
||||
@ -109,8 +107,6 @@ EXPORTS += [
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AudioStreamTrack.h',
|
||||
'AudioTrack.h',
|
||||
'AudioTrackList.h',
|
||||
'MediaStreamTrack.h',
|
||||
'TextTrack.h',
|
||||
'TextTrackCue.h',
|
||||
@ -119,8 +115,6 @@ EXPORTS.mozilla.dom += [
|
||||
'TextTrackRegion.h',
|
||||
'VideoPlaybackQuality.h',
|
||||
'VideoStreamTrack.h',
|
||||
'VideoTrack.h',
|
||||
'VideoTrackList.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
@ -133,8 +127,6 @@ UNIFIED_SOURCES += [
|
||||
'AudioSink.cpp',
|
||||
'AudioStream.cpp',
|
||||
'AudioStreamTrack.cpp',
|
||||
'AudioTrack.cpp',
|
||||
'AudioTrackList.cpp',
|
||||
'BufferDecoder.cpp',
|
||||
'DOMMediaStream.cpp',
|
||||
'EncodedBufferCache.cpp',
|
||||
@ -150,8 +142,6 @@ UNIFIED_SOURCES += [
|
||||
'MediaStreamGraph.cpp',
|
||||
'MediaStreamTrack.cpp',
|
||||
'MediaTaskQueue.cpp',
|
||||
'MediaTrack.cpp',
|
||||
'MediaTrackList.cpp',
|
||||
'MP3FrameParser.cpp',
|
||||
'RtspMediaResource.cpp',
|
||||
'SharedThreadPool.cpp',
|
||||
@ -165,8 +155,6 @@ UNIFIED_SOURCES += [
|
||||
'VideoPlaybackQuality.cpp',
|
||||
'VideoSegment.cpp',
|
||||
'VideoStreamTrack.cpp',
|
||||
'VideoTrack.cpp',
|
||||
'VideoTrackList.cpp',
|
||||
'VideoUtils.cpp',
|
||||
'WebVTTListener.cpp',
|
||||
]
|
||||
|
@ -1,17 +0,0 @@
|
||||
/* -*- 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://www.whatwg.org/specs/web-apps/current-work/#audiotrack
|
||||
*/
|
||||
|
||||
[Pref="media.track.enabled"]
|
||||
interface AudioTrack {
|
||||
readonly attribute DOMString id;
|
||||
readonly attribute DOMString kind;
|
||||
readonly attribute DOMString label;
|
||||
readonly attribute DOMString language;
|
||||
attribute boolean enabled;
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
/* -*- 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://www.whatwg.org/specs/web-apps/current-work/#audiotracklist
|
||||
*/
|
||||
|
||||
[Pref="media.track.enabled"]
|
||||
interface AudioTrackList : EventTarget {
|
||||
readonly attribute unsigned long length;
|
||||
getter AudioTrack (unsigned long index);
|
||||
AudioTrack? getTrackById(DOMString id);
|
||||
|
||||
attribute EventHandler onchange;
|
||||
attribute EventHandler onaddtrack;
|
||||
attribute EventHandler onremovetrack;
|
||||
};
|
@ -2,18 +2,16 @@
|
||||
/* 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://www.whatwg.org/specs/web-apps/current-work/#trackevent
|
||||
*/
|
||||
|
||||
|
||||
[Constructor(DOMString type, optional TrackEventInit eventInitDict)]
|
||||
interface TrackEvent : Event
|
||||
{
|
||||
readonly attribute (VideoTrack or AudioTrack or TextTrack)? track;
|
||||
readonly attribute TextTrack? track;
|
||||
};
|
||||
|
||||
dictionary TrackEventInit : EventInit
|
||||
{
|
||||
(VideoTrack or AudioTrack or TextTrack)? track = null;
|
||||
TextTrack? track = null;
|
||||
};
|
||||
|
@ -1,17 +0,0 @@
|
||||
/* -*- 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://www.whatwg.org/specs/web-apps/current-work/#videotrack
|
||||
*/
|
||||
|
||||
[Pref="media.track.enabled"]
|
||||
interface VideoTrack {
|
||||
readonly attribute DOMString id;
|
||||
readonly attribute DOMString kind;
|
||||
readonly attribute DOMString label;
|
||||
readonly attribute DOMString language;
|
||||
attribute boolean selected;
|
||||
};
|
@ -1,21 +0,0 @@
|
||||
/* -*- 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://www.whatwg.org/specs/web-apps/current-work/#videotracklist
|
||||
*/
|
||||
|
||||
[Pref="media.track.enabled"]
|
||||
interface VideoTrackList : EventTarget {
|
||||
readonly attribute unsigned long length;
|
||||
getter VideoTrack (unsigned long index);
|
||||
VideoTrack? getTrackById(DOMString id);
|
||||
readonly attribute long selectedIndex;
|
||||
|
||||
attribute EventHandler onchange;
|
||||
attribute EventHandler onaddtrack;
|
||||
attribute EventHandler onremovetrack;
|
||||
};
|
||||
|
@ -37,8 +37,6 @@ WEBIDL_FILES = [
|
||||
'AudioParam.webidl',
|
||||
'AudioProcessingEvent.webidl',
|
||||
'AudioStreamTrack.webidl',
|
||||
'AudioTrack.webidl',
|
||||
'AudioTrackList.webidl',
|
||||
'BarProp.webidl',
|
||||
'BatteryManager.webidl',
|
||||
'BeforeUnloadEvent.webidl',
|
||||
@ -468,8 +466,6 @@ WEBIDL_FILES = [
|
||||
'ValidityState.webidl',
|
||||
'VideoPlaybackQuality.webidl',
|
||||
'VideoStreamTrack.webidl',
|
||||
'VideoTrack.webidl',
|
||||
'VideoTrackList.webidl',
|
||||
'VTTCue.webidl',
|
||||
'VTTRegion.webidl',
|
||||
'WaveShaperNode.webidl',
|
||||
|
@ -345,9 +345,6 @@ pref("media.tabstreaming.time_per_frame", 40);
|
||||
pref("media.webvtt.enabled", true);
|
||||
pref("media.webvtt.regions.enabled", false);
|
||||
|
||||
// AudioTrack and VideoTrack support
|
||||
pref("media.track.enabled", false);
|
||||
|
||||
// Whether to enable MediaSource support
|
||||
pref("media.mediasource.enabled", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user