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() {
});
}, 'addTrack() for a single track and a different stream.');
promise_test(function() {
let pc = new RTCPeerConnection();
return createStreams({audio:true, video:false}, 2)
.then(function(streams) {
let streamA = streams[0];
let streamB = streams[1];
let track = streamA.getAudioTracks()[0];
let exception = null;
try {
pc.addTrack(track, streamA, streamB);
} catch (e) {
exception = e;
}
// The spec supports multiple streams per track but our implementation
// doesn't. Fix test when resolving https://crbug.com/webrtc/7932.
assert_true(exception != null);
assert_equals('NotSupportedError', exception.name);
});
}, 'addTrack() for a single track and two streams throws NotSupportedError.');
promise_test(async t => {
let pc = new RTCPeerConnection({sdpSemantics: "plan-b"});
let [streamA, streamB] = await createStreams({audio:true, video:false}, 2);
let track = streamA.getAudioTracks()[0];
assert_throws('NotSupportedError', () => {
pc.addTrack(track, streamA, streamB)
});
}, 'addTrack() for a single track and two streams (Plan B) throws NotSupportedError.');
promise_test(async t => {
let pc = new RTCPeerConnection({sdpSemantics: "unified-plan"});
let [streamA, streamB] = await createStreams({audio:true, video:false}, 2);
let track = streamA.getAudioTracks()[0];
let sender = pc.addTrack(track, streamA, streamB);
assert_equals(sender.track, track);
assert_array_equals(pc.getLocalStreams(), [ streamA, streamB ]);
}, 'addTrack() for a single track and two streams (Unified Plan).');
promise_test(function() {
let pc = new RTCPeerConnection();
......
......@@ -535,7 +535,8 @@ RTCPeerConnection::RTCPeerConnection(ExecutionContext* context,
negotiation_needed_(false),
stopped_(false),
closed_(false),
has_data_channels_(false) {
has_data_channels_(false),
sdp_semantics_(configuration.sdp_semantics) {
Document* document = ToDocument(GetExecutionContext());
// If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
......@@ -1424,9 +1425,13 @@ RTCRtpSender* RTCPeerConnection::addTrack(MediaStreamTrack* track,
DCHECK(track->Component());
if (ThrowExceptionIfSignalingStateClosed(signaling_state_, exception_state))
return nullptr;
if (streams.size() >= 2) {
// TODO(hbos): Don't throw an exception when this is supported by the lower
// layers. https://crbug.com/webrtc/7932
// TODO(bugs.webrtc.org/8530): Take out WebRTCSdpSemantics::kDefault check
// once default is no longer interpreted as Plan B lower down.
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(
kNotSupportedError,
"Adding a track to multiple streams is not supported.");
......
......@@ -44,6 +44,7 @@
#include "platform/heap/HeapAllocator.h"
#include "platform/scheduler/public/frame_scheduler.h"
#include "public/platform/WebMediaConstraints.h"
#include "public/platform/WebRTCConfiguration.h"
#include "public/platform/WebRTCPeerConnectionHandler.h"
#include "public/platform/WebRTCPeerConnectionHandlerClient.h"
......@@ -351,6 +352,7 @@ class MODULES_EXPORT RTCPeerConnection final
String last_answer_;
bool has_data_channels_; // For RAPPOR metrics
WebRTCSdpSemantics sdp_semantics_;
};
} // 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