2014-04-16 07:06:45 +04:00
|
|
|
/* -*- 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"
|
2016-05-10 12:02:15 +03:00
|
|
|
#include "mozilla/dom/VideoStreamTrack.h"
|
2014-04-16 07:06:45 +04:00
|
|
|
#include "mozilla/dom/VideoTrack.h"
|
|
|
|
#include "mozilla/dom/VideoTrackBinding.h"
|
|
|
|
#include "mozilla/dom/VideoTrackList.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-04-11 17:27:00 +03:00
|
|
|
VideoTrack::VideoTrack(nsIGlobalObject* aOwnerGlobal, const nsAString& aId,
|
2014-04-16 07:06:45 +04:00
|
|
|
const nsAString& aKind, const nsAString& aLabel,
|
2016-05-10 12:02:15 +03:00
|
|
|
const nsAString& aLanguage,
|
|
|
|
VideoStreamTrack* aStreamTarck)
|
2018-04-11 17:27:00 +03:00
|
|
|
: MediaTrack(aOwnerGlobal, aId, aKind, aLabel, aLanguage),
|
2014-04-16 07:06:45 +04:00
|
|
|
mSelected(false),
|
2016-05-10 12:02:15 +03:00
|
|
|
mVideoStreamTrack(aStreamTarck) {}
|
2014-04-16 07:06:45 +04:00
|
|
|
|
2016-05-10 12:02:15 +03:00
|
|
|
VideoTrack::~VideoTrack() {}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(VideoTrack, MediaTrack, mVideoStreamTrack)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(VideoTrack, MediaTrack)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(VideoTrack, MediaTrack)
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(VideoTrack)
|
2016-05-10 12:02:15 +03:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(MediaTrack)
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* VideoTrack::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return VideoTrack_Binding::Wrap(aCx, this, aGivenProto);
|
2014-04-16 07:06:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2016-08-24 11:58:04 +03:00
|
|
|
|
|
|
|
HTMLMediaElement* element = mList->GetMediaElement();
|
|
|
|
if (element) {
|
|
|
|
element->NotifyMediaTrackEnabled(this);
|
|
|
|
}
|
2014-04-16 07:06:45 +04:00
|
|
|
} else {
|
|
|
|
list.mSelectedIndex = -1;
|
2016-08-24 11:58:04 +03:00
|
|
|
|
|
|
|
HTMLMediaElement* element = mList->GetMediaElement();
|
|
|
|
if (element) {
|
|
|
|
element->NotifyMediaTrackDisabled(this);
|
|
|
|
}
|
2014-04-16 07:06:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|