Skip to content

Commit

Permalink
Bug 1718223 - Allow pref to control max throughput of EME decryption …
Browse files Browse the repository at this point in the history
…r=bryce

Adds a pref `media.eme.max-throughput-ms` to allow users to modify EME's maximum decryption rate. The default value is 200ms which is the same as the old hard-coded value.

Differential Revision: https://phabricator.services.mozilla.com/D122876
  • Loading branch information
iidebyo committed Aug 18, 2021
1 parent 8f12a28 commit 228fb46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions dom/media/platforms/agnostic/eme/DecryptThroughputLimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ namespace mozilla {

// We throttle our decrypt so that we don't decrypt more than a certain
// duration of samples per second. This is to work around bugs in the
// Widevine CDM. See bug 1338924 and bug 1342822.
// Widevine CDM. See bugs 1338924, 1342822, 1718223.
class DecryptThroughputLimit {
public:
explicit DecryptThroughputLimit(nsISerialEventTarget* aTargetThread)
: mThrottleScheduler(aTargetThread) {}
explicit DecryptThroughputLimit(nsISerialEventTarget* aTargetThread,
uint32_t aMaxThroughputMs)
: mThrottleScheduler(aTargetThread),
mMaxThroughput(aMaxThroughputMs / 1000.0) {}

typedef MozPromise<RefPtr<MediaRawData>, MediaResult, true> ThrottlePromise;

Expand All @@ -31,7 +33,8 @@ class DecryptThroughputLimit {
MOZ_RELEASE_ASSERT(!mThrottleScheduler.IsScheduled());

const TimeDuration WindowSize = TimeDuration::FromSeconds(0.1);
const TimeDuration MaxThroughput = TimeDuration::FromSeconds(0.2);
const TimeDuration MaxThroughput =
TimeDuration::FromSeconds(mMaxThroughput);

// Forget decrypts that happened before the start of our window.
const TimeStamp now = TimeStamp::Now();
Expand Down Expand Up @@ -86,6 +89,8 @@ class DecryptThroughputLimit {
DelayedScheduler mThrottleScheduler;
MozPromiseHolder<ThrottlePromise> mPromiseHolder;

double mMaxThroughput;

struct DecryptedJob {
TimeStamp mTimestamp;
TimeDuration mSampleDuration;
Expand Down
4 changes: 3 additions & 1 deletion dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class EMEDecryptor : public MediaDataDecoder,
RefPtr<InitPromise> Init() override {
MOZ_ASSERT(!mIsShutdown);
mThread = GetCurrentSerialEventTarget();
mThroughputLimiter.emplace(mThread);
uint32_t maxThroughputMs = StaticPrefs::media_eme_max_throughput_ms();
EME_LOG("EME max-throughput-ms=%" PRIu32, maxThroughputMs);
mThroughputLimiter.emplace(mThread, maxThroughputMs);

return mDecoder->Init();
}
Expand Down
5 changes: 5 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8044,6 +8044,11 @@
value: false
mirror: always

- name: media.eme.max-throughput-ms
type: RelaxedAtomicUint32
value: 200
mirror: always

- name: media.clearkey.persistent-license.enabled
type: bool
value: false
Expand Down

0 comments on commit 228fb46

Please sign in to comment.