OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 #include "webrtc/test/gtest.h" | 14 #include "webrtc/test/gtest.h" |
15 | 15 |
16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
17 | 17 |
18 #include "webrtc/base/rate_limiter.h" | 18 #include "webrtc/base/rate_limiter.h" |
19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 namespace { | 25 namespace { |
26 #define test_rate 64000u | 26 |
27 const uint32_t kTestRate = 64000u; | |
28 const uint8_t kTestPayload[] = { 't', 'e', 's', 't' }; | |
29 const uint8_t kPcmuPayloadType = 96; | |
30 const uint8_t kDtmfPayloadType = 97; | |
31 | |
32 struct CngCodecSpec { | |
33 int payload_type; | |
34 int clockrate_hz; | |
35 }; | |
36 | |
37 const CngCodecSpec kCngCodecs[] = {{13, 8000}, | |
38 {103, 16000}, | |
39 {104, 32000}, | |
40 {105, 48000}}; | |
41 | |
42 bool IsComfortNoisePayload(uint8_t payloadType) { | |
danilchap
2016/10/05 08:12:57
s/payloadType/payload_type/
| |
43 for (const auto& c : kCngCodecs) { | |
44 if (c.payload_type == payloadType) | |
45 return true; | |
46 } | |
47 | |
48 return false; | |
49 } | |
27 | 50 |
28 class VerifyingAudioReceiver : public NullRtpData { | 51 class VerifyingAudioReceiver : public NullRtpData { |
29 public: | 52 public: |
30 int32_t OnReceivedPayloadData( | 53 int32_t OnReceivedPayloadData( |
31 const uint8_t* payloadData, | 54 const uint8_t* payloadData, |
32 size_t payloadSize, | 55 size_t payloadSize, |
33 const webrtc::WebRtcRTPHeader* rtpHeader) override { | 56 const webrtc::WebRtcRTPHeader* rtpHeader) override { |
34 if (rtpHeader->header.payloadType == 98 || | 57 const uint8_t payload_type = rtpHeader->header.payloadType; |
35 rtpHeader->header.payloadType == 99) { | 58 if (payload_type == kPcmuPayloadType || payload_type == kDtmfPayloadType) { |
36 EXPECT_EQ(4u, payloadSize); | 59 EXPECT_EQ(sizeof(kTestPayload), payloadSize); |
37 char str[5]; | |
38 memcpy(str, payloadData, payloadSize); | |
39 str[4] = 0; | |
40 // All our test vectors for payload type 96 and 97 even the stereo is on | 60 // All our test vectors for payload type 96 and 97 even the stereo is on |
danilchap
2016/10/05 08:12:57
may be update the comment with improvements to cod
| |
41 // a per channel base equal to the 4 chars "test". | 61 // a per channel base equal to the 4 chars "test". |
42 // Note there is no null termination so we add that to use the | 62 const size_t min_size = std::min(sizeof(kTestPayload), payloadSize); |
43 // test EXPECT_STRCASEEQ. | 63 EXPECT_EQ(0, memcmp(payloadData, kTestPayload, min_size)); |
44 EXPECT_STRCASEEQ("test", str); | 64 } else if (IsComfortNoisePayload(payload_type)) { |
45 return 0; | 65 // CNG types should be recognized properly. |
46 } | 66 EXPECT_EQ(kAudioFrameCN, rtpHeader->frameType); |
47 if (rtpHeader->header.payloadType == 100 || | 67 EXPECT_TRUE(rtpHeader->type.Audio.isCNG); |
48 rtpHeader->header.payloadType == 101 || | |
49 rtpHeader->header.payloadType == 102) { | |
50 if (rtpHeader->type.Audio.channel == 1) { | |
51 if (payloadData[0] == 0xff) { | |
52 // All our test vectors for payload type 100, 101 and 102 have the | |
53 // first channel data being equal to 0xff. | |
54 return 0; | |
55 } | |
56 } | |
57 ADD_FAILURE() << "This code path should never happen."; | |
58 return -1; | |
59 } | 68 } |
60 return 0; | 69 return 0; |
61 } | 70 } |
62 }; | 71 }; |
63 | 72 |
64 class RTPCallback : public NullRtpFeedback { | 73 class RTPCallback : public NullRtpFeedback { |
65 public: | 74 public: |
66 int32_t OnInitializeDecoder(const int8_t payloadType, | 75 int32_t OnInitializeDecoder(const int8_t payloadType, |
67 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 76 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
68 const int frequency, | 77 const int frequency, |
69 const size_t channels, | 78 const size_t channels, |
70 const uint32_t rate) override { | 79 const uint32_t rate) override { |
71 if (payloadType == 96) { | 80 if (payloadType == kPcmuPayloadType) { |
72 EXPECT_EQ(test_rate, rate) << | 81 EXPECT_EQ(kTestRate, rate) << |
73 "The rate should be 64K for this payloadType"; | 82 "The rate should be 64K for this payloadType"; |
74 } | 83 } |
75 return 0; | 84 return 0; |
76 } | 85 } |
77 }; | 86 }; |
78 | 87 |
88 } // namespace | |
89 | |
79 class RtpRtcpAudioTest : public ::testing::Test { | 90 class RtpRtcpAudioTest : public ::testing::Test { |
80 protected: | 91 protected: |
81 RtpRtcpAudioTest() | 92 RtpRtcpAudioTest() |
82 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) { | 93 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) { |
83 test_CSRC[0] = 1234; | 94 test_CSRC[0] = 1234; |
84 test_CSRC[2] = 2345; | 95 test_CSRC[2] = 2345; |
85 test_ssrc = 3456; | 96 test_ssrc = 3456; |
86 test_timestamp = 4567; | 97 test_timestamp = 4567; |
87 test_sequence_number = 2345; | 98 test_sequence_number = 2345; |
88 } | 99 } |
89 ~RtpRtcpAudioTest() {} | 100 ~RtpRtcpAudioTest() {} |
90 | 101 |
91 void SetUp() override { | 102 void SetUp() override { |
92 data_receiver1 = new VerifyingAudioReceiver(); | 103 data_receiver1.reset(new VerifyingAudioReceiver()); |
93 data_receiver2 = new VerifyingAudioReceiver(); | 104 data_receiver2.reset(new VerifyingAudioReceiver()); |
94 rtp_callback = new RTPCallback(); | 105 rtp_callback.reset(new RTPCallback()); |
95 transport1 = new LoopBackTransport(); | 106 transport1.reset(new LoopBackTransport()); |
96 transport2 = new LoopBackTransport(); | 107 transport2.reset(new LoopBackTransport()); |
97 | 108 |
98 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); | 109 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); |
99 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); | 110 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); |
100 | 111 |
101 rtp_payload_registry1_.reset(new RTPPayloadRegistry( | 112 rtp_payload_registry1_.reset(new RTPPayloadRegistry( |
102 RTPPayloadStrategy::CreateStrategy(true))); | 113 RTPPayloadStrategy::CreateStrategy(true))); |
103 rtp_payload_registry2_.reset(new RTPPayloadRegistry( | 114 rtp_payload_registry2_.reset(new RTPPayloadRegistry( |
104 RTPPayloadStrategy::CreateStrategy(true))); | 115 RTPPayloadStrategy::CreateStrategy(true))); |
105 | 116 |
106 RtpRtcp::Configuration configuration; | 117 RtpRtcp::Configuration configuration; |
107 configuration.audio = true; | 118 configuration.audio = true; |
108 configuration.clock = &fake_clock; | 119 configuration.clock = &fake_clock; |
109 configuration.receive_statistics = receive_statistics1_.get(); | 120 configuration.receive_statistics = receive_statistics1_.get(); |
110 configuration.outgoing_transport = transport1; | 121 configuration.outgoing_transport = transport1.get(); |
111 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; | 122 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; |
112 | 123 |
113 module1 = RtpRtcp::CreateRtpRtcp(configuration); | 124 module1.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
114 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( | 125 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( |
115 &fake_clock, data_receiver1, NULL, rtp_payload_registry1_.get())); | 126 &fake_clock, data_receiver1.get(), NULL, rtp_payload_registry1_.get())); |
116 | 127 |
117 configuration.receive_statistics = receive_statistics2_.get(); | 128 configuration.receive_statistics = receive_statistics2_.get(); |
118 configuration.outgoing_transport = transport2; | 129 configuration.outgoing_transport = transport2.get(); |
119 | 130 |
120 module2 = RtpRtcp::CreateRtpRtcp(configuration); | 131 module2.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
121 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( | 132 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( |
122 &fake_clock, data_receiver2, NULL, rtp_payload_registry2_.get())); | 133 &fake_clock, data_receiver2.get(), NULL, rtp_payload_registry2_.get())); |
123 | 134 |
124 transport1->SetSendModule(module2, rtp_payload_registry2_.get(), | 135 transport1->SetSendModule(module2.get(), rtp_payload_registry2_.get(), |
125 rtp_receiver2_.get(), receive_statistics2_.get()); | 136 rtp_receiver2_.get(), receive_statistics2_.get()); |
126 transport2->SetSendModule(module1, rtp_payload_registry1_.get(), | 137 transport2->SetSendModule(module1.get(), rtp_payload_registry1_.get(), |
127 rtp_receiver1_.get(), receive_statistics1_.get()); | 138 rtp_receiver1_.get(), receive_statistics1_.get()); |
128 } | 139 } |
129 | 140 |
130 void TearDown() override { | 141 void RegisterPayload(const CodecInst& codec) { |
danilchap
2016/10/05 08:12:57
nice helper. makes test below obviously clearer.
ossu
2016/10/05 09:42:29
\o/
| |
131 delete module1; | 142 EXPECT_EQ(0, module1->RegisterSendPayload(codec)); |
132 delete module2; | 143 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload( |
133 delete transport1; | 144 codec.plname, |
134 delete transport2; | 145 codec.pltype, |
135 delete data_receiver1; | 146 codec.plfreq, |
136 delete data_receiver2; | 147 codec.channels, |
137 delete rtp_callback; | 148 codec.rate)); |
149 EXPECT_EQ(0, module2->RegisterSendPayload(codec)); | |
150 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( | |
151 codec.plname, | |
152 codec.pltype, | |
153 codec.plfreq, | |
154 codec.channels, | |
155 codec.rate)); | |
138 } | 156 } |
139 | 157 |
140 RtpRtcp* module1; | 158 std::unique_ptr<RtpRtcp> module1; |
danilchap
2016/10/05 08:12:57
likely be better to put modules last so that they
ossu
2016/10/05 09:42:29
Done.
| |
141 RtpRtcp* module2; | 159 std::unique_ptr<RtpRtcp> module2; |
142 std::unique_ptr<ReceiveStatistics> receive_statistics1_; | 160 std::unique_ptr<ReceiveStatistics> receive_statistics1_; |
143 std::unique_ptr<ReceiveStatistics> receive_statistics2_; | 161 std::unique_ptr<ReceiveStatistics> receive_statistics2_; |
144 std::unique_ptr<RtpReceiver> rtp_receiver1_; | 162 std::unique_ptr<RtpReceiver> rtp_receiver1_; |
145 std::unique_ptr<RtpReceiver> rtp_receiver2_; | 163 std::unique_ptr<RtpReceiver> rtp_receiver2_; |
146 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry1_; | 164 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry1_; |
147 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry2_; | 165 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry2_; |
148 VerifyingAudioReceiver* data_receiver1; | 166 std::unique_ptr<VerifyingAudioReceiver> data_receiver1; |
danilchap
2016/10/05 08:12:57
might also turn this members from unique pointers
ossu
2016/10/05 09:42:29
Done. Turned out rtp_callback was never used, so I
| |
149 VerifyingAudioReceiver* data_receiver2; | 167 std::unique_ptr<VerifyingAudioReceiver> data_receiver2; |
150 LoopBackTransport* transport1; | 168 std::unique_ptr<LoopBackTransport> transport1; |
151 LoopBackTransport* transport2; | 169 std::unique_ptr<LoopBackTransport> transport2; |
152 RTPCallback* rtp_callback; | 170 std::unique_ptr<RTPCallback> rtp_callback; |
153 uint32_t test_ssrc; | 171 uint32_t test_ssrc; |
154 uint32_t test_timestamp; | 172 uint32_t test_timestamp; |
155 uint16_t test_sequence_number; | 173 uint16_t test_sequence_number; |
156 uint32_t test_CSRC[webrtc::kRtpCsrcSize]; | 174 uint32_t test_CSRC[webrtc::kRtpCsrcSize]; |
157 SimulatedClock fake_clock; | 175 SimulatedClock fake_clock; |
158 RateLimiter retransmission_rate_limiter_; | 176 RateLimiter retransmission_rate_limiter_; |
159 }; | 177 }; |
160 | 178 |
161 TEST_F(RtpRtcpAudioTest, Basic) { | 179 TEST_F(RtpRtcpAudioTest, Basic) { |
162 module1->SetSSRC(test_ssrc); | 180 module1->SetSSRC(test_ssrc); |
163 module1->SetStartTimestamp(test_timestamp); | 181 module1->SetStartTimestamp(test_timestamp); |
164 | 182 |
165 // Test detection at the end of a DTMF tone. | 183 // Test detection at the end of a DTMF tone. |
166 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); | 184 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); |
167 | 185 |
168 EXPECT_EQ(0, module1->SetSendingStatus(true)); | 186 EXPECT_EQ(0, module1->SetSendingStatus(true)); |
169 | 187 |
170 // Start basic RTP test. | 188 // Start basic RTP test. |
171 | 189 |
172 // Send an empty RTP packet. | 190 // Send an empty RTP packet. |
173 // Should fail since we have not registered the payload type. | 191 // Should fail since we have not registered the payload type. |
174 EXPECT_FALSE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1, | 192 EXPECT_FALSE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, |
175 nullptr, 0, nullptr, nullptr, | 193 kPcmuPayloadType, 0, -1, nullptr, 0, |
176 nullptr)); | 194 nullptr, nullptr, nullptr)); |
177 | 195 |
178 CodecInst voice_codec; | 196 CodecInst voice_codec; |
179 memset(&voice_codec, 0, sizeof(voice_codec)); | 197 memset(&voice_codec, 0, sizeof(voice_codec)); |
180 voice_codec.pltype = 96; | 198 voice_codec.pltype = kPcmuPayloadType; |
181 voice_codec.plfreq = 8000; | 199 voice_codec.plfreq = 8000; |
182 memcpy(voice_codec.plname, "PCMU", 5); | 200 memcpy(voice_codec.plname, "PCMU", 5); |
201 RegisterPayload(voice_codec); | |
183 | 202 |
184 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); | 203 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, |
185 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload( | 204 kPcmuPayloadType, 0, -1, kTestPayload, |
186 voice_codec.plname, | 205 4, nullptr, nullptr, nullptr)); |
187 voice_codec.pltype, | |
188 voice_codec.plfreq, | |
189 voice_codec.channels, | |
190 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); | |
191 EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec)); | |
192 voice_codec.rate = test_rate; | |
193 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( | |
194 voice_codec.plname, | |
195 voice_codec.pltype, | |
196 voice_codec.plfreq, | |
197 voice_codec.channels, | |
198 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); | |
199 | |
200 const uint8_t test[5] = "test"; | |
201 EXPECT_EQ(true, | |
202 module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1, | |
203 test, 4, nullptr, nullptr, nullptr)); | |
204 | 206 |
205 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC()); | 207 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC()); |
206 uint32_t timestamp; | 208 uint32_t timestamp; |
207 EXPECT_TRUE(rtp_receiver2_->Timestamp(×tamp)); | 209 EXPECT_TRUE(rtp_receiver2_->Timestamp(×tamp)); |
208 EXPECT_EQ(test_timestamp, timestamp); | 210 EXPECT_EQ(test_timestamp, timestamp); |
209 } | 211 } |
210 | 212 |
211 TEST_F(RtpRtcpAudioTest, DTMF) { | 213 TEST_F(RtpRtcpAudioTest, DTMF) { |
212 CodecInst voice_codec; | 214 CodecInst voice_codec; |
213 memset(&voice_codec, 0, sizeof(voice_codec)); | 215 memset(&voice_codec, 0, sizeof(voice_codec)); |
214 voice_codec.pltype = 96; | 216 voice_codec.pltype = kPcmuPayloadType; |
215 voice_codec.plfreq = 8000; | 217 voice_codec.plfreq = 8000; |
218 voice_codec.rate = kTestRate; | |
216 memcpy(voice_codec.plname, "PCMU", 5); | 219 memcpy(voice_codec.plname, "PCMU", 5); |
217 | 220 RegisterPayload(voice_codec); |
218 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); | |
219 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload( | |
220 voice_codec.plname, | |
221 voice_codec.pltype, | |
222 voice_codec.plfreq, | |
223 voice_codec.channels, | |
224 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); | |
225 EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec)); | |
226 voice_codec.rate = test_rate; | |
227 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( | |
228 voice_codec.plname, | |
229 voice_codec.pltype, | |
230 voice_codec.plfreq, | |
231 voice_codec.channels, | |
232 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); | |
233 | 221 |
234 module1->SetSSRC(test_ssrc); | 222 module1->SetSSRC(test_ssrc); |
235 module1->SetStartTimestamp(test_timestamp); | 223 module1->SetStartTimestamp(test_timestamp); |
236 EXPECT_EQ(0, module1->SetSendingStatus(true)); | 224 EXPECT_EQ(0, module1->SetSendingStatus(true)); |
237 | 225 |
238 // Prepare for DTMF. | 226 // Prepare for DTMF. |
239 voice_codec.pltype = 97; | 227 voice_codec.pltype = kDtmfPayloadType; |
240 voice_codec.plfreq = 8000; | 228 voice_codec.plfreq = 8000; |
241 memcpy(voice_codec.plname, "telephone-event", 16); | 229 memcpy(voice_codec.plname, "telephone-event", 16); |
242 | 230 |
243 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); | 231 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); |
244 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( | 232 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( |
245 voice_codec.plname, | 233 voice_codec.plname, |
246 voice_codec.pltype, | 234 voice_codec.pltype, |
247 voice_codec.plfreq, | 235 voice_codec.plfreq, |
248 voice_codec.channels, | 236 voice_codec.channels, |
249 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); | 237 voice_codec.rate)); |
250 | 238 |
251 // Start DTMF test. | 239 // Start DTMF test. |
252 int timeStamp = 160; | 240 int timeStamp = 160; |
253 | 241 |
254 // Send a DTMF tone using RFC 2833 (4733). | 242 // Send a DTMF tone using RFC 2833 (4733). |
255 for (int i = 0; i < 16; i++) { | 243 for (int i = 0; i < 16; i++) { |
256 EXPECT_EQ(0, module1->SendTelephoneEventOutband(i, timeStamp, 10)); | 244 EXPECT_EQ(0, module1->SendTelephoneEventOutband(i, timeStamp, 10)); |
257 } | 245 } |
258 timeStamp += 160; // Prepare for next packet. | 246 timeStamp += 160; // Prepare for next packet. |
259 | 247 |
260 const uint8_t test[9] = "test"; | |
261 | |
262 // Send RTP packets for 16 tones a 160 ms 100ms | 248 // Send RTP packets for 16 tones a 160 ms 100ms |
263 // pause between = 2560ms + 1600ms = 4160ms | 249 // pause between = 2560ms + 1600ms = 4160ms |
264 for (; timeStamp <= 250 * 160; timeStamp += 160) { | 250 for (; timeStamp <= 250 * 160; timeStamp += 160) { |
265 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, | 251 EXPECT_TRUE(module1->SendOutgoingData( |
266 timeStamp, -1, test, 4, nullptr, | 252 webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1, |
267 nullptr, nullptr)); | 253 kTestPayload, 4, nullptr, nullptr, nullptr)); |
268 fake_clock.AdvanceTimeMilliseconds(20); | 254 fake_clock.AdvanceTimeMilliseconds(20); |
269 module1->Process(); | 255 module1->Process(); |
270 } | 256 } |
271 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10)); | 257 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10)); |
272 | 258 |
273 for (; timeStamp <= 740 * 160; timeStamp += 160) { | 259 for (; timeStamp <= 740 * 160; timeStamp += 160) { |
274 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, | 260 EXPECT_TRUE(module1->SendOutgoingData( |
275 timeStamp, -1, test, 4, nullptr, | 261 webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1, |
276 nullptr, nullptr)); | 262 kTestPayload, 4, nullptr, nullptr, nullptr)); |
277 fake_clock.AdvanceTimeMilliseconds(20); | 263 fake_clock.AdvanceTimeMilliseconds(20); |
278 module1->Process(); | 264 module1->Process(); |
279 } | 265 } |
280 } | 266 } |
281 | 267 |
282 } // namespace | 268 TEST_F(RtpRtcpAudioTest, ComfortNoise) { |
269 module1->SetSSRC(test_ssrc); | |
270 module1->SetStartTimestamp(test_timestamp); | |
271 | |
272 EXPECT_EQ(0, module1->SetSendingStatus(true)); | |
273 | |
274 // Register PCMU and all four comfort noise codecs | |
275 CodecInst voice_codec = {0}; | |
danilchap
2016/10/05 08:12:57
Probably better to use older, primitive memset way
ossu
2016/10/05 09:42:29
I believe it will value initialize everything, jus
danilchap
2016/10/05 09:54:22
According to the link I posted since C++11 the rem
ossu
2016/10/05 10:00:57
No, it doesn't. I quote (removing the C++17 specif
danilchap
2016/10/05 10:54:09
Yes, you right, I didn't read that part careful en
ossu
2016/10/05 11:00:07
Agreed!
| |
276 voice_codec.pltype = kPcmuPayloadType; | |
277 voice_codec.plfreq = 8000; | |
278 memcpy(voice_codec.plname, "PCMU", 5); | |
279 RegisterPayload(voice_codec); | |
280 | |
281 for (const auto& c : kCngCodecs) { | |
282 CodecInst cng_codec = {0}; | |
283 cng_codec.pltype = c.payload_type; | |
284 cng_codec.plfreq = c.clockrate_hz; | |
285 memcpy(cng_codec.plname, "CN", 3); | |
286 RegisterPayload(cng_codec); | |
287 } | |
288 | |
289 // Transmit comfort noise packets interleaved by PCMU packets. | |
290 uint32_t in_timestamp = 0; | |
291 for (const auto& c : kCngCodecs) { | |
292 uint32_t timestamp; | |
293 EXPECT_TRUE(module1->SendOutgoingData( | |
294 webrtc::kAudioFrameSpeech, kPcmuPayloadType, in_timestamp, -1, | |
295 kTestPayload, 4, nullptr, nullptr, nullptr)); | |
296 | |
297 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC()); | |
298 EXPECT_TRUE(rtp_receiver2_->Timestamp(×tamp)); | |
299 EXPECT_EQ(test_timestamp + in_timestamp, timestamp); | |
300 in_timestamp += 10; | |
301 | |
302 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameCN, c.payload_type, | |
303 in_timestamp, -1, kTestPayload, 1, | |
304 nullptr, nullptr, nullptr)); | |
305 | |
306 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC()); | |
307 EXPECT_TRUE(rtp_receiver2_->Timestamp(×tamp)); | |
308 EXPECT_EQ(test_timestamp + in_timestamp, timestamp); | |
309 in_timestamp += 10; | |
310 } | |
311 } | |
312 | |
283 } // namespace webrtc | 313 } // namespace webrtc |
OLD | NEW |