diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/VideoTrack.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/VideoTrack.cpp')
-rw-r--r-- | dom/media/VideoTrack.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/dom/media/VideoTrack.cpp b/dom/media/VideoTrack.cpp new file mode 100644 index 000000000..f451e381e --- /dev/null +++ b/dom/media/VideoTrack.cpp @@ -0,0 +1,103 @@ +/* -*- 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/VideoStreamTrack.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, + VideoStreamTrack* aStreamTarck) + : MediaTrack(aId, aKind, aLabel, aLanguage) + , mSelected(false) + , mVideoStreamTrack(aStreamTarck) +{ +} + +VideoTrack::~VideoTrack() +{ +} + +NS_IMPL_CYCLE_COLLECTION_INHERITED(VideoTrack, MediaTrack, mVideoStreamTrack) + +NS_IMPL_ADDREF_INHERITED(VideoTrack, MediaTrack) +NS_IMPL_RELEASE_INHERITED(VideoTrack, MediaTrack) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VideoTrack) +NS_INTERFACE_MAP_END_INHERITING(MediaTrack) + +JSObject* +VideoTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) +{ + return VideoTrackBinding::Wrap(aCx, this, aGivenProto); +} + +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; + + HTMLMediaElement* element = mList->GetMediaElement(); + if (element) { + element->NotifyMediaTrackEnabled(this); + } + } else { + list.mSelectedIndex = -1; + + HTMLMediaElement* element = mList->GetMediaElement(); + if (element) { + element->NotifyMediaTrackDisabled(this); + } + } + + // 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 |