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 |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1259 |
1260 EXPECT_EQ(0, memcmp(extension, payload_data - sizeof(extension), | 1260 EXPECT_EQ(0, memcmp(extension, payload_data - sizeof(extension), |
1261 sizeof(extension))); | 1261 sizeof(extension))); |
1262 } | 1262 } |
1263 | 1263 |
1264 // As RFC4733, named telephone events are carried as part of the audio stream | 1264 // As RFC4733, named telephone events are carried as part of the audio stream |
1265 // and must use the same sequence number and timestamp base as the regular | 1265 // and must use the same sequence number and timestamp base as the regular |
1266 // audio channel. | 1266 // audio channel. |
1267 // This test checks the marker bit for the first packet and the consequent | 1267 // This test checks the marker bit for the first packet and the consequent |
1268 // packets of the same telephone event. Since it is specifically for DTMF | 1268 // packets of the same telephone event. Since it is specifically for DTMF |
1269 // events, ignoring audio packets and sending kFrameEmpty instead of those. | 1269 // events, ignoring audio packets and sending kEmptyFrame instead of those. |
1270 TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) { | 1270 TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) { |
1271 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "telephone-event"; | 1271 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "telephone-event"; |
1272 uint8_t payload_type = 126; | 1272 uint8_t payload_type = 126; |
1273 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 0, | 1273 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 0, |
1274 0, 0)); | 1274 0, 0)); |
1275 // For Telephone events, payload is not added to the registered payload list, | 1275 // For Telephone events, payload is not added to the registered payload list, |
1276 // it will register only the payload used for audio stream. | 1276 // it will register only the payload used for audio stream. |
1277 // Registering the payload again for audio stream with different payload name. | 1277 // Registering the payload again for audio stream with different payload name. |
1278 strcpy(payload_name, "payload_name"); | 1278 strcpy(payload_name, "payload_name"); |
1279 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 8000, | 1279 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 8000, |
1280 1, 0)); | 1280 1, 0)); |
1281 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 1281 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
1282 // DTMF event key=9, duration=500 and attenuationdB=10 | 1282 // DTMF event key=9, duration=500 and attenuationdB=10 |
1283 rtp_sender_->SendTelephoneEvent(9, 500, 10); | 1283 rtp_sender_->SendTelephoneEvent(9, 500, 10); |
1284 // During start, it takes the starting timestamp as last sent timestamp. | 1284 // During start, it takes the starting timestamp as last sent timestamp. |
1285 // The duration is calculated as the difference of current and last sent | 1285 // The duration is calculated as the difference of current and last sent |
1286 // timestamp. So for first call it will skip since the duration is zero. | 1286 // timestamp. So for first call it will skip since the duration is zero. |
1287 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kFrameEmpty, payload_type, | 1287 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1288 capture_time_ms, 0, nullptr, 0, | 1288 capture_time_ms, 0, nullptr, 0, |
1289 nullptr)); | 1289 nullptr)); |
1290 // DTMF Sample Length is (Frequency/1000) * Duration. | 1290 // DTMF Sample Length is (Frequency/1000) * Duration. |
1291 // So in this case, it is (8000/1000) * 500 = 4000. | 1291 // So in this case, it is (8000/1000) * 500 = 4000. |
1292 // Sending it as two packets. | 1292 // Sending it as two packets. |
1293 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kFrameEmpty, payload_type, | 1293 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1294 capture_time_ms + 2000, 0, nullptr, | 1294 capture_time_ms + 2000, 0, nullptr, |
1295 0, nullptr)); | 1295 0, nullptr)); |
1296 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser( | 1296 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser( |
1297 webrtc::RtpHeaderParser::Create()); | 1297 webrtc::RtpHeaderParser::Create()); |
1298 ASSERT_TRUE(rtp_parser.get() != nullptr); | 1298 ASSERT_TRUE(rtp_parser.get() != nullptr); |
1299 webrtc::RTPHeader rtp_header; | 1299 webrtc::RTPHeader rtp_header; |
1300 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, | 1300 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, |
1301 transport_.last_sent_packet_len_, | 1301 transport_.last_sent_packet_len_, |
1302 &rtp_header)); | 1302 &rtp_header)); |
1303 // Marker Bit should be set to 1 for first packet. | 1303 // Marker Bit should be set to 1 for first packet. |
1304 EXPECT_TRUE(rtp_header.markerBit); | 1304 EXPECT_TRUE(rtp_header.markerBit); |
1305 | 1305 |
1306 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kFrameEmpty, payload_type, | 1306 ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, |
1307 capture_time_ms + 4000, 0, nullptr, | 1307 capture_time_ms + 4000, 0, nullptr, |
1308 0, nullptr)); | 1308 0, nullptr)); |
1309 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, | 1309 ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, |
1310 transport_.last_sent_packet_len_, | 1310 transport_.last_sent_packet_len_, |
1311 &rtp_header)); | 1311 &rtp_header)); |
1312 // Marker Bit should be set to 0 for rest of the packets. | 1312 // Marker Bit should be set to 0 for rest of the packets. |
1313 EXPECT_FALSE(rtp_header.markerBit); | 1313 EXPECT_FALSE(rtp_header.markerBit); |
1314 } | 1314 } |
1315 | 1315 |
1316 TEST_F(RtpSenderTestWithoutPacer, BytesReportedCorrectly) { | 1316 TEST_F(RtpSenderTestWithoutPacer, BytesReportedCorrectly) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), | 1420 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
1421 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); | 1421 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
1422 | 1422 |
1423 // Verify that this packet does have CVO byte. | 1423 // Verify that this packet does have CVO byte. |
1424 VerifyCVOPacket( | 1424 VerifyCVOPacket( |
1425 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), | 1425 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
1426 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, | 1426 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
1427 hdr.rotation); | 1427 hdr.rotation); |
1428 } | 1428 } |
1429 } // namespace webrtc | 1429 } // namespace webrtc |
OLD | NEW |