Diff
Modified: tags/Safari-604.1.23.0.3/LayoutTests/ChangeLog (217633 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/ChangeLog 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/LayoutTests/ChangeLog 2017-05-31 22:49:40 UTC (rev 217634)
@@ -1,3 +1,21 @@
+2017-05-31 Matthew Hanson <matthew_han...@apple.com>
+
+ Cherry-pick r217624. rdar://problem/32493091
+
+ 2017-05-31 Youenn Fablet <you...@apple.com>
+
+ PeerConnection should respect tracks that are muted at the time they are added
+ https://bugs.webkit.org/show_bug.cgi?id=172771
+
+ Reviewed by Eric Carlson.
+
+ * webrtc/audio-replace-track.html:
+ * webrtc/peer-connection-audio-unmute-expected.txt: Added.
+ * webrtc/peer-connection-audio-unmute.html: Added.
+ * webrtc/routines.js:
+ * webrtc/video-unmute-expected.txt: Added.
+ * webrtc/video-unmute.html: Added.
+
2017-05-24 Chris Dumez <cdu...@apple.com>
ResourceResponses for data URLs have their Source marked as Unknown
Modified: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/audio-replace-track.html (217633 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/audio-replace-track.html 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/audio-replace-track.html 2017-05-31 22:49:40 UTC (rev 217634)
@@ -9,18 +9,6 @@
</head>
<body>
<script>
- async function doHumAnalysis(stream, expected)
- {
- var context = new webkitAudioContext();
- for (var cptr = 0; cptr < 10; cptr++) {
- var results = await analyseAudio(stream, 200, context);
- if (results.heardHum === expected)
- return true;
- }
- await context.close();
- return false;
- }
-
var sender;
var remoteStream;
var secondStream;
Added: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute-expected.txt (0 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute-expected.txt (rev 0)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute-expected.txt 2017-05-31 22:49:40 UTC (rev 217634)
@@ -0,0 +1,3 @@
+
+PASS Muting a local audio track before adding it should be correctly handled
+
Added: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute.html (0 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute.html (rev 0)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/peer-connection-audio-unmute.html 2017-05-31 22:49:40 UTC (rev 217634)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>A muted audio track that is added should not cause audio to be sent</title>
+ <script src=""
+ <script src=""
+</head>
+<body>
+ <script src =""
+ <script>
+ promise_test((test) => {
+ if (window.testRunner)
+ testRunner.setUserMediaPermission(true);
+
+ var localTrack;
+ return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
+ localTrack = localStream.getAudioTracks()[0];
+ localTrack.enabled = false;
+ var remoteStream;
+ return new Promise((resolve, reject) => {
+ createConnections((firstConnection) => {
+ firstConnection.addTrack(localTrack, localStream);
+ }, (secondConnection) => {
+ secondConnection._ontrack_ = (trackEvent) => {
+ remoteStream = trackEvent.streams[0];
+ resolve();
+ };
+ });
+ }).then(() => {
+ return doHumAnalysis(remoteStream, false).then((result) => {
+ assert_true(result, "Should not hear hum");
+ });
+ }).then(() => {
+ localTrack.enabled = true;
+ }).then(() => {
+ return doHumAnalysis(remoteStream, true).then((result) => {
+ assert_true(result, "Should hear hum");
+ });
+ });
+ });
+ }, "Muting a local audio track before adding it should be correctly handled");
+ </script>
+</body>
+</html>
Modified: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/routines.js (217633 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/routines.js 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/routines.js 2017-05-31 22:49:40 UTC (rev 217634)
@@ -130,3 +130,15 @@
{
return new Promise((resolve) => setTimeout(resolve, duration));
}
+
+async function doHumAnalysis(stream, expected)
+{
+ var context = new webkitAudioContext();
+ for (var cptr = 0; cptr < 10; cptr++) {
+ var results = await analyseAudio(stream, 200, context);
+ if (results.heardHum === expected)
+ return true;
+ }
+ await context.close();
+ return false;
+}
Added: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute-expected.txt (0 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute-expected.txt (rev 0)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute-expected.txt 2017-05-31 22:49:40 UTC (rev 217634)
@@ -0,0 +1,6 @@
+
+
+PASS Setting video exchange
+PASS Track is enabled, video should be black
+PASS Track is enabled, video should not be black
+
Added: tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute.html (0 => 217634)
--- tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute.html (rev 0)
+++ tags/Safari-604.1.23.0.3/LayoutTests/webrtc/video-unmute.html 2017-05-31 22:49:40 UTC (rev 217634)
@@ -0,0 +1,90 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Testing basic video exchange from offerer to receiver</title>
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <video id="localVideo" autoplay playsInline width="320" height="240"></video>
+ <video id="video" autoplay playsInline width="320" height="240"></video>
+ <canvas id="canvas1" width="320" height="240"></canvas>
+ <canvas id="canvas2" width="320" height="240"></canvas>
+ <canvas id="canvas3" width="320" height="240"></canvas>
+ <script src =""
+ <script>
+function isVideoBlack(id)
+{
+ var canvas = document.getElementById(id);
+ canvas.width = video.videoWidth;
+ canvas.height = video.videoHeight;
+ canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
+
+ imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
+ data = ""
+ for (var cptr = 0; cptr < canvas.width * canvas.height; ++cptr) {
+ // Approximatively black pixels.
+ if (data[4 * cptr] > 10 || data[4 * cptr + 1] > 10 || data[4 * cptr + 2] > 10)
+ return false;
+ }
+ return true;
+}
+
+function pollVideoBlackCheck(expected, id, resolve)
+{
+ if (isVideoBlack(id) === expected) {
+ resolve();
+ return;
+ }
+
+ setTimeout(() => pollVideoBlackCheck(expected, id, resolve), 50);
+}
+
+function checkVideoBlack(expected, id)
+{
+ return new Promise((resolve, reject) => {
+ pollVideoBlackCheck(expected, id, resolve);
+ setTimeout(() => reject("checkVideoBlack timed out for " + id + " expected " + expected), 5000);
+ });
+}
+
+var track;
+var remoteTrack;
+promise_test((test) => {
+ if (window.testRunner)
+ testRunner.setUserMediaPermission(true);
+
+ return navigator.mediaDevices.getUserMedia({video: {width: 320, height: 240, facingMode: "environment"}}).then((localStream) => {
+ track = localStream.getVideoTracks()[0];
+ track.enabled = false;
+ localVideo.srcObject = localStream;
+ return new Promise((resolve, reject) => {
+ createConnections((firstConnection) => {
+ firstConnection.addTrack(track, localStream);
+ }, (secondConnection) => {
+ secondConnection._ontrack_ = (trackEvent) => {
+ remoteTrack = trackEvent.track;
+ resolve(trackEvent.streams[0]);
+ };
+ });
+ setTimeout(() => reject("Test timed out"), 5000);
+ });
+ }).then((remoteStream) => {
+ video.srcObject = remoteStream;
+ return video.play();
+ });
+}, "Setting video exchange");
+
+promise_test((test) => {
+ return checkVideoBlack(true, "canvas1");
+}, "Track is enabled, video should be black");
+
+promise_test((test) => {
+ track.enabled = true;
+ return checkVideoBlack(false, "canvas2");
+}, "Track is enabled, video should not be black");
+
+ </script>
+ </body>
+</html>
Modified: tags/Safari-604.1.23.0.3/Source/WebCore/ChangeLog (217633 => 217634)
--- tags/Safari-604.1.23.0.3/Source/WebCore/ChangeLog 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/Source/WebCore/ChangeLog 2017-05-31 22:49:40 UTC (rev 217634)
@@ -1,5 +1,40 @@
2017-05-31 Matthew Hanson <matthew_han...@apple.com>
+ Cherry-pick r217624. rdar://problem/32493091
+
+ 2017-05-31 Youenn Fablet <you...@apple.com>
+
+ PeerConnection should respect tracks that are muted at the time they are added
+ https://bugs.webkit.org/show_bug.cgi?id=172771
+
+ Reviewed by Eric Carlson.
+
+ Tests: webrtc/peer-connection-audio-unmute.html
+ webrtc/video-unmute.html
+
+ Making sure that muted/enabled state of sources are correctly handled at creation time of the outgoing webrtc sources.
+ This should trigger silent audio and black frames.
+
+ * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
+ (WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
+ (WebCore::RealtimeOutgoingAudioSource::setSource):
+ (WebCore::RealtimeOutgoingAudioSource::initializeConverter):
+ * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
+ * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
+ (WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
+ (WebCore::RealtimeOutgoingVideoSource::setSource):
+ (WebCore::RealtimeOutgoingVideoSource::sourceMutedChanged):
+ (WebCore::RealtimeOutgoingVideoSource::sourceEnabledChanged):
+ (WebCore::RealtimeOutgoingVideoSource::initializeFromSource):
+ (WebCore::RealtimeOutgoingVideoSource::AddOrUpdateSink):
+ (WebCore::RealtimeOutgoingVideoSource::RemoveSink):
+ (WebCore::RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded):
+ (WebCore::RealtimeOutgoingVideoSource::setSizeFromSource): Deleted.
+ (WebCore::RealtimeOutgoingVideoSource::sendBlackFrames): Deleted.
+ * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
+
+2017-05-31 Matthew Hanson <matthew_han...@apple.com>
+
Cherry-pick r217570. rdar://problem/30772609
2017-05-30 Alex Christensen <achristen...@webkit.org>
Modified: tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp (217633 => 217634)
--- tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp 2017-05-31 22:49:40 UTC (rev 217634)
@@ -51,6 +51,7 @@
, m_sampleConverter(AudioSampleDataSource::create(LibWebRTCAudioFormat::sampleRate * 2))
{
m_audioSource->addObserver(*this);
+ initializeConverter();
}
bool RealtimeOutgoingAudioSource::setSource(Ref<RealtimeMediaSource>&& newSource)
@@ -59,10 +60,15 @@
m_audioSource = WTFMove(newSource);
m_audioSource->addObserver(*this);
+ initializeConverter();
+ return true;
+}
+
+void RealtimeOutgoingAudioSource::initializeConverter()
+{
m_muted = m_audioSource->muted();
m_enabled = m_audioSource->enabled();
m_sampleConverter->setMuted(m_muted || !m_enabled);
- return true;
}
void RealtimeOutgoingAudioSource::stop()
Modified: tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (217633 => 217634)
--- tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h 2017-05-31 22:49:40 UTC (rev 217634)
@@ -73,6 +73,8 @@
void pullAudioData();
+ void initializeConverter();
+
Vector<webrtc::AudioTrackSinkInterface*> m_sinks;
Ref<RealtimeMediaSource> m_audioSource;
Ref<AudioSampleDataSource> m_sampleConverter;
Modified: tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp (217633 => 217634)
--- tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp 2017-05-31 22:49:40 UTC (rev 217634)
@@ -47,7 +47,7 @@
, m_blackFrameTimer(*this, &RealtimeOutgoingVideoSource::sendOneBlackFrame)
{
m_videoSource->addObserver(*this);
- setSizeFromSource();
+ initializeFromSource();
}
bool RealtimeOutgoingVideoSource::setSource(Ref<RealtimeMediaSource>&& newSource)
@@ -64,9 +64,7 @@
m_videoSource = WTFMove(newSource);
m_videoSource->addObserver(*this);
- setSizeFromSource();
- m_muted = m_videoSource->muted();
- m_enabled = m_videoSource->enabled();
+ initializeFromSource();
return true;
}
@@ -78,6 +76,16 @@
m_isStopped = true;
}
+void RealtimeOutgoingVideoSource::updateBlackFramesSending()
+{
+ if (!m_muted && m_enabled && m_blackFrameTimer.isActive()) {
+ m_blackFrameTimer.stop();
+ return;
+ }
+
+ sendBlackFramesIfNeeded();
+}
+
void RealtimeOutgoingVideoSource::sourceMutedChanged()
{
ASSERT(m_muted != m_videoSource->muted());
@@ -84,12 +92,7 @@
m_muted = m_videoSource->muted();
- if (m_muted && m_sinks.size() && m_enabled) {
- sendBlackFrames();
- return;
- }
- if (m_blackFrameTimer.isActive())
- m_blackFrameTimer.stop();
+ updateBlackFramesSending();
}
void RealtimeOutgoingVideoSource::sourceEnabledChanged()
@@ -98,19 +101,19 @@
m_enabled = m_videoSource->enabled();
- if (!m_enabled && m_sinks.size() && !m_muted) {
- sendBlackFrames();
- return;
- }
- if (m_blackFrameTimer.isActive())
- m_blackFrameTimer.stop();
+ updateBlackFramesSending();
}
-void RealtimeOutgoingVideoSource::setSizeFromSource()
+void RealtimeOutgoingVideoSource::initializeFromSource()
{
const auto& settings = m_videoSource->settings();
m_width = settings.width();
m_height = settings.height();
+
+ m_muted = m_videoSource->muted();
+ m_enabled = m_videoSource->enabled();
+
+ sendBlackFramesIfNeeded();
}
bool RealtimeOutgoingVideoSource::GetStats(Stats*)
@@ -127,15 +130,36 @@
if (!m_sinks.contains(sink))
m_sinks.append(sink);
+
+ callOnMainThread([protectedThis = makeRef(*this)]() {
+ protectedThis->sendBlackFramesIfNeeded();
+ });
}
void RealtimeOutgoingVideoSource::RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink)
{
m_sinks.removeFirst(sink);
+
+ if (m_sinks.size())
+ return;
+
+ callOnMainThread([protectedThis = makeRef(*this)]() {
+ if (protectedThis->m_blackFrameTimer.isActive())
+ protectedThis->m_blackFrameTimer.stop();
+ });
}
-void RealtimeOutgoingVideoSource::sendBlackFrames()
+void RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded()
{
+ if (m_blackFrameTimer.isActive())
+ return;
+
+ if (!m_sinks.size())
+ return;
+
+ if (!m_muted && m_enabled)
+ return;
+
if (!m_blackFrame) {
auto frame = m_bufferPool.CreateBuffer(m_width, m_height);
frame->SetToBlack();
Modified: tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h (217633 => 217634)
--- tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h 2017-05-31 22:49:35 UTC (rev 217633)
+++ tags/Safari-604.1.23.0.3/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h 2017-05-31 22:49:40 UTC (rev 217634)
@@ -58,9 +58,10 @@
RealtimeOutgoingVideoSource(Ref<RealtimeMediaSource>&&);
void sendFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&);
- void sendBlackFrames();
+ void sendBlackFramesIfNeeded();
void sendOneBlackFrame();
- void setSizeFromSource();
+ void initializeFromSource();
+ void updateBlackFramesSending();
// Notifier API
void RegisterObserver(webrtc::ObserverInterface*) final { }
@@ -82,7 +83,7 @@
// RealtimeMediaSource::Observer API
void sourceMutedChanged() final;
void sourceEnabledChanged() final;
- void sourceSettingsChanged() final { setSizeFromSource(); }
+ void sourceSettingsChanged() final { initializeFromSource(); }
void videoSampleAvailable(MediaSample&) final;
Vector<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;