Bug 1298777 - don't need to capture audio for media element without audio track.
MozReview-Commit-ID: DKRGiuTGjtg
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -6545,17 +6545,26 @@ HTMLMediaElement::SetMediaInfo(const Med
{
mMediaInfo = aInfo;
AudioCaptureStreamChangeIfNeeded();
}
void
HTMLMediaElement::AudioCaptureStreamChangeIfNeeded()
{
- // TODO : only capture media element with audio track, see bug1298777.
+ // Window audio capturing only happens after creating audio channel agent.
+ if (!mAudioChannelAgent) {
+ return;
+ }
+
+ // No need to capture a silence media element.
+ if (!HasAudio()) {
+ return;
+ }
+
if (mAudioCapturedByWindow && !mCaptureStreamPort) {
nsCOMPtr<nsPIDOMWindowInner> window = OwnerDoc()->GetInnerWindow();
if (!OwnerDoc()->GetInnerWindow()) {
return;
}
uint64_t id = window->WindowID();
MediaStreamGraph* msg =