Skip to content

Commit

Permalink
Make matroska mime type checking more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVreeken authored and roytam1 committed Jul 12, 2019
1 parent a960d67 commit 68c810a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dom/media/mediasource/ContainerParser.cpp
Expand Up @@ -697,7 +697,7 @@ ContainerParser::CreateForMIMEType(const nsACString& aType)
if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) {
return new WebMContainerParser(aType);
}
if (aType.LowerCaseEqualsLiteral("video/x-matroska")) {
if (aType.LowerCaseEqualsLiteral("video/x-matroska") || aType.LowerCaseEqualsLiteral("audio/x-matroska")) {
return new WebMContainerParser(aType);
}

Expand Down
3 changes: 2 additions & 1 deletion dom/media/mediasource/MediaSource.cpp
Expand Up @@ -118,7 +118,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a
}
return NS_OK;
}
if (mimeType.EqualsASCII("audio/webm")) {
if (mimeType.EqualsASCII("audio/webm") ||
mimeType.EqualsASCII("audio/x-matroska")) {
if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
Preferences::GetBool("media.mediasource.webm.audio.enabled", true))) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
Expand Down
1 change: 1 addition & 0 deletions dom/media/mediasource/TrackBuffersManager.cpp
Expand Up @@ -815,6 +815,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType()

if (mType.LowerCaseEqualsLiteral("video/webm") ||
mType.LowerCaseEqualsLiteral("video/x-matroska") ||
mType.LowerCaseEqualsLiteral("audio/x-matroska") ||
mType.LowerCaseEqualsLiteral("audio/webm")) {
mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ );
return;
Expand Down
9 changes: 6 additions & 3 deletions dom/media/webm/WebMDecoder.cpp
Expand Up @@ -41,8 +41,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
}

const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm");
const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ;
if (!isWebMAudio && !isWebMVideo) {
const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm");
const bool isMatroskaAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/x-matroska") ;
const bool isMatroskaVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ;

if (!isWebMAudio && !isWebMVideo && !isMatroskaAudio && !isMatroskaVideo) {
return false;
}

Expand All @@ -63,7 +66,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs,
}
// Note: Only accept VP8/VP9 in a video content type, not in an audio
// content type.
if (isWebMVideo &&
if ((isWebMVideo || isMatroskaVideo) &&
(codec.EqualsLiteral("vp8") || codec.EqualsLiteral("vp8.0") ||
codec.EqualsLiteral("vp9") || codec.EqualsLiteral("vp9.0"))) {

Expand Down

0 comments on commit 68c810a

Please sign in to comment.