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

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: Cleanups. 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 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include "talk/media/base/fakemediaengine.h" 28 #include "talk/media/base/fakemediaengine.h"
29 #include "talk/media/base/fakertp.h" 29 #include "talk/media/base/fakertp.h"
30 #include "talk/media/base/fakescreencapturerfactory.h" 30 #include "talk/media/base/fakescreencapturerfactory.h"
31 #include "talk/media/base/fakevideocapturer.h" 31 #include "talk/media/base/fakevideocapturer.h"
32 #include "talk/media/base/mediachannel.h" 32 #include "talk/media/base/mediachannel.h"
33 #include "talk/media/base/rtpdump.h" 33 #include "talk/media/base/rtpdump.h"
34 #include "talk/media/base/screencastid.h" 34 #include "talk/media/base/screencastid.h"
35 #include "talk/media/base/testutils.h" 35 #include "talk/media/base/testutils.h"
36 #include "webrtc/p2p/base/faketransportcontroller.h" 36 #include "talk/media/webrtc/fakewebrtccall.h"
37 #include "talk/app/webrtc/fakemediacontroller.h"
37 #include "talk/session/media/channel.h" 38 #include "talk/session/media/channel.h"
38 #include "webrtc/base/fileutils.h" 39 #include "webrtc/base/fileutils.h"
39 #include "webrtc/base/gunit.h" 40 #include "webrtc/base/gunit.h"
40 #include "webrtc/base/helpers.h" 41 #include "webrtc/base/helpers.h"
41 #include "webrtc/base/logging.h" 42 #include "webrtc/base/logging.h"
42 #include "webrtc/base/pathutils.h" 43 #include "webrtc/base/pathutils.h"
43 #include "webrtc/base/signalthread.h" 44 #include "webrtc/base/signalthread.h"
44 #include "webrtc/base/ssladapter.h" 45 #include "webrtc/base/ssladapter.h"
45 #include "webrtc/base/sslidentity.h" 46 #include "webrtc/base/sslidentity.h"
46 #include "webrtc/base/window.h" 47 #include "webrtc/base/window.h"
48 #include "webrtc/p2p/base/faketransportcontroller.h"
47 49
48 #define MAYBE_SKIP_TEST(feature) \ 50 #define MAYBE_SKIP_TEST(feature) \
49 if (!(rtc::SSLStreamAdapter::feature())) { \ 51 if (!(rtc::SSLStreamAdapter::feature())) { \
50 LOG(LS_INFO) << "Feature disabled... skipping"; \ 52 LOG(LS_INFO) << "Feature disabled... skipping"; \
51 return; \ 53 return; \
52 } 54 }
53 55
54 using cricket::CA_OFFER; 56 using cricket::CA_OFFER;
55 using cricket::CA_PRANSWER; 57 using cricket::CA_PRANSWER;
56 using cricket::CA_ANSWER; 58 using cricket::CA_ANSWER;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 DTLS = 0x10 }; 129 DTLS = 0x10 };
128 130
129 ChannelTest(bool verify_playout, 131 ChannelTest(bool verify_playout,
130 const uint8* rtp_data, 132 const uint8* rtp_data,
131 int rtp_len, 133 int rtp_len,
132 const uint8* rtcp_data, 134 const uint8* rtcp_data,
133 int rtcp_len) 135 int rtcp_len)
134 : verify_playout_(verify_playout), 136 : verify_playout_(verify_playout),
135 transport_controller1_(cricket::ICEROLE_CONTROLLING), 137 transport_controller1_(cricket::ICEROLE_CONTROLLING),
136 transport_controller2_(cricket::ICEROLE_CONTROLLED), 138 transport_controller2_(cricket::ICEROLE_CONTROLLED),
139 call_(webrtc::Call::Config()),
140 media_controller_(&call_),
137 media_channel1_(NULL), 141 media_channel1_(NULL),
138 media_channel2_(NULL), 142 media_channel2_(NULL),
139 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), 143 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
140 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), 144 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
141 media_info_callbacks1_(), 145 media_info_callbacks1_(),
142 media_info_callbacks2_() {} 146 media_info_callbacks2_() {}
143 147
144 void CreateChannels(int flags1, int flags2) { 148 void CreateChannels(int flags1, int flags2) {
145 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), 149 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()),
146 new typename T::MediaChannel(NULL, typename T::Options()), 150 new typename T::MediaChannel(NULL, typename T::Options()),
147 flags1, flags2, rtc::Thread::Current()); 151 flags1, flags2, rtc::Thread::Current());
148 } 152 }
149 void CreateChannels( 153 void CreateChannels(
150 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, 154 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2,
151 int flags1, int flags2, rtc::Thread* thread) { 155 int flags1, int flags2, rtc::Thread* thread) {
152 media_channel1_ = ch1; 156 media_channel1_ = ch1;
153 media_channel2_ = ch2; 157 media_channel2_ = ch2;
154 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, 158 channel1_.reset(CreateChannel(thread, &media_engine_, ch1,
155 &transport_controller1_, 159 &media_controller_, &transport_controller1_,
156 (flags1 & RTCP) != 0)); 160 (flags1 & RTCP) != 0));
157 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, 161 channel2_.reset(CreateChannel(thread, &media_engine_, ch2,
158 &transport_controller2_, 162 &media_controller_, &transport_controller2_,
159 (flags2 & RTCP) != 0)); 163 (flags2 & RTCP) != 0));
160 channel1_->SignalMediaMonitor.connect( 164 channel1_->SignalMediaMonitor.connect(
161 this, &ChannelTest<T>::OnMediaMonitor); 165 this, &ChannelTest<T>::OnMediaMonitor);
162 channel2_->SignalMediaMonitor.connect( 166 channel2_->SignalMediaMonitor.connect(
163 this, &ChannelTest<T>::OnMediaMonitor); 167 this, &ChannelTest<T>::OnMediaMonitor);
164 if ((flags1 & DTLS) && (flags2 & DTLS)) { 168 if ((flags1 & DTLS) && (flags2 & DTLS)) {
165 flags1 = (flags1 & ~SECURE); 169 flags1 = (flags1 & ~SECURE);
166 flags2 = (flags2 & ~SECURE); 170 flags2 = (flags2 & ~SECURE);
167 } 171 }
168 CreateContent(flags1, kPcmuCodec, kH264Codec, 172 CreateContent(flags1, kPcmuCodec, kH264Codec,
(...skipping 29 matching lines...) Expand all
198 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); 202 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
199 } 203 }
200 if (flags2 & SSRC_MUX) { 204 if (flags2 & SSRC_MUX) {
201 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); 205 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
202 } 206 }
203 } 207 }
204 typename T::Channel* CreateChannel( 208 typename T::Channel* CreateChannel(
205 rtc::Thread* thread, 209 rtc::Thread* thread,
206 cricket::MediaEngineInterface* engine, 210 cricket::MediaEngineInterface* engine,
207 typename T::MediaChannel* ch, 211 typename T::MediaChannel* ch,
212 webrtc::MediaControllerInterface* media_controller,
208 cricket::TransportController* transport_controller, 213 cricket::TransportController* transport_controller,
209 bool rtcp) { 214 bool rtcp) {
210 typename T::Channel* channel = new typename T::Channel( 215 typename T::Channel* channel =
211 thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp); 216 new typename T::Channel(thread, engine, ch, media_controller,
217 transport_controller, cricket::CN_AUDIO, rtcp);
212 if (!channel->Init()) { 218 if (!channel->Init()) {
213 delete channel; 219 delete channel;
214 channel = NULL; 220 channel = NULL;
215 } 221 }
216 return channel; 222 return channel;
217 } 223 }
218 224
219 bool SendInitiate() { 225 bool SendInitiate() {
220 bool result = channel1_->SetLocalContent(&local_media_content1_, 226 bool result = channel1_->SetLocalContent(&local_media_content1_,
221 CA_OFFER, NULL); 227 CA_OFFER, NULL);
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 EXPECT_FALSE(media_channel1_->ready_to_send()); 1788 EXPECT_FALSE(media_channel1_->ready_to_send());
1783 } 1789 }
1784 1790
1785 protected: 1791 protected:
1786 // TODO(pbos): Remove playout from all media channels and let renderers mute 1792 // TODO(pbos): Remove playout from all media channels and let renderers mute
1787 // themselves. 1793 // themselves.
1788 const bool verify_playout_; 1794 const bool verify_playout_;
1789 cricket::FakeTransportController transport_controller1_; 1795 cricket::FakeTransportController transport_controller1_;
1790 cricket::FakeTransportController transport_controller2_; 1796 cricket::FakeTransportController transport_controller2_;
1791 cricket::FakeMediaEngine media_engine_; 1797 cricket::FakeMediaEngine media_engine_;
1798 cricket::FakeCall call_;
1799 cricket::FakeMediaController media_controller_;
1792 // The media channels are owned by the voice channel objects below. 1800 // The media channels are owned by the voice channel objects below.
1793 typename T::MediaChannel* media_channel1_; 1801 typename T::MediaChannel* media_channel1_;
1794 typename T::MediaChannel* media_channel2_; 1802 typename T::MediaChannel* media_channel2_;
1795 rtc::scoped_ptr<typename T::Channel> channel1_; 1803 rtc::scoped_ptr<typename T::Channel> channel1_;
1796 rtc::scoped_ptr<typename T::Channel> channel2_; 1804 rtc::scoped_ptr<typename T::Channel> channel2_;
1797 typename T::Content local_media_content1_; 1805 typename T::Content local_media_content1_;
1798 typename T::Content local_media_content2_; 1806 typename T::Content local_media_content2_;
1799 typename T::Content remote_media_content1_; 1807 typename T::Content remote_media_content1_;
1800 typename T::Content remote_media_content2_; 1808 typename T::Content remote_media_content2_;
1801 // The RTP and RTCP packets to send in the tests. 1809 // The RTP and RTCP packets to send in the tests.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 kRtcpReport, 1859 kRtcpReport,
1852 sizeof(kRtcpReport)) {} 1860 sizeof(kRtcpReport)) {}
1853 }; 1861 };
1854 1862
1855 // override to add NULL parameter 1863 // override to add NULL parameter
1856 template <> 1864 template <>
1857 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( 1865 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
1858 rtc::Thread* thread, 1866 rtc::Thread* thread,
1859 cricket::MediaEngineInterface* engine, 1867 cricket::MediaEngineInterface* engine,
1860 cricket::FakeVideoMediaChannel* ch, 1868 cricket::FakeVideoMediaChannel* ch,
1869 webrtc::MediaControllerInterface* media_controller,
1861 cricket::TransportController* transport_controller, 1870 cricket::TransportController* transport_controller,
1862 bool rtcp) { 1871 bool rtcp) {
1863 cricket::VideoChannel* channel = new cricket::VideoChannel( 1872 cricket::VideoChannel* channel =
1864 thread, ch, transport_controller, cricket::CN_VIDEO, rtcp); 1873 new cricket::VideoChannel(thread, ch, media_controller,
1874 transport_controller, cricket::CN_VIDEO, rtcp);
1865 if (!channel->Init()) { 1875 if (!channel->Init()) {
1866 delete channel; 1876 delete channel;
1867 channel = NULL; 1877 channel = NULL;
1868 } 1878 }
1869 return channel; 1879 return channel;
1870 } 1880 }
1871 1881
1872 // override to add 0 parameter 1882 // override to add 0 parameter
1873 template<> 1883 template<>
1874 bool ChannelTest<VideoTraits>::AddStream1(int id) { 1884 bool ChannelTest<VideoTraits>::AddStream1(int id) {
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 } 2533 }
2524 2534
2525 TEST_F(VideoChannelTest, TestOnReadyToSend) { 2535 TEST_F(VideoChannelTest, TestOnReadyToSend) {
2526 Base::TestOnReadyToSend(); 2536 Base::TestOnReadyToSend();
2527 } 2537 }
2528 2538
2529 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { 2539 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) {
2530 Base::TestOnReadyToSendWithRtcpMux(); 2540 Base::TestOnReadyToSendWithRtcpMux();
2531 } 2541 }
2532 2542
2543 TEST_F(VideoChannelTest, OnSentPacketIsCalled) {
2544 Base::SendRtpToRtp();
2545 EXPECT_TRUE(call_.on_packet_sent_called());
2546 }
2547
2533 TEST_F(VideoChannelTest, TestApplyViewRequest) { 2548 TEST_F(VideoChannelTest, TestApplyViewRequest) {
2534 CreateChannels(0, 0); 2549 CreateChannels(0, 0);
2535 cricket::StreamParams stream2; 2550 cricket::StreamParams stream2;
2536 stream2.id = "stream2"; 2551 stream2.id = "stream2";
2537 stream2.ssrcs.push_back(2222); 2552 stream2.ssrcs.push_back(2222);
2538 local_media_content1_.AddStream(stream2); 2553 local_media_content1_.AddStream(stream2);
2539 2554
2540 EXPECT_TRUE(SendInitiate()); 2555 EXPECT_TRUE(SendInitiate());
2541 EXPECT_TRUE(SendAccept()); 2556 EXPECT_TRUE(SendAccept());
2542 2557
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 kRtcpReport, 2620 kRtcpReport,
2606 sizeof(kRtcpReport)) {} 2621 sizeof(kRtcpReport)) {}
2607 }; 2622 };
2608 2623
2609 // Override to avoid engine channel parameter. 2624 // Override to avoid engine channel parameter.
2610 template <> 2625 template <>
2611 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( 2626 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
2612 rtc::Thread* thread, 2627 rtc::Thread* thread,
2613 cricket::MediaEngineInterface* engine, 2628 cricket::MediaEngineInterface* engine,
2614 cricket::FakeDataMediaChannel* ch, 2629 cricket::FakeDataMediaChannel* ch,
2630 webrtc::MediaControllerInterface* media_controller,
2615 cricket::TransportController* transport_controller, 2631 cricket::TransportController* transport_controller,
2616 bool rtcp) { 2632 bool rtcp) {
2617 cricket::DataChannel* channel = new cricket::DataChannel( 2633 cricket::DataChannel* channel = new cricket::DataChannel(
2618 thread, ch, transport_controller, cricket::CN_DATA, rtcp); 2634 thread, ch, transport_controller, cricket::CN_DATA, rtcp);
2619 if (!channel->Init()) { 2635 if (!channel->Init()) {
2620 delete channel; 2636 delete channel;
2621 channel = NULL; 2637 channel = NULL;
2622 } 2638 }
2623 return channel; 2639 return channel;
2624 } 2640 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 }; 2810 };
2795 rtc::Buffer payload(data, 3); 2811 rtc::Buffer payload(data, 3);
2796 cricket::SendDataResult result; 2812 cricket::SendDataResult result;
2797 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2813 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2798 EXPECT_EQ(params.ssrc, 2814 EXPECT_EQ(params.ssrc,
2799 media_channel1_->last_sent_data_params().ssrc); 2815 media_channel1_->last_sent_data_params().ssrc);
2800 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2816 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2801 } 2817 }
2802 2818
2803 // TODO(pthatcher): TestSetReceiver? 2819 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698