Bug 1343437 - MFR::OnDemuxerInitDone forwards non-NS_OK MediaResult to HTMLMediaElement::DecodeWarning - r?jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 27 Feb 2017 10:44:42 +1100
changeset 493016 9427f7cc7e73bb6a2790a60a7d3e136d721572e7
parent 493015 1e04bc4863d1fe5e7d4d5e83ba6ce0e58d135e13
child 493017 6475ff690d974ef3b5cdf8f5142b815f06dfe345
push id47625
push usergsquelart@mozilla.com
push dateFri, 03 Mar 2017 05:16:08 +0000
reviewersjya
bugs1343437
milestone54.0a1
Bug 1343437 - MFR::OnDemuxerInitDone forwards non-NS_OK MediaResult to HTMLMediaElement::DecodeWarning - r?jya The MediaFormatReader now takes the MediaResult from the Demuxer::Init promise resolution, and if there are no other errors but the MediaResult is not NS_OK it will forward that warning to the decoder owner (i.e., the associated HTMLMediaElement). MozReview-Commit-ID: 5rTmzqqPLI0
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1254,17 +1254,17 @@ MediaFormatReader::AsyncReadMetadata()
     ->Then(OwnerThread(), __func__, this,
            &MediaFormatReader::OnDemuxerInitDone,
            &MediaFormatReader::OnDemuxerInitFailed)
     ->Track(mDemuxerInitRequest);
   return p;
 }
 
 void
-MediaFormatReader::OnDemuxerInitDone(nsresult)
+MediaFormatReader::OnDemuxerInitDone(const MediaResult& aResult)
 {
   MOZ_ASSERT(OnTaskQueue());
   mDemuxerInitRequest.Complete();
 
   mDemuxerInitDone = true;
 
   UniquePtr<MetadataTags> tags(MakeUnique<MetadataTags>());
 
@@ -1378,16 +1378,20 @@ MediaFormatReader::OnDemuxerInitDone(nsr
       RequestDemuxSamples(TrackInfo::kAudioTrack);
     }
 
     if (HasVideo()) {
       RequestDemuxSamples(TrackInfo::kVideoTrack);
     }
   }
 
+  if (aResult != NS_OK && mDecoder && mDecoder->GetOwner()) {
+    mDecoder->GetOwner()->DecodeWarning(aResult);
+  }
+
   MaybeResolveMetadataPromise();
 }
 
 void
 MediaFormatReader::MaybeResolveMetadataPromise()
 {
   MOZ_ASSERT(OnTaskQueue());
 
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -480,17 +480,17 @@ private:
   bool NeedInput(DecoderData& aDecoder);
 
   DecoderData& GetDecoderData(TrackType aTrack);
 
   // Demuxer objects.
   class DemuxerProxy;
   UniquePtr<DemuxerProxy> mDemuxer;
   bool mDemuxerInitDone;
-  void OnDemuxerInitDone(nsresult);
+  void OnDemuxerInitDone(const MediaResult& aResult);
   void OnDemuxerInitFailed(const MediaResult& aError);
   MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
   MozPromiseRequestHolder<NotifyDataArrivedPromise> mNotifyDataArrivedPromise;
   void OnDemuxFailed(TrackType aTrack, const MediaResult &aError);
 
   void DoDemuxVideo();
   void OnVideoDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples);
   void OnVideoDemuxFailed(const MediaResult& aError)