Backed out changeset f3b3547c610a (bug 1144409) for eme test failures CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Mon, 23 Mar 2015 16:06:32 -0700
changeset 265479 dd850ffd05bc3277c4ea52b8ca113b36871ba84c
parent 265478 7167a20b3bf885e1b1eedd3ae43a967e8771384d
child 265480 812ea3cdd997ed7f58238c3ff267f302a31bd5a3
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1144409
milestone39.0a1
backs outf3b3547c610ab0d7a923b8ac80730a8f33349b1e
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset f3b3547c610a (bug 1144409) for eme test failures CLOSED TREE
dom/html/HTMLMediaElement.cpp
dom/media/MediaInfo.h
dom/media/fmp4/MP4Reader.cpp
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3088,20 +3088,17 @@ void HTMLMediaElement::MetadataLoaded(co
   }
   if (mIsEncrypted) {
     if (!mMediaSource) {
       DecodeError();
       return;
     }
 
 #ifdef MOZ_EME
-    // Dispatch a distinct 'encrypted' event for each initData we have.
-    for (const auto& initData : aInfo->mCrypto.mInitDatas) {
-      DispatchEncrypted(initData.mInitData, initData.mType);
-    }
+    DispatchEncrypted(aInfo->mCrypto.mInitData, aInfo->mCrypto.mType);
 #endif
   }
 
   // Expose the tracks to JS directly.
   for (OutputMediaStream& out : mOutputStreams) {
     if (aInfo->HasAudio()) {
       TrackID audioTrackId = aInfo->mAudio.mTrackInfo.mOutputId;
       out.mStream->CreateDOMTrack(audioTrackId, MediaSegment::AUDIO);
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -100,66 +100,43 @@ public:
   // True if we have an active audio bitstream.
   bool mHasAudio;
 
   TrackInfo mTrackInfo;
 };
 
 class EncryptionInfo {
 public:
-  struct InitData {
-    InitData(const nsString& aType, nsTArray<uint8_t>&& aInitData)
-      : mType(aType)
-      , mInitData(Move(aInitData))
-    {
-    }
+  EncryptionInfo() : mIsEncrypted(false) {}
 
-    // Encryption type to be passed to JS. Usually `cenc'.
-    nsString mType;
+  // Encryption type to be passed to JS. Usually `cenc'.
+  nsString mType;
 
-    // Encryption data.
-    nsTArray<uint8_t> mInitData;
-  };
-  typedef nsTArray<InitData> InitDatas;
+  // Encryption data.
+  nsTArray<uint8_t> mInitData;
 
   // True if the stream has encryption metadata
-  bool IsEncrypted() const
-  {
-    return !mInitDatas.IsEmpty();
-  }
-
-  void AddInitData(const nsString& aType, nsTArray<uint8_t>&& aInitData)
-  {
-    mInitDatas.AppendElement(InitData(aType, Move(aInitData)));
-  }
-
-  void AddInitData(const EncryptionInfo& aInfo)
-  {
-    mInitDatas.AppendElements(aInfo.mInitDatas);
-  }
-
-  // One 'InitData' per encrypted buffer.
-  InitDatas mInitDatas;
+  bool mIsEncrypted;
 };
 
 class MediaInfo {
 public:
   bool HasVideo() const
   {
     return mVideo.mHasVideo;
   }
 
   bool HasAudio() const
   {
     return mAudio.mHasAudio;
   }
 
   bool IsEncrypted() const
   {
-    return mCrypto.IsEncrypted();
+    return mCrypto.mIsEncrypted;
   }
 
   bool HasValidMedia() const
   {
     return HasVideo() || HasAudio();
   }
 
   // TODO: Store VideoInfo and AudioIndo in arrays to support multi-tracks.
--- a/dom/media/fmp4/MP4Reader.cpp
+++ b/dom/media/fmp4/MP4Reader.cpp
@@ -363,17 +363,17 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo
     if (mAudio.mActive) {
       mAudio.mTrackDemuxer = new MP4AudioDemuxer(mDemuxer);
     }
     mCrypto = mDemuxer->Crypto();
 
     {
       MonitorAutoUnlock unlock(mDemuxerMonitor);
       ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-      mIsEncrypted = mCrypto.valid;
+      mInfo.mCrypto.mIsEncrypted = mIsEncrypted = mCrypto.valid;
     }
 
     // Remember that we've initialized the demuxer, so that if we're decoding
     // an encrypted stream and we need to wait for a CDM to be set, we don't
     // need to reinit the demuxer.
     mDemuxerInitialized = true;
   } else if (mPlatform && !IsWaitingMediaResources()) {
     *aInfo = mInfo;
@@ -395,24 +395,25 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo
     mVideo.mCallback = new DecoderCallback(this, kVideo);
 
     // Collect telemetry from h264 AVCC SPS.
     if (!mFoundSPSForTelemetry) {
       mFoundSPSForTelemetry = AccumulateSPSTelemetry(video.extra_data);
     }
   }
 
-  if (mCrypto.valid) {
+  if (mIsEncrypted) {
     nsTArray<uint8_t> initData;
     ExtractCryptoInitData(initData);
     if (initData.Length() == 0) {
       return NS_ERROR_FAILURE;
     }
 
-    mInfo.mCrypto.AddInitData(NS_LITERAL_STRING("cenc"), Move(initData));
+    mInfo.mCrypto.mInitData = initData;
+    mInfo.mCrypto.mType = NS_LITERAL_STRING("cenc");
   }
 
   // Get the duration, and report it to the decoder if we have it.
   Microseconds duration;
   {
     MonitorAutoLock lock(mDemuxerMonitor);
     duration = mDemuxer->Duration();
   }
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -1054,16 +1054,32 @@ MediaSourceReader::MaybeNotifyHaveData()
     if (ended || haveVideo) {
       WaitPromise(MediaData::VIDEO_DATA).ResolveIfExists(MediaData::VIDEO_DATA, __func__);
     }
   }
   MSE_DEBUG("isSeeking=%d haveAudio=%d, haveVideo=%d ended=%d",
             IsSeeking(), haveAudio, haveVideo, ended);
 }
 
