2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
#include "nsIDOMHTMLSourceElement.h"
|
2013-03-19 16:27:35 +04:00
|
|
|
#include "mozilla/dom/HTMLVideoElement.h"
|
2013-03-19 16:28:34 +04:00
|
|
|
#include "mozilla/dom/HTMLVideoElementBinding.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsSize.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "plbase64.h"
|
|
|
|
#include "prlock.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2012-08-21 08:06:46 +04:00
|
|
|
#include "ImageContainer.h"
|
2016-05-27 09:33:48 +03:00
|
|
|
#include "VideoFrameContainer.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
|
|
|
|
#include "nsITimer.h"
|
|
|
|
|
2013-02-14 19:59:21 +04:00
|
|
|
#include "MediaError.h"
|
2012-11-14 23:46:40 +04:00
|
|
|
#include "MediaDecoder.h"
|
2013-06-11 19:23:13 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-01-07 16:16:07 +04:00
|
|
|
#include "mozilla/dom/WakeLock.h"
|
|
|
|
#include "mozilla/dom/power/PowerManagerService.h"
|
2016-06-09 20:04:42 +03:00
|
|
|
#include "mozilla/dom/Performance.h"
|
2013-10-22 01:23:33 +04:00
|
|
|
#include "mozilla/dom/VideoPlaybackQuality.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2016-07-18 03:51:30 +03:00
|
|
|
#include <algorithm>
|
|
|
|
#include <limits>
|
|
|
|
|
2011-09-18 13:22:18 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-06-11 19:23:13 +04:00
|
|
|
static bool sVideoStatsEnabled;
|
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2014-07-13 06:20:42 +04:00
|
|
|
HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
|
2013-03-19 16:23:54 +04:00
|
|
|
: HTMLMediaElement(aNodeInfo)
|
2015-09-02 16:18:16 +03:00
|
|
|
, mUseScreenWakeLock(true)
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
HTMLVideoElement::~HTMLVideoElement()
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
nsresult HTMLVideoElement::GetVideoSize(nsIntSize* size)
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
2015-04-14 08:17:55 +03:00
|
|
|
if (!mMediaInfo.HasVideo()) {
|
2012-05-11 12:32:15 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-05-23 13:34:14 +04:00
|
|
|
if (mDisableVideo) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-05-11 20:54:52 +03:00
|
|
|
switch (mMediaInfo.mVideo.mRotation) {
|
|
|
|
case VideoInfo::Rotation::kDegree_90:
|
|
|
|
case VideoInfo::Rotation::kDegree_270: {
|
|
|
|
size->width = mMediaInfo.mVideo.mDisplay.height;
|
|
|
|
size->height = mMediaInfo.mVideo.mDisplay.width;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VideoInfo::Rotation::kDegree_0:
|
|
|
|
case VideoInfo::Rotation::kDegree_180:
|
|
|
|
default: {
|
|
|
|
size->height = mMediaInfo.mVideo.mDisplay.height;
|
|
|
|
size->width = mMediaInfo.mVideo.mDisplay.width;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-05-11 12:32:15 +04:00
|
|
|
return NS_OK;
|
2008-07-09 12:22:20 +04:00
|
|
|
}
|
2009-02-26 10:04:42 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-03-19 16:27:35 +04:00
|
|
|
HTMLVideoElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2009-02-26 10:04:42 +03:00
|
|
|
{
|
|
|
|
if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) {
|
2011-02-04 22:46:16 +03:00
|
|
|
return aResult.ParseSpecialIntValue(aValue);
|
2009-02-26 10:04:42 +03:00
|
|
|
}
|
|
|
|
|
2013-03-19 16:23:54 +04:00
|
|
|
return HTMLMediaElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
2009-02-26 10:04:42 +03:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void
|
|
|
|
HTMLVideoElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 03:51:01 +03:00
|
|
|
GenericSpecifiedValues* aData)
|
2009-02-26 10:04:42 +03:00
|
|
|
{
|
2017-01-27 03:51:01 +03:00
|
|
|
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
2009-02-26 10:04:42 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-03-19 16:27:35 +04:00
|
|
|
HTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2009-02-26 10:04:42 +03:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
|
|
|
{ &nsGkAtoms::width },
|
|
|
|
{ &nsGkAtoms::height },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2009-02-26 10:04:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2009-02-26 10:04:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2013-03-19 16:27:35 +04:00
|
|
|
HTMLVideoElement::GetAttributeMappingFunction() const
|
2009-02-26 10:04:42 +03:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2009-06-26 11:25:17 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
2010-07-29 08:58:07 +04:00
|
|
|
{
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString value(
|
2011-11-16 11:50:19 +04:00
|
|
|
"video/webm,"
|
|
|
|
"video/ogg,"
|
|
|
|
"video/*;q=0.9,"
|
|
|
|
"application/ogg;q=0.7,"
|
|
|
|
"audio/*;q=0.6,*/*;q=0.5");
|
2010-07-29 08:58:07 +04:00
|
|
|
|
2011-11-16 11:50:19 +04:00
|
|
|
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
|
|
|
value,
|
|
|
|
false);
|
2010-07-29 08:58:07 +04:00
|
|
|
}
|
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
bool
|
2015-03-17 23:42:14 +03:00
|
|
|
HTMLVideoElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
2015-01-20 23:39:28 +03:00
|
|
|
{
|
2015-03-23 12:02:33 +03:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::controls) ||
|
|
|
|
HTMLMediaElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 23:39:28 +03:00
|
|
|
}
|
|
|
|
|
2013-03-19 16:28:34 +04:00
|
|
|
uint32_t HTMLVideoElement::MozParsedFrames() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2013-06-11 19:23:13 +04:00
|
|
|
if (!sVideoStatsEnabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-19 16:28:34 +04:00
|
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t HTMLVideoElement::MozDecodedFrames() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2013-06-11 19:23:13 +04:00
|
|
|
if (!sVideoStatsEnabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-19 16:28:34 +04:00
|
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t HTMLVideoElement::MozPresentedFrames() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2013-06-11 19:23:13 +04:00
|
|
|
if (!sVideoStatsEnabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-19 16:28:34 +04:00
|
|
|
return mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t HTMLVideoElement::MozPaintedFrames()
|
2011-03-24 01:28:57 +03:00
|
|
|
{
|
2013-03-19 16:28:34 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2013-06-11 19:23:13 +04:00
|
|
|
if (!sVideoStatsEnabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-19 16:23:54 +04:00
|
|
|
layers::ImageContainer* container = GetImageContainer();
|
2013-03-19 16:28:34 +04:00
|
|
|
return container ? container->GetPaintCount() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double HTMLVideoElement::MozFrameDelay()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2012-02-15 08:35:01 +04:00
|
|
|
VideoFrameContainer* container = GetVideoFrameContainer();
|
2015-05-25 06:42:24 +03:00
|
|
|
// Hide negative delays. Frame timing tweaks in the compositor (e.g.
|
|
|
|
// adding a bias value to prevent multiple dropped/duped frames when
|
|
|
|
// frame times are aligned with composition times) may produce apparent
|
|
|
|
// negative delay, but we shouldn't report that.
|
|
|
|
return container ? std::max(0.0, container->GetFrameDelay()) : 0.0;
|
2011-03-24 01:28:57 +03:00
|
|
|
}
|
2012-04-28 19:01:10 +04:00
|
|
|
|
2013-03-19 16:28:34 +04:00
|
|
|
bool HTMLVideoElement::MozHasAudio() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
2015-02-09 09:51:17 +03:00
|
|
|
return HasAudio();
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
2015-09-02 16:18:16 +03:00
|
|
|
bool HTMLVideoElement::MozUseScreenWakeLock() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
|
|
return mUseScreenWakeLock;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLVideoElement::SetMozUseScreenWakeLock(bool aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
|
|
|
|
mUseScreenWakeLock = aValue;
|
|
|
|
UpdateScreenWakeLock();
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:28:34 +04:00
|
|
|
JSObject*
|
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
|
|
|
HTMLVideoElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-03-19 16:28:34 +04:00
|
|
|
{
|
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
|
|
|
return HTMLVideoElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
2016-08-29 13:56:38 +03:00
|
|
|
void
|
|
|
|
HTMLVideoElement::NotifyOwnerDocumentActivityChanged()
|
2013-05-10 16:42:39 +04:00
|
|
|
{
|
2016-08-29 13:56:38 +03:00
|
|
|
HTMLMediaElement::NotifyOwnerDocumentActivityChanged();
|
2014-03-18 12:44:41 +04:00
|
|
|
UpdateScreenWakeLock();
|
2013-05-10 16:42:39 +04:00
|
|
|
}
|
|
|
|
|
2016-07-26 04:32:58 +03:00
|
|
|
FrameStatistics*
|
|
|
|
HTMLVideoElement::GetFrameStatistics()
|
|
|
|
{
|
|
|
|
return mDecoder ? &(mDecoder->GetFrameStatistics()) : nullptr;
|
|
|
|
}
|
|
|
|
|
2013-07-05 04:24:35 +04:00
|
|
|
already_AddRefed<VideoPlaybackQuality>
|
|
|
|
HTMLVideoElement::GetVideoPlaybackQuality()
|
2013-06-21 07:14:18 +04:00
|
|
|
{
|
2013-07-05 04:24:35 +04:00
|
|
|
DOMHighResTimeStamp creationTime = 0;
|
2016-07-14 08:18:36 +03:00
|
|
|
uint32_t totalFrames = 0;
|
|
|
|
uint32_t droppedFrames = 0;
|
|
|
|
uint32_t corruptedFrames = 0;
|
2013-07-11 07:52:22 +04:00
|
|
|
|
|
|
|
if (sVideoStatsEnabled) {
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow()) {
|
2016-06-09 20:04:42 +03:00
|
|
|
Performance* perf = window->GetPerformance();
|
2013-07-11 07:52:22 +04:00
|
|
|
if (perf) {
|
2015-07-30 08:41:00 +03:00
|
|
|
creationTime = perf->Now();
|
2013-07-11 07:52:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mDecoder) {
|
2016-07-18 02:51:25 +03:00
|
|
|
FrameStatisticsData stats =
|
|
|
|
mDecoder->GetFrameStatistics().GetFrameStatisticsData();
|
2016-07-18 03:51:30 +03:00
|
|
|
if (sizeof(totalFrames) >= sizeof(stats.mParsedFrames)) {
|
2016-10-21 04:01:59 +03:00
|
|
|
totalFrames = stats.mPresentedFrames + stats.mDroppedFrames;
|
2016-07-18 03:51:30 +03:00
|
|
|
droppedFrames = stats.mDroppedFrames;
|
|
|
|
} else {
|
2016-10-21 04:01:59 +03:00
|
|
|
uint64_t total = stats.mPresentedFrames + stats.mDroppedFrames;
|
2016-07-18 03:51:30 +03:00
|
|
|
const auto maxNumber = std::numeric_limits<uint32_t>::max();
|
2016-10-21 04:01:59 +03:00
|
|
|
if (total <= maxNumber) {
|
|
|
|
totalFrames = uint32_t(total);
|
|
|
|
droppedFrames = uint32_t(stats.mDroppedFrames);
|
2016-07-18 03:51:30 +03:00
|
|
|
} else {
|
|
|
|
// Too big number(s) -> Resize everything to fit in 32 bits.
|
2016-10-21 04:01:59 +03:00
|
|
|
double ratio = double(maxNumber) / double(total);
|
|
|
|
totalFrames = maxNumber; // === total * ratio
|
|
|
|
droppedFrames = uint32_t(double(stats.mDroppedFrames) * ratio);
|
2016-07-18 03:51:30 +03:00
|
|
|
}
|
|
|
|
}
|
2015-03-03 07:46:48 +03:00
|
|
|
corruptedFrames = 0;
|
2013-07-11 07:52:22 +04:00
|
|
|
}
|
2013-06-21 07:14:18 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<VideoPlaybackQuality> playbackQuality =
|
2013-07-05 04:24:35 +04:00
|
|
|
new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames,
|
2014-03-04 06:31:57 +04:00
|
|
|
corruptedFrames);
|
2013-06-21 07:14:18 +04:00
|
|
|
return playbackQuality.forget();
|
|
|
|
}
|
|
|
|
|
2013-05-10 16:42:39 +04:00
|
|
|
void
|
|
|
|
HTMLVideoElement::WakeLockCreate()
|
|
|
|
{
|
2014-03-18 12:44:41 +04:00
|
|
|
HTMLMediaElement::WakeLockCreate();
|
|
|
|
UpdateScreenWakeLock();
|
2013-05-10 16:42:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLVideoElement::WakeLockRelease()
|
|
|
|
{
|
2014-03-18 12:44:41 +04:00
|
|
|
UpdateScreenWakeLock();
|
|
|
|
HTMLMediaElement::WakeLockRelease();
|
2013-05-10 16:42:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-03-18 12:44:41 +04:00
|
|
|
HTMLVideoElement::UpdateScreenWakeLock()
|
2013-05-10 16:42:39 +04:00
|
|
|
{
|
2013-07-01 11:02:28 +04:00
|
|
|
bool hidden = OwnerDoc()->Hidden();
|
2013-05-10 16:42:39 +04:00
|
|
|
|
2015-09-02 16:18:16 +03:00
|
|
|
if (mScreenWakeLock && (mPaused || hidden || !mUseScreenWakeLock)) {
|
2014-01-07 16:16:07 +04:00
|
|
|
ErrorResult rv;
|
|
|
|
mScreenWakeLock->Unlock(rv);
|
2015-11-21 00:29:41 +03:00
|
|
|
rv.SuppressException();
|
2013-05-10 16:42:39 +04:00
|
|
|
mScreenWakeLock = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-02 16:18:16 +03:00
|
|
|
if (!mScreenWakeLock && !mPaused && !hidden &&
|
|
|
|
mUseScreenWakeLock && HasVideo()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<power::PowerManagerService> pmService =
|
2014-01-07 16:16:07 +04:00
|
|
|
power::PowerManagerService::GetInstance();
|
2013-05-10 16:42:39 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(pmService);
|
|
|
|
|
2014-01-07 16:16:07 +04:00
|
|
|
ErrorResult rv;
|
|
|
|
mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
|
|
|
|
OwnerDoc()->GetInnerWindow(),
|
|
|
|
rv);
|
2013-05-10 16:42:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-11 19:23:13 +04:00
|
|
|
void
|
|
|
|
HTMLVideoElement::Init()
|
|
|
|
{
|
|
|
|
Preferences::AddBoolVarCache(&sVideoStatsEnabled, "media.video_stats.enabled");
|
|
|
|
}
|
2014-07-13 06:20:42 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|