Skip to content

Commit

Permalink
Ignore case in MIME type checks
Browse files Browse the repository at this point in the history
Closes #1991

Change-Id: Ib76f7539ff5173fca1ddb409e33240e7e9d3fd11
  • Loading branch information
joeyparrish committed Jul 9, 2019
1 parent a6b0bb6 commit 85ba5e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/media/transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ shaka.media.Transmuxer = class {
* @return {boolean}
*/
static isTsContainer(mimeType) {
return mimeType.split(';')[0].split('/')[1] == 'mp2t';
return mimeType.toLowerCase().split(';')[0].split('/')[1] == 'mp2t';
}


Expand All @@ -106,7 +106,7 @@ shaka.media.Transmuxer = class {
*/
static convertTsCodecs(contentType, tsMimeType) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;
let mp4MimeType = tsMimeType.replace('mp2t', 'mp4');
let mp4MimeType = tsMimeType.replace(/mp2t/i, 'mp4');
if (contentType == ContentType.AUDIO) {
mp4MimeType = mp4MimeType.replace('video', 'audio');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/polyfill/mediasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ shaka.polyfill.MediaSource = class {
const basicMimeType = pieces[0];
const container = basicMimeType.split('/')[1];

if (container == 'mp2t') {
if (container.toLowerCase() == 'mp2t') {
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions test/media/transmuxer_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ describe('Transmuxer', () => {
expect(isSupported(transportStreamVideoMimeType, ContentType.VIDEO))
.toBe(true);
});

// Issue #1991
it('handles upper-case MIME types', () => {
const mimeType = transportStreamVideoMimeType.replace('mp2t', 'MP2T');
expect(isSupported(mimeType, ContentType.VIDEO)).toBe(true);
});
});

describe('convertTsCodecs', () => {
Expand Down Expand Up @@ -87,6 +93,13 @@ describe('Transmuxer', () => {
convertTsCodecs(ContentType.VIDEO, 'video/mp2t; codecs="avc1.66.1"'))
.toBe('video/mp4; codecs="avc1.420001"');
});

// Issue #1991
it('handles upper-case MIME types', () => {
expect(convertTsCodecs(
ContentType.VIDEO, 'video/MP2T; codecs="avc1.420001"'))
.toBe('video/mp4; codecs="avc1.420001"');
});
});

describe('transmuxing', () => {
Expand Down

0 comments on commit 85ba5e4

Please sign in to comment.