Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 05 Jan 2016 10:16:27 +0800
changeset 342133 6092f83a0f42b67d75fb998a975b990d92eab9aa
parent 342132 475f9404726f7dbee9f0e199b4cd7db2d4715294
child 342134 e38700f246f8924cc7c4635aef4d9f18fd21c268
push id13352
push userpehrsons@gmail.com
push dateFri, 18 Mar 2016 13:49:47 +0000
reviewersmt
bugs1208371
milestone47.0a1
Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt MozReview-Commit-ID: 6bMpKO6ccjd
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1881,16 +1881,21 @@ public:
     mElement->AddDecoderPrincipalChangeObserver(this);
   }
 
   MediaSourceEnum GetMediaSource() const override
   {
     return MediaSourceEnum::Other;
   }
 
+  CORSMode GetCORSMode() const override
+  {
+    return mElement->GetCORSMode();
+  }
+
   already_AddRefed<Promise>
   ApplyConstraints(nsPIDOMWindowInner* aWindow,
                    const dom::MediaTrackConstraints& aConstraints,
                    ErrorResult &aRv) override
   {
     NS_ERROR("ApplyConstraints not implemented for media element capture");
     return nullptr;
   }
@@ -1995,17 +2000,16 @@ HTMLMediaElement::CaptureStreamInternal(
   if (!mOutputStreams.IsEmpty() &&
       aGraph != mOutputStreams[0].mStream->GetInputStream()->Graph()) {
     return nullptr;
   }
 
   OutputMediaStream* out = mOutputStreams.AppendElement();
   MediaStreamTrackSourceGetter* getter = new CaptureStreamTrackSourceGetter(this);
   out->mStream = DOMMediaStream::CreateTrackUnionStream(window, aGraph, getter);
-  out->mStream->SetCORSMode(mCORSMode);
   out->mFinishWhenEnded = aFinishWhenEnded;
 
   mAudioCaptured = true;
   if (mDecoder) {
     mDecoder->AddOutputStream(out->mStream->GetInputStream()->AsProcessedStream(),
                               aFinishWhenEnded);
     if (mReadyState >= HAVE_METADATA) {
       // Expose the tracks to JS directly.
@@ -4271,20 +4275,16 @@ already_AddRefed<nsIPrincipal> HTMLMedia
 }
 
 void HTMLMediaElement::NotifyDecoderPrincipalChanged()
 {
   RefPtr<nsIPrincipal> principal = GetCurrentPrincipal();
 
   mDecoder->UpdateSameOriginStatus(!principal || IsCORSSameOrigin());
 
-  for (OutputMediaStream& ms : mOutputStreams) {
-    ms.mStream->SetCORSMode(mCORSMode);
-  }
-
   for (DecoderPrincipalChangeObserver* observer :
          mDecoderPrincipalChangeObservers) {
     observer->NotifyDecoderPrincipalChanged();
   }
 }
 
 void HTMLMediaElement::AddDecoderPrincipalChangeObserver(DecoderPrincipalChangeObserver* aObserver)
 {
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -263,17 +263,17 @@ public:
   // of this element must have a principal that subsumes this principal.
   // Returns null if nothing is playing.
   already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
 
   // called to notify that the principal of the decoder's media resource has changed.
   void NotifyDecoderPrincipalChanged() final override;
 
   // An interface for observing principal changes on the media elements
-  // MediaDecoder.
+  // MediaDecoder. This will also be notified if the active CORSMode changes.
   class DecoderPrincipalChangeObserver
   {
   public:
     virtual void NotifyDecoderPrincipalChanged() = 0;
   };
 
   /**
    * Add a DecoderPrincipalChangeObserver to this media element.