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

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

Issue 1327933002: Full impl of NnChannel::SetSendParameters and NnChannel::SetRecvParameters (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 3 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
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 static const uint32 kSsrc1 = 0x1111; 70 static const uint32 kSsrc1 = 0x1111;
71 static const uint32 kSsrc2 = 0x2222; 71 static const uint32 kSsrc2 = 0x2222;
72 static const uint32 kSsrc3 = 0x3333; 72 static const uint32 kSsrc3 = 0x3333;
73 static const int kAudioPts[] = {0, 8}; 73 static const int kAudioPts[] = {0, 8};
74 static const int kVideoPts[] = {97, 99}; 74 static const int kVideoPts[] = {97, 99};
75 75
76 template<class ChannelT, 76 template<class ChannelT,
77 class MediaChannelT, 77 class MediaChannelT,
78 class ContentT, 78 class ContentT,
79 class CodecT, 79 class CodecT,
80 class MediaInfoT> 80 class MediaInfoT,
81 class OptionsT>
81 class Traits { 82 class Traits {
82 public: 83 public:
83 typedef ChannelT Channel; 84 typedef ChannelT Channel;
84 typedef MediaChannelT MediaChannel; 85 typedef MediaChannelT MediaChannel;
85 typedef ContentT Content; 86 typedef ContentT Content;
86 typedef CodecT Codec; 87 typedef CodecT Codec;
87 typedef MediaInfoT MediaInfo; 88 typedef MediaInfoT MediaInfo;
89 typedef OptionsT Options;
88 }; 90 };
89 91
90 // Controls how long we wait for a session to send messages that we 92 // Controls how long we wait for a session to send messages that we
91 // expect, in milliseconds. We put it high to avoid flaky tests. 93 // expect, in milliseconds. We put it high to avoid flaky tests.
92 static const int kEventTimeout = 5000; 94 static const int kEventTimeout = 5000;
93 95
94 class VoiceTraits : public Traits<cricket::VoiceChannel, 96 class VoiceTraits : public Traits<cricket::VoiceChannel,
95 cricket::FakeVoiceMediaChannel, 97 cricket::FakeVoiceMediaChannel,
96 cricket::AudioContentDescription, 98 cricket::AudioContentDescription,
97 cricket::AudioCodec, 99 cricket::AudioCodec,
98 cricket::VoiceMediaInfo> { 100 cricket::VoiceMediaInfo,
101 cricket::AudioOptions> {
99 }; 102 };
100 103
101 class VideoTraits : public Traits<cricket::VideoChannel, 104 class VideoTraits : public Traits<cricket::VideoChannel,
102 cricket::FakeVideoMediaChannel, 105 cricket::FakeVideoMediaChannel,
103 cricket::VideoContentDescription, 106 cricket::VideoContentDescription,
104 cricket::VideoCodec, 107 cricket::VideoCodec,
105 cricket::VideoMediaInfo> { 108 cricket::VideoMediaInfo,
109 cricket::VideoOptions> {
106 }; 110 };
107 111
108 class DataTraits : public Traits<cricket::DataChannel, 112 class DataTraits : public Traits<cricket::DataChannel,
109 cricket::FakeDataMediaChannel, 113 cricket::FakeDataMediaChannel,
110 cricket::DataContentDescription, 114 cricket::DataContentDescription,
111 cricket::DataCodec, 115 cricket::DataCodec,
112 cricket::DataMediaInfo> { 116 cricket::DataMediaInfo,
117 cricket::DataOptions> {
113 }; 118 };
114 119
115 120
116 rtc::StreamInterface* Open(const std::string& path) { 121 rtc::StreamInterface* Open(const std::string& path) {
117 return rtc::Filesystem::OpenFile( 122 return rtc::Filesystem::OpenFile(
118 rtc::Pathname(path), "wb"); 123 rtc::Pathname(path), "wb");
119 } 124 }
120 125
121 // Base class for Voice/VideoChannel tests 126 // Base class for Voice/VideoChannel tests
122 template<class T> 127 template<class T>
(...skipping 10 matching lines...) Expand all
133 media_channel2_(NULL), 138 media_channel2_(NULL),
134 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), 139 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
135 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), 140 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
136 media_info_callbacks1_(), 141 media_info_callbacks1_(),
137 media_info_callbacks2_(), 142 media_info_callbacks2_(),
138 ssrc_(0), 143 ssrc_(0),
139 error_(T::MediaChannel::ERROR_NONE) { 144 error_(T::MediaChannel::ERROR_NONE) {
140 } 145 }
141 146
142 void CreateChannels(int flags1, int flags2) { 147 void CreateChannels(int flags1, int flags2) {
143 CreateChannels(new typename T::MediaChannel(NULL), 148 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()),
144 new typename T::MediaChannel(NULL), 149 new typename T::MediaChannel(NULL, typename T::Options()),
145 flags1, flags2, rtc::Thread::Current()); 150 flags1, flags2, rtc::Thread::Current());
146 } 151 }
147 void CreateChannels(int flags) {
148 CreateChannels(new typename T::MediaChannel(NULL),
149 new typename T::MediaChannel(NULL),
150 flags, rtc::Thread::Current());
151 }
152 void CreateChannels(int flags1, int flags2,
153 rtc::Thread* thread) {
154 CreateChannels(new typename T::MediaChannel(NULL),
155 new typename T::MediaChannel(NULL),
156 flags1, flags2, thread);
157 }
158 void CreateChannels(int flags,
159 rtc::Thread* thread) {
160 CreateChannels(new typename T::MediaChannel(NULL),
161 new typename T::MediaChannel(NULL),
162 flags, thread);
163 }
164 void CreateChannels( 152 void CreateChannels(
165 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, 153 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2,
166 int flags1, int flags2, rtc::Thread* thread) { 154 int flags1, int flags2, rtc::Thread* thread) {
167 media_channel1_ = ch1; 155 media_channel1_ = ch1;
168 media_channel2_ = ch2; 156 media_channel2_ = ch2;
169 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_, 157 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_,
170 (flags1 & RTCP) != 0)); 158 (flags1 & RTCP) != 0));
171 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_, 159 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_,
172 (flags2 & RTCP) != 0)); 160 (flags2 & RTCP) != 0));
173 channel1_->SignalMediaMonitor.connect( 161 channel1_->SignalMediaMonitor.connect(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); 197 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_);
210 198
211 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. 199 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
212 if (flags1 & SSRC_MUX) { 200 if (flags1 & SSRC_MUX) {
213 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); 201 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
214 } 202 }
215 if (flags2 & SSRC_MUX) { 203 if (flags2 & SSRC_MUX) {
216 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); 204 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
217 } 205 }
218 } 206 }
219
220 void CreateChannels(
221 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2,
222 int flags, rtc::Thread* thread) {
223 media_channel1_ = ch1;
224 media_channel2_ = ch2;
225
226 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_,
227 (flags & RTCP) != 0));
228 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session1_,
229 (flags & RTCP) != 0));
230 channel1_->SignalMediaMonitor.connect(
231 this, &ChannelTest<T>::OnMediaMonitor);
232 channel2_->SignalMediaMonitor.connect(
233 this, &ChannelTest<T>::OnMediaMonitor);
234 channel2_->SignalMediaError.connect(
235 this, &ChannelTest<T>::OnMediaChannelError);
236 CreateContent(flags, kPcmuCodec, kH264Codec,
237 &local_media_content1_);
238 CreateContent(flags, kPcmuCodec, kH264Codec,
239 &local_media_content2_);
240 CopyContent(local_media_content1_, &remote_media_content1_);
241 CopyContent(local_media_content2_, &remote_media_content2_);
242 // Add stream information (SSRC) to the local content but not to the remote
243 // content. This means that we per default know the SSRC of what we send but
244 // not what we receive.
245 AddLegacyStreamInContent(kSsrc1, flags, &local_media_content1_);
246 AddLegacyStreamInContent(kSsrc2, flags, &local_media_content2_);
247
248 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
249 if (flags & SSRC_MUX) {
250 AddLegacyStreamInContent(kSsrc1, flags, &remote_media_content1_);
251 AddLegacyStreamInContent(kSsrc2, flags, &remote_media_content2_);
252 }
253 }
254
255 typename T::Channel* CreateChannel(rtc::Thread* thread, 207 typename T::Channel* CreateChannel(rtc::Thread* thread,
256 cricket::MediaEngineInterface* engine, 208 cricket::MediaEngineInterface* engine,
257 typename T::MediaChannel* ch, 209 typename T::MediaChannel* ch,
258 cricket::BaseSession* session, 210 cricket::BaseSession* session,
259 bool rtcp) { 211 bool rtcp) {
260 typename T::Channel* channel = new typename T::Channel( 212 typename T::Channel* channel = new typename T::Channel(
261 thread, engine, ch, session, cricket::CN_AUDIO, rtcp); 213 thread, engine, ch, session, cricket::CN_AUDIO, rtcp);
262 if (!channel->Init()) { 214 if (!channel->Init()) {
263 delete channel; 215 delete channel;
264 channel = NULL; 216 channel = NULL;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 EXPECT_EQ(1U, media_channel2_->codecs().size()); 912 EXPECT_EQ(1U, media_channel2_->codecs().size());
961 } 913 }
962 914
963 // Test that we don't crash if packets are sent during call teardown 915 // Test that we don't crash if packets are sent during call teardown
964 // when RTCP mux is enabled. This is a regression test against a specific 916 // when RTCP mux is enabled. This is a regression test against a specific
965 // race condition that would only occur when a RTCP packet was sent during 917 // race condition that would only occur when a RTCP packet was sent during
966 // teardown of a channel on which RTCP mux was enabled. 918 // teardown of a channel on which RTCP mux was enabled.
967 void TestCallTeardownRtcpMux() { 919 void TestCallTeardownRtcpMux() {
968 class LastWordMediaChannel : public T::MediaChannel { 920 class LastWordMediaChannel : public T::MediaChannel {
969 public: 921 public:
970 LastWordMediaChannel() : T::MediaChannel(NULL) {} 922 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
971 ~LastWordMediaChannel() { 923 ~LastWordMediaChannel() {
972 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame)); 924 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame));
973 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); 925 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
974 } 926 }
975 }; 927 };
976 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), 928 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
977 RTCP | RTCP_MUX, RTCP | RTCP_MUX, 929 RTCP | RTCP_MUX, RTCP | RTCP_MUX,
978 rtc::Thread::Current()); 930 rtc::Thread::Current());
979 EXPECT_TRUE(SendInitiate()); 931 EXPECT_TRUE(SendInitiate());
980 EXPECT_TRUE(SendAccept()); 932 EXPECT_TRUE(SendAccept());
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 }; 2731 };
2780 rtc::Buffer payload(data, 3); 2732 rtc::Buffer payload(data, 3);
2781 cricket::SendDataResult result; 2733 cricket::SendDataResult result;
2782 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2734 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2783 EXPECT_EQ(params.ssrc, 2735 EXPECT_EQ(params.ssrc,
2784 media_channel1_->last_sent_data_params().ssrc); 2736 media_channel1_->last_sent_data_params().ssrc);
2785 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2737 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2786 } 2738 }
2787 2739
2788 // TODO(pthatcher): TestSetReceiver? 2740 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698