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

Side by Side Diff: talk/session/media/channel_unittest.cc

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add missing updated_options Created 5 years, 2 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 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2009 Google Inc. 3 * Copyright 2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // Calling "_w" method here is ok since we only use one thread for this test 287 // Calling "_w" method here is ok since we only use one thread for this test
288 cricket::FakeTransport* GetTransport1() { 288 cricket::FakeTransport* GetTransport1() {
289 return transport_controller1_.GetTransport_w(channel1_->content_name()); 289 return transport_controller1_.GetTransport_w(channel1_->content_name());
290 } 290 }
291 cricket::FakeTransport* GetTransport2() { 291 cricket::FakeTransport* GetTransport2() {
292 return transport_controller2_.GetTransport_w(channel2_->content_name()); 292 return transport_controller2_.GetTransport_w(channel2_->content_name());
293 } 293 }
294 294
295 bool SendRtp1() { 295 bool SendRtp1() {
296 return media_channel1_->SendRtp(rtp_packet_.c_str(), 296 return media_channel1_->SendRtp(rtp_packet_.c_str(),
297 static_cast<int>(rtp_packet_.size())); 297 static_cast<int>(rtp_packet_.size()),
298 rtc::PacketOptions());
298 } 299 }
299 bool SendRtp2() { 300 bool SendRtp2() {
300 return media_channel2_->SendRtp(rtp_packet_.c_str(), 301 return media_channel2_->SendRtp(rtp_packet_.c_str(),
301 static_cast<int>(rtp_packet_.size())); 302 static_cast<int>(rtp_packet_.size()),
303 rtc::PacketOptions());
302 } 304 }
303 bool SendRtcp1() { 305 bool SendRtcp1() {
304 return media_channel1_->SendRtcp(rtcp_packet_.c_str(), 306 return media_channel1_->SendRtcp(rtcp_packet_.c_str(),
305 static_cast<int>(rtcp_packet_.size())); 307 static_cast<int>(rtcp_packet_.size()));
306 } 308 }
307 bool SendRtcp2() { 309 bool SendRtcp2() {
308 return media_channel2_->SendRtcp(rtcp_packet_.c_str(), 310 return media_channel2_->SendRtcp(rtcp_packet_.c_str(),
309 static_cast<int>(rtcp_packet_.size())); 311 static_cast<int>(rtcp_packet_.size()));
310 } 312 }
311 // Methods to send custom data. 313 // Methods to send custom data.
312 bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { 314 bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
313 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); 315 std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
314 return media_channel1_->SendRtp(data.c_str(), 316 return media_channel1_->SendRtp(data.c_str(), static_cast<int>(data.size()),
315 static_cast<int>(data.size())); 317 rtc::PacketOptions());
316 } 318 }
317 bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { 319 bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
318 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); 320 std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
319 return media_channel2_->SendRtp(data.c_str(), 321 return media_channel2_->SendRtp(data.c_str(), static_cast<int>(data.size()),
320 static_cast<int>(data.size())); 322 rtc::PacketOptions());
321 } 323 }
322 bool SendCustomRtcp1(uint32_t ssrc) { 324 bool SendCustomRtcp1(uint32_t ssrc) {
323 std::string data(CreateRtcpData(ssrc)); 325 std::string data(CreateRtcpData(ssrc));
324 return media_channel1_->SendRtcp(data.c_str(), 326 return media_channel1_->SendRtcp(data.c_str(),
325 static_cast<int>(data.size())); 327 static_cast<int>(data.size()));
326 } 328 }
327 bool SendCustomRtcp2(uint32_t ssrc) { 329 bool SendCustomRtcp2(uint32_t ssrc) {
328 std::string data(CreateRtcpData(ssrc)); 330 std::string data(CreateRtcpData(ssrc));
329 return media_channel2_->SendRtcp(data.c_str(), 331 return media_channel2_->SendRtcp(data.c_str(),
330 static_cast<int>(data.size())); 332 static_cast<int>(data.size()));
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 952
951 // Test that we don't crash if packets are sent during call teardown 953 // Test that we don't crash if packets are sent during call teardown
952 // when RTCP mux is enabled. This is a regression test against a specific 954 // when RTCP mux is enabled. This is a regression test against a specific
953 // race condition that would only occur when a RTCP packet was sent during 955 // race condition that would only occur when a RTCP packet was sent during
954 // teardown of a channel on which RTCP mux was enabled. 956 // teardown of a channel on which RTCP mux was enabled.
955 void TestCallTeardownRtcpMux() { 957 void TestCallTeardownRtcpMux() {
956 class LastWordMediaChannel : public T::MediaChannel { 958 class LastWordMediaChannel : public T::MediaChannel {
957 public: 959 public:
958 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} 960 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
959 ~LastWordMediaChannel() { 961 ~LastWordMediaChannel() {
960 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame)); 962 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
963 rtc::PacketOptions());
961 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); 964 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
962 } 965 }
963 }; 966 };
964 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), 967 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
965 RTCP | RTCP_MUX, RTCP | RTCP_MUX, 968 RTCP | RTCP_MUX, RTCP | RTCP_MUX,
966 rtc::Thread::Current()); 969 rtc::Thread::Current());
967 EXPECT_TRUE(SendInitiate()); 970 EXPECT_TRUE(SendInitiate());
968 EXPECT_TRUE(SendAccept()); 971 EXPECT_TRUE(SendAccept());
969 EXPECT_TRUE(SendTerminate()); 972 EXPECT_TRUE(SendTerminate());
970 } 973 }
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 EXPECT_FALSE(channel2_->secure()); 1705 EXPECT_FALSE(channel2_->secure());
1703 EXPECT_TRUE(SendInitiate()); 1706 EXPECT_TRUE(SendInitiate());
1704 EXPECT_TRUE(SendAccept()); 1707 EXPECT_TRUE(SendAccept());
1705 EXPECT_TRUE(channel1_->secure()); 1708 EXPECT_TRUE(channel1_->secure());
1706 EXPECT_TRUE(channel2_->secure()); 1709 EXPECT_TRUE(channel2_->secure());
1707 channel2_->srtp_filter()->set_signal_silent_time(250); 1710 channel2_->srtp_filter()->set_signal_silent_time(250);
1708 channel2_->srtp_filter()->SignalSrtpError.connect( 1711 channel2_->srtp_filter()->SignalSrtpError.connect(
1709 &error_handler, &SrtpErrorHandler::OnSrtpError); 1712 &error_handler, &SrtpErrorHandler::OnSrtpError);
1710 1713
1711 // Testing failures in sending packets. 1714 // Testing failures in sending packets.
1712 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1715 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1716 rtc::PacketOptions()));
1713 // The first failure will trigger an error. 1717 // The first failure will trigger an error.
1714 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1718 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
1715 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1719 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1716 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1720 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1717 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; 1721 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1718 // The next 250 ms failures will not trigger an error. 1722 // The next 250 ms failures will not trigger an error.
1719 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1723 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1724 rtc::PacketOptions()));
1720 // Wait for a while to ensure no message comes in. 1725 // Wait for a while to ensure no message comes in.
1721 rtc::Thread::Current()->ProcessMessages(200); 1726 rtc::Thread::Current()->ProcessMessages(200);
1722 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); 1727 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
1723 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1728 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1724 // Wait for a little more - the error will be triggered again. 1729 // Wait for a little more - the error will be triggered again.
1725 rtc::Thread::Current()->ProcessMessages(200); 1730 rtc::Thread::Current()->ProcessMessages(200);
1726 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); 1731 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1732 rtc::PacketOptions()));
1727 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1733 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
1728 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1734 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1729 1735
1730 // Testing failures in receiving packets. 1736 // Testing failures in receiving packets.
1731 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1737 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1732 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; 1738 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1733 1739
1734 cricket::TransportChannel* transport_channel = 1740 cricket::TransportChannel* transport_channel =
1735 channel2_->transport_channel(); 1741 channel2_->transport_channel();
1736 transport_channel->SignalReadPacket( 1742 transport_channel->SignalReadPacket(
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 }; 2796 };
2791 rtc::Buffer payload(data, 3); 2797 rtc::Buffer payload(data, 3);
2792 cricket::SendDataResult result; 2798 cricket::SendDataResult result;
2793 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2799 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2794 EXPECT_EQ(params.ssrc, 2800 EXPECT_EQ(params.ssrc,
2795 media_channel1_->last_sent_data_params().ssrc); 2801 media_channel1_->last_sent_data_params().ssrc);
2796 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2802 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2797 } 2803 }
2798 2804
2799 // TODO(pthatcher): TestSetReceiver? 2805 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698