зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1540573 - P5. Only "always throttle" media download to the readahead on cellular connections. r=jya
Normally when downloading media data we throttle the download only if we're ahead of the read cursor more than the "readahead limit", and if we estimate that the connection is fast enough that we'll be able to download at a rate fast enough to playback in real time if we resume it later. On mobile we additionally override this so that we always throttle the download once we're ahead of the read cursor by the readahead limit. This is to save data. I think we can relax this to only do this override if we're on a cellular connection; if we're on WiFi we can assume data is cheap. Differential Revision: https://phabricator.services.mozilla.com/D26234 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c13f163bd6
Коммит
c957fbd2ef
|
@ -11,6 +11,7 @@
|
||||||
#include "BaseMediaResource.h"
|
#include "BaseMediaResource.h"
|
||||||
#include "MediaShutdownManager.h"
|
#include "MediaShutdownManager.h"
|
||||||
#include "mozilla/StaticPrefs.h"
|
#include "mozilla/StaticPrefs.h"
|
||||||
|
#include "VideoUtils.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -458,8 +459,9 @@ MediaStatistics ChannelMediaDecoder::GetStatistics(
|
||||||
bool ChannelMediaDecoder::ShouldThrottleDownload(
|
bool ChannelMediaDecoder::ShouldThrottleDownload(
|
||||||
const MediaStatistics& aStats) {
|
const MediaStatistics& aStats) {
|
||||||
// We throttle the download if either the throttle override pref is set
|
// We throttle the download if either the throttle override pref is set
|
||||||
// (so that we can always throttle in Firefox on mobile) or if the download
|
// (so that we always throttle at the readahead limit on mobile if using
|
||||||
// is fast enough that there's no concern about playback being interrupted.
|
// a cellular network) or if the download is fast enough that there's no
|
||||||
|
// concern about playback being interrupted.
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
NS_ENSURE_TRUE(GetStateMachine(), false);
|
NS_ENSURE_TRUE(GetStateMachine(), false);
|
||||||
|
|
||||||
|
@ -472,8 +474,9 @@ bool ChannelMediaDecoder::ShouldThrottleDownload(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Preferences::GetBool("media.throttle-regardless-of-download-rate",
|
if (OnCellularConnection() &&
|
||||||
false)) {
|
Preferences::GetBool(
|
||||||
|
"media.throttle-cellular-regardless-of-download-rate", false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,9 +553,10 @@ pref("browser.meta_refresh_when_inactive.disabled", true);
|
||||||
// prevent video elements from preloading too much data
|
// prevent video elements from preloading too much data
|
||||||
pref("media.preload.default", 1); // default to preload none
|
pref("media.preload.default", 1); // default to preload none
|
||||||
pref("media.preload.auto", 2); // preload metadata if preload=auto
|
pref("media.preload.auto", 2); // preload metadata if preload=auto
|
||||||
// On mobile we'll throttle the download once the readahead_limit is hit,
|
// On mobile we throttle the download once the readahead_limit is hit
|
||||||
// even if the download is slow. This is to preserve battery and data.
|
// if we're using a cellular connection, even if the download is slow.
|
||||||
pref("media.throttle-regardless-of-download-rate", true);
|
// This is to preserve battery and data.
|
||||||
|
pref("media.throttle-cellular-regardless-of-download-rate", true);
|
||||||
|
|
||||||
// Number of video frames we buffer while decoding video.
|
// Number of video frames we buffer while decoding video.
|
||||||
// On Android this is decided by a similar value which varies for
|
// On Android this is decided by a similar value which varies for
|
||||||
|
|
Загрузка…
Ссылка в новой задаче