Bug 1320705: P6. Fix codec mimetypes. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 02 Dec 2016 12:23:23 +1100
changeset 325260 05a07920b83263f12235f283c5869be656dba405
parent 325259 7495e866529ebd20352e63eb2b25dfa688a7dfd2
child 325261 328475b7579ca8ef7b019703b9a10dfbc8a802dd
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersgerald
bugs1320705
milestone53.0a1
Bug 1320705: P6. Fix codec mimetypes. r=gerald MozReview-Commit-ID: FozWtbvDNnA
dom/media/ogg/OggDemuxer.cpp
dom/media/platforms/agnostic/OpusDecoder.cpp
dom/media/platforms/agnostic/TheoraDecoder.cpp
dom/media/platforms/agnostic/VorbisDecoder.cpp
dom/media/webm/WebMDemuxer.cpp
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -388,17 +388,17 @@ OggDemuxer::SetupTargetTheora(TheoraStat
   // Apply the aspect ratio to produce the intrinsic display size we report
   // to the element.
   ScaleDisplayByAspectRatio(displaySize, aTheoraState->mPixelAspectRatio);
 
   nsIntSize frameSize(aTheoraState->mInfo.frame_width,
                       aTheoraState->mInfo.frame_height);
   if (IsValidVideoRegion(frameSize, picture, displaySize)) {
     // Video track's frame sizes will not overflow. Activate the video track.
-    mInfo.mVideo.mMimeType = "video/ogg; codecs=theora";
+    mInfo.mVideo.mMimeType = "video/theora";
     mInfo.mVideo.mDisplay = displaySize;
     mInfo.mVideo.mImage = frameSize;
     mInfo.mVideo.SetImageRect(picture);
 
     // Copy Theora info data for time computations on other threads.
     memcpy(&mTheoraInfo, &aTheoraState->mInfo, sizeof(mTheoraInfo));
 
     // Save header packets for the decoder
@@ -418,17 +418,17 @@ OggDemuxer::SetupTargetVorbis(VorbisStat
   if (mVorbisState) {
     mVorbisState->Reset();
   }
 
   // Copy Vorbis info data for time computations on other threads.
   memcpy(&mVorbisInfo, &aVorbisState->mInfo, sizeof(mVorbisInfo));
   mVorbisInfo.codec_setup = nullptr;
 
-  mInfo.mAudio.mMimeType = "audio/ogg; codecs=vorbis";
+  mInfo.mAudio.mMimeType = "audio/vorbis";
   mInfo.mAudio.mRate = aVorbisState->mInfo.rate;
   mInfo.mAudio.mChannels = aVorbisState->mInfo.channels;
 
   // Save header packets for the decoder
   if (!XiphHeadersToExtradata(mInfo.mAudio.mCodecSpecificConfig,
                               aHeaders.mHeaders, aHeaders.mHeaderLens)) {
     return;
   }
@@ -439,17 +439,17 @@ OggDemuxer::SetupTargetVorbis(VorbisStat
 
 void
 OggDemuxer::SetupTargetOpus(OpusState* aOpusState, OggHeaders& aHeaders)
 {
   if (mOpusState) {
     mOpusState->Reset();
   }
 
-  mInfo.mAudio.mMimeType = "audio/ogg; codecs=opus";
+  mInfo.mAudio.mMimeType = "audio/opus";
   mInfo.mAudio.mRate = aOpusState->mRate;
   mInfo.mAudio.mChannels = aOpusState->mChannels;
 
   // Save preskip & the first header packet for the Opus decoder
   uint64_t preSkip = aOpusState->Time(0, aOpusState->mPreSkip);
   uint8_t c[sizeof(preSkip)];
   BigEndian::writeUint64(&c[0], preSkip);
   mInfo.mAudio.mCodecSpecificConfig->AppendElements(&c[0], sizeof(preSkip));
@@ -825,17 +825,17 @@ OggDemuxer::ReadOggChain(const media::Ti
       (mVorbisState->mInfo.channels == newVorbisState->mInfo.channels)) {
 
     SetupTargetVorbis(newVorbisState, vorbisHeaders);
     LOG(LogLevel::Debug, ("New vorbis ogg link, serial=%d\n", mVorbisSerial));
 
     if (msgInfo) {
       InitTrack(msgInfo, &mInfo.mAudio, true);
     }
-    mInfo.mAudio.mMimeType = NS_LITERAL_CSTRING("audio/ogg; codec=vorbis");
+    mInfo.mAudio.mMimeType = NS_LITERAL_CSTRING("audio/vorbis");
     mInfo.mAudio.mRate = newVorbisState->mInfo.rate;
     mInfo.mAudio.mChannels = newVorbisState->mInfo.channels;
 
     chained = true;
     tags = newVorbisState->GetTags();
   }
 
   OggHeaders opusHeaders;
@@ -844,17 +844,17 @@ OggDemuxer::ReadOggChain(const media::Ti
       (mOpusState->mRate == newOpusState->mRate) &&
       (mOpusState->mChannels == newOpusState->mChannels)) {
 
     SetupTargetOpus(newOpusState, opusHeaders);
 
     if (msgInfo) {
       InitTrack(msgInfo, &mInfo.mAudio, true);
     }
-    mInfo.mAudio.mMimeType = NS_LITERAL_CSTRING("audio/ogg; codec=opus");
+    mInfo.mAudio.mMimeType = NS_LITERAL_CSTRING("audio/opus");
     mInfo.mAudio.mRate = newOpusState->mRate;
     mInfo.mAudio.mChannels = newOpusState->mChannels;
 
     chained = true;
     tags = newOpusState->GetTags();
   }
 
   OggHeaders flacHeaders;
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -335,16 +335,13 @@ OpusDataDecoder::Flush()
   SyncRunnable::DispatchToThread(mTaskQueue, runnable);
   mIsFlushing = false;
 }
 
 /* static */
 bool
 OpusDataDecoder::IsOpus(const nsACString& aMimeType)
 {
-  return aMimeType.EqualsLiteral("audio/webm; codecs=opus") ||
-         aMimeType.EqualsLiteral("audio/ogg; codecs=opus") ||
-         aMimeType.EqualsLiteral("audio/mp4; codecs=opus") ||
-         aMimeType.EqualsLiteral("audio/opus");
+  return aMimeType.EqualsLiteral("audio/opus");
 }
 
 } // namespace mozilla
 #undef OPUS_DEBUG
--- a/dom/media/platforms/agnostic/TheoraDecoder.cpp
+++ b/dom/media/platforms/agnostic/TheoraDecoder.cpp
@@ -228,13 +228,13 @@ TheoraDecoder::Drain()
   MOZ_ASSERT(mCallback->OnReaderTaskQueue());
   mTaskQueue->Dispatch(NewRunnableMethod(this, &TheoraDecoder::ProcessDrain));
 }
 
 /* static */
 bool
 TheoraDecoder::IsTheora(const nsACString& aMimeType)
 {
-  return aMimeType.EqualsLiteral("video/ogg; codecs=theora");
+  return aMimeType.EqualsLiteral("video/theora");
 }
 
 } // namespace mozilla
 #undef LOG
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -283,18 +283,17 @@ VorbisDataDecoder::Flush()
   SyncRunnable::DispatchToThread(mTaskQueue, r);
   mIsFlushing = false;
 }
 
 /* static */
 bool
 VorbisDataDecoder::IsVorbis(const nsACString& aMimeType)
 {
-  return aMimeType.EqualsLiteral("audio/webm; codecs=vorbis") ||
-         aMimeType.EqualsLiteral("audio/ogg; codecs=vorbis");
+  return aMimeType.EqualsLiteral("audio/vorbis");
 }
 
 /* static */ const AudioConfig::Channel*
 VorbisDataDecoder::VorbisLayout(uint32_t aChannels)
 {
   // From https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html
   // Section 4.3.9.
   typedef AudioConfig::Channel Channel;
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -395,19 +395,19 @@ WebMDemuxer::ReadMetadata()
       if (r == -1) {
         return NS_ERROR_FAILURE;
       }
 
       mAudioTrack = track;
       mHasAudio = true;
       mAudioCodec = nestegg_track_codec_id(context, track);
       if (mAudioCodec == NESTEGG_CODEC_VORBIS) {
-        mInfo.mAudio.mMimeType = "audio/webm; codecs=vorbis";
+        mInfo.mAudio.mMimeType = "audio/vorbis";
       } else if (mAudioCodec == NESTEGG_CODEC_OPUS) {
-        mInfo.mAudio.mMimeType = "audio/webm; codecs=opus";
+        mInfo.mAudio.mMimeType = "audio/opus";
         OpusDataDecoder::AppendCodecDelay(mInfo.mAudio.mCodecSpecificConfig,
             media::TimeUnit::FromNanoseconds(params.codec_delay).ToMicroseconds());
       }
       mSeekPreroll = params.seek_preroll;
       mInfo.mAudio.mRate = params.rate;
       mInfo.mAudio.mChannels = params.channels;
 
       unsigned int nheaders = 0;