Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt
MozReview-Commit-ID: 6bMpKO6ccjd
--- 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.