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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/webrtc/webrtc_browsertest_base.cc ('k') | chrome/test/data/webrtc/munge_sdp.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc b/chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc
index bd591a994707151759292c68c2c31ff09259b054..f93585016a40b8ba36829471cb6505aee3e20639 100644
--- a/chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc
+++ b/chrome/browser/media/webrtc/webrtc_rtp_browsertest.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+#include <vector>
+
#include "base/command_line.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "content/public/common/content_switches.h"
@@ -63,3 +66,230 @@ IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest, GetReceivers) {
VerifyRtpReceivers(left_tab_, 2);
VerifyRtpReceivers(right_tab_, 6);
}
+
+IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest, AddAndRemoveTracksWithoutStream) {
+ StartServerAndOpenTabs();
+
+ SetupPeerconnectionWithoutLocalStream(left_tab_);
+ SetupPeerconnectionWithoutLocalStream(right_tab_);
+
+ // TODO(hbos): Here and in other "AddAndRemoveTracks" tests: when ontrack and
+ // ended events are supported, verify that these are fired on the remote side
+ // when tracks are added and removed. https://crbug.com/webrtc/7933
+
+ // Add two tracks.
+ EXPECT_EQ(0u, GetNegotiationNeededCount(left_tab_));
+ std::vector<std::string> ids =
+ CreateAndAddAudioAndVideoTrack(left_tab_, StreamArgumentType::NO_STREAM);
+ // TODO(hbos): Should only fire once (if the "negotiationneeded" bit changes
+ // from false to true), not once per track added. https://crbug.com/740501
+ EXPECT_EQ(2u, GetNegotiationNeededCount(left_tab_));
+ std::string audio_stream_id = ids[0];
+ std::string audio_track_id = ids[1];
+ std::string video_stream_id = ids[2];
+ std::string video_track_id = ids[3];
+ EXPECT_EQ("null", audio_stream_id);
+ EXPECT_NE("null", audio_track_id);
+ EXPECT_EQ("null", video_stream_id);
+ EXPECT_NE("null", video_track_id);
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 2);
+ // Negotiate call, sets remote description.
+ NegotiateCall(left_tab_, right_tab_);
+ // TODO(hbos): When |addTrack| without streams results in SDP that does not
+ // signal a remote stream to be added this should be EXPECT_FALSE.
+ // https://crbug.com/webrtc/7933
+ EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
+ EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 2);
+
+ // Remove first track.
+ RemoveTrack(left_tab_, audio_track_id);
+ EXPECT_EQ(3u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 1);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
+ EXPECT_TRUE(HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 1);
+
+ // Remove second track.
+ RemoveTrack(left_tab_, video_track_id);
+ EXPECT_EQ(4u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 0);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, kUndefined, audio_track_id));
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, kUndefined, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 0);
+}
+
+IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest,
+ AddAndRemoveTracksWithSharedStream) {
+ StartServerAndOpenTabs();
+
+ SetupPeerconnectionWithoutLocalStream(left_tab_);
+ SetupPeerconnectionWithoutLocalStream(right_tab_);
+
+ // Add two tracks.
+ EXPECT_EQ(0u, GetNegotiationNeededCount(left_tab_));
+ std::vector<std::string> ids = CreateAndAddAudioAndVideoTrack(
+ left_tab_, StreamArgumentType::SHARED_STREAM);
+ // TODO(hbos): Should only fire once (if the "negotiationneeded" bit changes
+ // from false to true), not once per track added. https://crbug.com/740501
+ EXPECT_EQ(2u, GetNegotiationNeededCount(left_tab_));
+ std::string audio_stream_id = ids[0];
+ std::string audio_track_id = ids[1];
+ std::string video_stream_id = ids[2];
+ std::string video_track_id = ids[3];
+ EXPECT_NE("null", audio_stream_id);
+ EXPECT_NE("null", audio_track_id);
+ EXPECT_NE("null", video_stream_id);
+ EXPECT_NE("null", video_track_id);
+ EXPECT_EQ(audio_stream_id, video_stream_id);
+ // TODO(hbos): When |getLocalStreams| is updated to return the streams of all
+ // senders, not just |addStream|-streams, then this will be EXPECT_TRUE.
+ // https://crbug.com/738918
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 2);
+ // Negotiate call, sets remote description.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 2);
+
+ // Remove first track.
+ RemoveTrack(left_tab_, audio_track_id);
+ EXPECT_EQ(3u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 1);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 1);
+
+ // Remove second track.
+ RemoveTrack(left_tab_, video_track_id);
+ EXPECT_EQ(4u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 0);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 0);
+}
+
+IN_PROC_BROWSER_TEST_F(WebRtcRtpBrowserTest,
+ AddAndRemoveTracksWithIndividualStreams) {
+ StartServerAndOpenTabs();
+
+ SetupPeerconnectionWithoutLocalStream(left_tab_);
+ SetupPeerconnectionWithoutLocalStream(right_tab_);
+
+ // Add two tracks.
+ EXPECT_EQ(0u, GetNegotiationNeededCount(left_tab_));
+ std::vector<std::string> ids = CreateAndAddAudioAndVideoTrack(
+ left_tab_, StreamArgumentType::INDIVIDUAL_STREAMS);
+ // TODO(hbos): Should only fire once (if the "negotiationneeded" bit changes
+ // from false to true), not once per track added. https://crbug.com/740501
+ EXPECT_EQ(2u, GetNegotiationNeededCount(left_tab_));
+ std::string audio_stream_id = ids[0];
+ std::string audio_track_id = ids[1];
+ std::string video_stream_id = ids[2];
+ std::string video_track_id = ids[3];
+ EXPECT_NE("null", audio_stream_id);
+ EXPECT_NE("null", audio_track_id);
+ EXPECT_NE("null", video_stream_id);
+ EXPECT_NE("null", video_track_id);
+ EXPECT_NE(audio_stream_id, video_stream_id);
+ // TODO(hbos): When |getLocalStreams| is updated to return the streams of all
+ // senders, not just |addStream|-streams, then this will be EXPECT_TRUE.
+ // https://crbug.com/738918
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, audio_stream_id, audio_track_id));
+ EXPECT_FALSE(
+ HasLocalStreamWithTrack(left_tab_, video_stream_id, video_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 2);
+ // Negotiate call, sets remote description.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 2);
+
+ // Remove first track.
+ RemoveTrack(left_tab_, audio_track_id);
+ EXPECT_EQ(3u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_TRUE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 1);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_TRUE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_TRUE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 1);
+
+ // Remove second track.
+ RemoveTrack(left_tab_, video_track_id);
+ EXPECT_EQ(4u, GetNegotiationNeededCount(left_tab_));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, audio_track_id));
+ EXPECT_FALSE(HasSenderWithTrack(left_tab_, video_track_id));
+ VerifyRtpSenders(left_tab_, 0);
+ // Re-negotiate call, sets remote description again.
+ NegotiateCall(left_tab_, right_tab_);
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, audio_stream_id, audio_track_id));
+ EXPECT_FALSE(
+ HasRemoteStreamWithTrack(right_tab_, video_stream_id, video_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, audio_track_id));
+ EXPECT_FALSE(HasReceiverWithTrack(right_tab_, video_track_id));
+ VerifyRtpReceivers(right_tab_, 0);
+}
« no previous file with comments | « chrome/browser/media/webrtc/webrtc_browsertest_base.cc ('k') | chrome/test/data/webrtc/munge_sdp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698