Skip to content

Commit

Permalink
fix: Fix case sensitivity for drm content type (#2800)
Browse files Browse the repository at this point in the history
This fixes the case sensitivity in the `DrmEngine` `willSupport` method. This comparison should be case insensitive, particularly for codec profiles described in hex which may be either lower or upper case. The change normalizes both the stored content types and the method arguments.

Closes #2799
  • Loading branch information
Stansbridge authored Aug 20, 2020
1 parent a22df6d commit 8b36acf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Adrián Gómez Llorente <[email protected]>
Alex Jones <[email protected]>
Alugha GmbH <*@alugha.com>
Alvaro Velad Galvan <[email protected]>
Anthony Stansbridge <[email protected]>
Bonnier Broadcasting <*@bonnierbroadcasting.com>
Bryan Huh <[email protected]>
Esteban Dosztal <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Aaron Vaage <[email protected]>
Alex Jones <[email protected]>
Alvaro Velad Galvan <[email protected]>
Andy Hochhaus <[email protected]>
Anthony Stansbridge <[email protected]>
Ashutosh Kumar Mukhiya <[email protected]>
Benjamin Wallberg <[email protected]>
Boris Cupac <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ shaka.media.DrmEngine = class {
return true;
}

return this.supportedTypes_.has(contentType);
return this.supportedTypes_.has(contentType.toLowerCase());
}

/**
Expand Down Expand Up @@ -831,11 +831,11 @@ shaka.media.DrmEngine = class {
const videoCaps = realConfig.videoCapabilities || [];

for (const cap of audioCaps) {
this.supportedTypes_.add(cap.contentType);
this.supportedTypes_.add(cap.contentType.toLowerCase());
}

for (const cap of videoCaps) {
this.supportedTypes_.add(cap.contentType);
this.supportedTypes_.add(cap.contentType.toLowerCase());
}

goog.asserts.assert(this.supportedTypes_.size,
Expand Down
1 change: 1 addition & 0 deletions test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ describe('DrmEngine', () => {
expect(drmEngine.initialized()).toBe(true);
expect(drmEngine.willSupport('audio/webm')).toBeTruthy();
expect(drmEngine.willSupport('video/mp4; codecs="fake"')).toBeTruthy();
expect(drmEngine.willSupport('video/mp4; codecs="FAKE"')).toBeTruthy();

// Because DrmEngine will err on being too accepting, make sure it will
// reject something. However, we can only check that it is actually
Expand Down

0 comments on commit 8b36acf

Please sign in to comment.