Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc

Issue 2951713002: RTCPeerConnection.addTrack and removeTrack added (behind flag) (Closed)
Patch Set: Addressed deadbeef's comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string>
6 #include <vector>
7
5 #include "base/command_line.h" 8 #include "base/command_line.h"
6 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" 9 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
7 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
8 #include "media/base/media_switches.h" 11 #include "media/base/media_switches.h"
9 12
10 static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; 13 static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html";
11 14
12 class WebRtcRtpBrowserTest : public WebRtcTestBase { 15 class WebRtcRtpBrowserTest : public WebRtcTestBase {
13 public: 16 public:
14 WebRtcRtpBrowserTest() : left_tab_(nullptr), right_tab_(nullptr) {} 17 WebRtcRtpBrowserTest() : left_tab_(nullptr), right_tab_(nullptr) {}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 CreateAndAddStreams(left_tab_, 3); 59 CreateAndAddStreams(left_tab_, 3);
57 60
58 SetupPeerconnectionWithoutLocalStream(right_tab_); 61 SetupPeerconnectionWithoutLocalStream(right_tab_);
59 CreateAndAddStreams(right_tab_, 1); 62 CreateAndAddStreams(right_tab_, 1);
60 63
61 NegotiateCall(left_tab_, right_tab_); 64 NegotiateCall(left_tab_, right_tab_);
62 65
63 VerifyRtpReceivers(left_tab_, 2); 66 VerifyRtpReceivers(left_tab_, 2);
64 VerifyRtpReceivers(right_tab_, 6); 67 VerifyRtpReceivers(right_tab_, 6);
65 } 68 }
69
70 IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest, AddAndRemoveTracksWithoutStream) {
71 StartServerAndOpenTabs();
72
73 SetupPeerconnectionWithoutLocalStream(left_tab_);
74 SetupPeerconnectionWithoutLocalStream(right_tab_);
75
76 // TODO(hbos): Here and in other "AddAndRemoveTracks" tests: when ontrack and
77 // ended events are supported, verify that these are fired on the remote side
78 // when tracks are added and removed. https://crbug.com/webrtc/7933
79
80 // Add two tracks.
81 StartCountingOnNegotiationNeeded(left_tab_);
82 std::vector<std::string> ids =
83 CreateAndAddAudioAndVideoTrack(left_tab_, StreamArgumentType::NO_STREAM);
84 WaitUntilOnNegotiationCountIs(left_tab_, 2);
Taylor_Brandstetter 2017/07/07 19:44:13 Actually, if we followed the standard, negotiation
hbos_chromium 2017/07/10 12:32:59 Done, filed an issue, this is a bug that should al
85 std::string audio_stream_id = ids[0];
86 std::string audio_track_id = ids[1];
87 std::string video_stream_id = ids[2];
88 std::string video_track_id = ids[3];
89 EXPECT_EQ("null", audio_stream_id);
90 EXPECT_NE("null", audio_track_id);
91 EXPECT_EQ("null", video_stream_id);
92 EXPECT_NE("null", video_track_id);
93 EXPECT_FALSE(
94 HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
95 EXPECT_FALSE(
96 HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
97 EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
98 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
99 VerifyRtpSenders(left_tab_, 2);
100 // Negotiate call, sets remote description.
101 NegotiateCall(left_tab_, right_tab_);
102 // TODO(hbos): When |addTrack| without streams results in SDP that does not
103 // signal a remote stream to be added this should be EXPECT_FALSE.
104 // https://crbug.com/webrtc/7933
105 EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
106 EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
107 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
108 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
109 VerifyRtpReceivers(right_tab_, 2);
110
111 // Remove first track.
112 RemoveTrack(left_tab_, audio_track_id);
113 WaitUntilOnNegotiationCountIs(left_tab_, 3);
114 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
115 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
116 VerifyRtpSenders(left_tab_, 1);
117 // Re-negotiate call, sets remote description again.
118 NegotiateCall(left_tab_, right_tab_);
119 EXPECT_FALSE(
120 HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
121 EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
122 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
123 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
124 VerifyRtpReceivers(right_tab_, 1);
125
126 // Remove second track.
127 RemoveTrack(left_tab_, video_track_id);
128 WaitUntilOnNegotiationCountIs(left_tab_, 4);
129 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
130 EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
131 VerifyRtpSenders(left_tab_, 0);
132 // Re-negotiate call, sets remote description again.
133 NegotiateCall(left_tab_, right_tab_);
134 EXPECT_FALSE(
135 HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
136 EXPECT_FALSE(
137 HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
138 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
139 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
140 VerifyRtpReceivers(right_tab_, 0);
141 }
142
143 IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest,
144 AddAndRemoveTracksWithSharedStream) {
145 StartServerAndOpenTabs();
146
147 SetupPeerconnectionWithoutLocalStream(left_tab_);
148 SetupPeerconnectionWithoutLocalStream(right_tab_);
149
150 // Add two tracks.
151 StartCountingOnNegotiationNeeded(left_tab_);
152 std::vector<std::string> ids = CreateAndAddAudioAndVideoTrack(
153 left_tab_, StreamArgumentType::SHARED_STREAM);
154 WaitUntilOnNegotiationCountIs(left_tab_, 2);
155 std::string audio_stream_id = ids[0];
156 std::string audio_track_id = ids[1];
157 std::string video_stream_id = ids[2];
158 std::string video_track_id = ids[3];
159 EXPECT_NE("null", audio_stream_id);
160 EXPECT_NE("null", audio_track_id);
161 EXPECT_NE("null", video_stream_id);
162 EXPECT_NE("null", video_track_id);
163 EXPECT_EQ(audio_stream_id, video_stream_id);
164 // TODO(hbos): When |getLocalStreams| is updated to return the streams of all
165 // senders, not just |addStream|-streams, then this will be EXPECT_TRUE.
166 // https://crbug.com/738918
167 EXPECT_FALSE(
168 HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
169 EXPECT_FALSE(
170 HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
171 EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
172 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
173 VerifyRtpSenders(left_tab_, 2);
174 // Negotiate call, sets remote description.
175 NegotiateCall(left_tab_, right_tab_);
176 EXPECT_TRUE(
177 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
178 EXPECT_TRUE(
179 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
180 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
181 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
182 VerifyRtpReceivers(right_tab_, 2);
183
184 // Remove first track.
185 RemoveTrack(left_tab_, audio_track_id);
186 WaitUntilOnNegotiationCountIs(left_tab_, 3);
187 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
188 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
189 VerifyRtpSenders(left_tab_, 1);
190 // Re-negotiate call, sets remote description again.
191 NegotiateCall(left_tab_, right_tab_);
192 EXPECT_FALSE(
193 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
194 EXPECT_TRUE(
195 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
196 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
197 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
198 VerifyRtpReceivers(right_tab_, 1);
199
200 // Remove second track.
201 RemoveTrack(left_tab_, video_track_id);
202 WaitUntilOnNegotiationCountIs(left_tab_, 4);
203 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
204 EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
205 VerifyRtpSenders(left_tab_, 0);
206 // Re-negotiate call, sets remote description again.
207 NegotiateCall(left_tab_, right_tab_);
208 EXPECT_FALSE(
209 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
210 EXPECT_FALSE(
211 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
212 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
213 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
214 VerifyRtpReceivers(right_tab_, 0);
215 }
216
217 IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest,
218 AddAndRemoveTracksWithIndividualStreams) {
219 StartServerAndOpenTabs();
220
221 SetupPeerconnectionWithoutLocalStream(left_tab_);
222 SetupPeerconnectionWithoutLocalStream(right_tab_);
223
224 // Add two tracks.
225 StartCountingOnNegotiationNeeded(left_tab_);
226 std::vector<std::string> ids = CreateAndAddAudioAndVideoTrack(
227 left_tab_, StreamArgumentType::INDIVIDUAL_STREAMS);
228 WaitUntilOnNegotiationCountIs(left_tab_, 2);
229 std::string audio_stream_id = ids[0];
230 std::string audio_track_id = ids[1];
231 std::string video_stream_id = ids[2];
232 std::string video_track_id = ids[3];
233 EXPECT_NE("null", audio_stream_id);
234 EXPECT_NE("null", audio_track_id);
235 EXPECT_NE("null", video_stream_id);
236 EXPECT_NE("null", video_track_id);
237 EXPECT_NE(audio_stream_id, video_stream_id);
238 // TODO(hbos): When |getLocalStreams| is updated to return the streams of all
239 // senders, not just |addStream|-streams, then this will be EXPECT_TRUE.
240 // https://crbug.com/738918
241 EXPECT_FALSE(
242 HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
243 EXPECT_FALSE(
244 HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
245 EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
246 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
247 VerifyRtpSenders(left_tab_, 2);
248 // Negotiate call, sets remote description.
249 NegotiateCall(left_tab_, right_tab_);
250 EXPECT_TRUE(
251 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
252 EXPECT_TRUE(
253 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
254 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
255 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
256 VerifyRtpReceivers(right_tab_, 2);
257
258 // Remove first track.
259 RemoveTrack(left_tab_, audio_track_id);
260 WaitUntilOnNegotiationCountIs(left_tab_, 3);
261 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
262 EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
263 VerifyRtpSenders(left_tab_, 1);
264 // Re-negotiate call, sets remote description again.
265 NegotiateCall(left_tab_, right_tab_);
266 EXPECT_FALSE(
267 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
268 EXPECT_TRUE(
269 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
270 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
271 EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
272 VerifyRtpReceivers(right_tab_, 1);
273
274 // Remove second track.
275 RemoveTrack(left_tab_, video_track_id);
276 WaitUntilOnNegotiationCountIs(left_tab_, 4);
277 EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
278 EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
279 VerifyRtpSenders(left_tab_, 0);
280 // Re-negotiate call, sets remote description again.
281 NegotiateCall(left_tab_, right_tab_);
282 EXPECT_FALSE(
283 HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
284 EXPECT_FALSE(
285 HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
286 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
287 EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
288 VerifyRtpReceivers(right_tab_, 0);
289 }
Taylor_Brandstetter 2017/07/07 19:44:13 I like this change; it's much easier to see what t
hbos_chromium 2017/07/10 12:32:59 I'd like that except the setup for the remove trac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698