+static void
+CombineEncryptionData(EncryptionInfo& aTo, const EncryptionInfo& aFrom)
+{
+  if (!aFrom.mIsEncrypted) {
+    return;
+  }
+  aTo.mIsEncrypted = true;
+
+  if (!aTo.mType.IsEmpty() && !aTo.mType.Equals(aFrom.mType)) {
+    NS_WARNING("mismatched encryption types");
+  }
+
+  aTo.mType = aFrom.mType;
+  aTo.mInitData.AppendElements(aFrom.mInitData);
+}
+
 nsresult
 MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
 
   MSE_DEBUG("tracks=%u/%u audio=%p video=%p",
             mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
             mAudioTrack.get(), mVideoTrack.get());
@@ -1077,30 +1093,30 @@ MediaSourceReader::ReadMetadata(MediaInf
 
   if (mAudioTrack) {
     MOZ_ASSERT(mAudioTrack->IsReady());
     mAudioSourceDecoder = mAudioTrack->Decoders()[0];
 
     const MediaInfo& info = GetAudioReader()->GetMediaInfo();
     MOZ_ASSERT(info.HasAudio());
     mInfo.mAudio = info.mAudio;
-    mInfo.mCrypto.AddInitData(info.mCrypto);
+    CombineEncryptionData(mInfo.mCrypto, info.mCrypto);
     MSE_DEBUG("audio reader=%p duration=%lld",
               mAudioSourceDecoder.get(),
               mAudioSourceDecoder->GetReader()->GetDecoder()->GetMediaDuration());
   }
 
   if (mVideoTrack) {
     MOZ_ASSERT(mVideoTrack->IsReady());
     mVideoSourceDecoder = mVideoTrack->Decoders()[0];
 
     const MediaInfo& info = GetVideoReader()->GetMediaInfo();
     MOZ_ASSERT(info.HasVideo());
     mInfo.mVideo = info.mVideo;
-    mInfo.mCrypto.AddInitData(info.mCrypto);
+    CombineEncryptionData(mInfo.mCrypto, info.mCrypto);
     MSE_DEBUG("video reader=%p duration=%lld",
               GetVideoReader(),
               GetVideoReader()->GetDecoder()->GetMediaDuration());
   }
 
   *aInfo = mInfo;
   *aTags = nullptr; // TODO: Handle metadata.