Bug 1156472 - Part 6 - Connect HTMLMediaElement and AudioContext to the capture stream when capturing is needed. r=roc
This commit is contained in:
@@ -2030,6 +2030,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
|
||||
mAllowCasting(false),
|
||||
mIsCasting(false),
|
||||
mAudioCaptured(false),
|
||||
mAudioCapturedByWindow(false),
|
||||
mPlayingBeforeSeek(false),
|
||||
mPlayingThroughTheAudioChannelBeforeSeek(false),
|
||||
mPausedForInactiveDocumentOrChannel(false),
|
||||
@@ -2097,6 +2098,11 @@ HTMLMediaElement::~HTMLMediaElement()
|
||||
EndSrcMediaStreamPlayback();
|
||||
}
|
||||
|
||||
if (mCaptureStreamPort) {
|
||||
mCaptureStreamPort->Destroy();
|
||||
mCaptureStreamPort = nullptr;
|
||||
}
|
||||
|
||||
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 0,
|
||||
"Destroyed media element should no longer be in element table");
|
||||
|
||||
@@ -4475,8 +4481,7 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
|
||||
(!mPaused &&
|
||||
(HasAttr(kNameSpaceID_None, nsGkAtoms::loop) ||
|
||||
(mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA &&
|
||||
!IsPlaybackEnded() &&
|
||||
(!mSrcStream || HasAudio())) ||
|
||||
!IsPlaybackEnded()) ||
|
||||
mPlayingThroughTheAudioChannelBeforeSeek));
|
||||
if (playingThroughTheAudioChannel != mPlayingThroughTheAudioChannel) {
|
||||
mPlayingThroughTheAudioChannel = playingThroughTheAudioChannel;
|
||||
@@ -4504,9 +4509,9 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
|
||||
void
|
||||
HTMLMediaElement::NotifyAudioChannelAgent(bool aPlaying)
|
||||
{
|
||||
// Immediately check if this should go to the MSG instead of the normal
|
||||
// media playback route.
|
||||
WindowAudioCaptureChanged();
|
||||
// Immediately check if this should go to the MSG instead of the normal
|
||||
// media playback route.
|
||||
WindowAudioCaptureChanged();
|
||||
|
||||
// This is needed to pass nsContentUtils::IsCallerChrome().
|
||||
// AudioChannel API should not called from content but it can happen that
|
||||
@@ -4681,11 +4686,33 @@ HTMLMediaElement::GetTopLevelPrincipal()
|
||||
|
||||
NS_IMETHODIMP HTMLMediaElement::WindowAudioCaptureChanged()
|
||||
{
|
||||
MOZ_ASSERT(mAudioChannelAgent);
|
||||
DebugOnly<bool> captured = OwnerDoc()->GetInnerWindow()->GetAudioCaptured();
|
||||
MOZ_ASSERT(mAudioChannelAgent);
|
||||
|
||||
// Something is going to happen here!!
|
||||
return NS_OK;
|
||||
if (!OwnerDoc()->GetInnerWindow()) {
|
||||
return NS_OK;
|
||||
}
|
||||
bool captured = OwnerDoc()->GetInnerWindow()->GetAudioCaptured();
|
||||
|
||||
if (captured != mAudioCapturedByWindow) {
|
||||
if (captured) {
|
||||
mAudioCapturedByWindow = true;
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(OwnerDoc()->GetParentObject());
|
||||
uint64_t id = window->WindowID();
|
||||
MediaStreamGraph* msg = MediaStreamGraph::GetInstance();
|
||||
|
||||
if (!mPlaybackStream) {
|
||||
nsRefPtr<DOMMediaStream> stream = CaptureStreamInternal(false, msg);
|
||||
mCaptureStreamPort = msg->ConnectToCaptureStream(id, stream->GetStream());
|
||||
} else {
|
||||
mCaptureStreamPort = msg->ConnectToCaptureStream(id, mPlaybackStream->GetStream());
|
||||
}
|
||||
} else {
|
||||
// TODO: uncapture
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AudioTrackList*
|
||||
|
||||
Reference in New Issue
Block a user