Commit 052e6c42 authored by Seth Hampson's avatar Seth Hampson Committed by Commit Bot

Updating addTrack test for multiple stream case and removing check.

Bug: webrtc:7932
Change-Id: I6d9a97754e6f19f5917927a24652786a4d9624c5
Reviewed-on: https://chromium-review.googlesource.com/986509
Commit-Queue: Seth Hampson <shampson@chromium.org>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548546}
parent 4ac29b47
...@@ -44,25 +44,23 @@ promise_test(function() { ...@@ -44,25 +44,23 @@ promise_test(function() {
}); });
}, 'addTrack() for a single track and a different stream.'); }, 'addTrack() for a single track and a different stream.');
promise_test(function() { promise_test(async t => {
let pc = new RTCPeerConnection(); let pc = new RTCPeerConnection({sdpSemantics: "plan-b"});
return createStreams({audio:true, video:false}, 2) let [streamA, streamB] = await createStreams({audio:true, video:false}, 2);
.then(function(streams) { let track = streamA.getAudioTracks()[0];
let streamA = streams[0]; assert_throws('NotSupportedError', () => {
let streamB = streams[1]; pc.addTrack(track, streamA, streamB)
let track = streamA.getAudioTracks()[0]; });
let exception = null; }, 'addTrack() for a single track and two streams (Plan B) throws NotSupportedError.');
try {
pc.addTrack(track, streamA, streamB); promise_test(async t => {
} catch (e) { let pc = new RTCPeerConnection({sdpSemantics: "unified-plan"});
exception = e; let [streamA, streamB] = await createStreams({audio:true, video:false}, 2);
} let track = streamA.getAudioTracks()[0];
// The spec supports multiple streams per track but our implementation let sender = pc.addTrack(track, streamA, streamB);
// doesn't. Fix test when resolving https://crbug.com/webrtc/7932. assert_equals(sender.track, track);
assert_true(exception != null); assert_array_equals(pc.getLocalStreams(), [ streamA, streamB ]);
assert_equals('NotSupportedError', exception.name); }, 'addTrack() for a single track and two streams (Unified Plan).');
});
}, 'addTrack() for a single track and two streams throws NotSupportedError.');
promise_test(function() { promise_test(function() {
let pc = new RTCPeerConnection(); let pc = new RTCPeerConnection();
......
...@@ -535,7 +535,8 @@ RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, ...@@ -535,7 +535,8 @@ RTCPeerConnection::RTCPeerConnection(ExecutionContext* context,
negotiation_needed_(false), negotiation_needed_(false),
stopped_(false), stopped_(false),
closed_(false), closed_(false),
has_data_channels_(false) { has_data_channels_(false),
sdp_semantics_(configuration.sdp_semantics) {
Document* document = ToDocument(GetExecutionContext()); Document* document = ToDocument(GetExecutionContext());
// If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
...@@ -1424,9 +1425,13 @@ RTCRtpSender* RTCPeerConnection::addTrack(MediaStreamTrack* track, ...@@ -1424,9 +1425,13 @@ RTCRtpSender* RTCPeerConnection::addTrack(MediaStreamTrack* track,
DCHECK(track->Component()); DCHECK(track->Component());
if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state)) if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state))
return nullptr; return nullptr;
if (streams.size() >= 2) { // TODO(bugs.webrtc.org/8530): Take out WebRTCSdpSemantics::kDefault check
// TODO(hbos): Don't throw an exception when this is supported by the lower // once default is no longer interpreted as Plan B lower down.
// layers. https://crbug.com/webrtc/7932 if ((sdp_semantics_ == WebRTCSdpSemantics::kPlanB ||
sdp_semantics_ == WebRTCSdpSemantics::kDefault) &&
streams.size() >= 2) {
// TODO(hbos): Update peer_handler_ to call the AddTrack() that returns the
// appropriate errors, and let the lower layers handle it.
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
kNotSupportedError, kNotSupportedError,
"Adding a track to multiple streams is not supported."); "Adding a track to multiple streams is not supported.");
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "platform/heap/HeapAllocator.h" #include "platform/heap/HeapAllocator.h"
#include "platform/scheduler/public/frame_scheduler.h" #include "platform/scheduler/public/frame_scheduler.h"
#include "public/platform/WebMediaConstraints.h" #include "public/platform/WebMediaConstraints.h"
#include "public/platform/WebRTCConfiguration.h"
#include "public/platform/WebRTCPeerConnectionHandler.h" #include "public/platform/WebRTCPeerConnectionHandler.h"
#include "public/platform/WebRTCPeerConnectionHandlerClient.h" #include "public/platform/WebRTCPeerConnectionHandlerClient.h"
...@@ -351,6 +352,7 @@ class MODULES_EXPORT RTCPeerConnection final ...@@ -351,6 +352,7 @@ class MODULES_EXPORT RTCPeerConnection final
String last_answer_; String last_answer_;
bool has_data_channels_; // For RAPPOR metrics bool has_data_channels_; // For RAPPOR metrics
WebRTCSdpSemantics sdp_semantics_;
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment