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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 class RtpSenderVideoTest : public RtpSenderTest { | 236 class RtpSenderVideoTest : public RtpSenderTest { |
237 protected: | 237 protected: |
238 void SetUp() override { | 238 void SetUp() override { |
239 // TODO(pbos): Set up to use pacer. | 239 // TODO(pbos): Set up to use pacer. |
240 SetUpRtpSender(false); | 240 SetUpRtpSender(false); |
241 rtp_sender_video_.reset( | 241 rtp_sender_video_.reset( |
242 new RTPSenderVideo(&fake_clock_, rtp_sender_.get())); | 242 new RTPSenderVideo(&fake_clock_, rtp_sender_.get())); |
243 } | 243 } |
244 std::unique_ptr<RTPSenderVideo> rtp_sender_video_; | 244 std::unique_ptr<RTPSenderVideo> rtp_sender_video_; |
245 | |
246 void VerifyCVOPacket(const RtpPacketReceived& rtp_packet, | |
247 bool expect_cvo, | |
248 uint16_t seq_num, | |
249 VideoRotation expected_rotation) { | |
250 EXPECT_EQ(payload_, rtp_packet.PayloadType()); | |
251 EXPECT_EQ(seq_num, rtp_packet.SequenceNumber()); | |
252 EXPECT_EQ(kTimestamp, rtp_packet.Timestamp()); | |
253 EXPECT_EQ(rtp_sender_->SSRC(), rtp_packet.Ssrc()); | |
254 EXPECT_EQ(0U, rtp_packet.Csrcs().size()); | |
255 EXPECT_EQ(0U, rtp_packet.padding_size()); | |
256 VideoRotation actual_rotation; | |
257 EXPECT_TRUE(rtp_packet.GetExtension<VideoOrientation>(&actual_rotation)); | |
258 EXPECT_EQ(expected_rotation, actual_rotation); | |
259 } | |
260 }; | 245 }; |
261 | 246 |
262 TEST_F(RtpSenderTestWithoutPacer, | 247 TEST_F(RtpSenderTestWithoutPacer, |
263 RegisterRtpTransmissionTimeOffsetHeaderExtension) { | 248 RegisterRtpTransmissionTimeOffsetHeaderExtension) { |
264 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); | 249 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
265 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 250 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
266 kRtpExtensionTransmissionTimeOffset, | 251 kRtpExtensionTransmissionTimeOffset, |
267 kTransmissionTimeOffsetExtensionId)); | 252 kTransmissionTimeOffsetExtensionId)); |
268 EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, | 253 EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, |
269 rtp_sender_->RtpHeaderExtensionLength()); | 254 rtp_sender_->RtpHeaderExtensionLength()); |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent()); | 1302 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent()); |
1318 | 1303 |
1319 // Must be at least 5ms in between retransmission attempts. | 1304 // Must be at least 5ms in between retransmission attempts. |
1320 fake_clock_.AdvanceTimeMilliseconds(5); | 1305 fake_clock_.AdvanceTimeMilliseconds(5); |
1321 | 1306 |
1322 // Resending should not work, bandwidth exceeded. | 1307 // Resending should not work, bandwidth exceeded. |
1323 rtp_sender_->OnReceivedNack(sequence_numbers, 0); | 1308 rtp_sender_->OnReceivedNack(sequence_numbers, 0); |
1324 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent()); | 1309 EXPECT_EQ(kNumPackets * 2, transport_.packets_sent()); |
1325 } | 1310 } |
1326 | 1311 |
1327 // Verify that all packets of a frame have CVO byte set. | 1312 TEST_F(RtpSenderVideoTest, KeyFrameHasCVO) { |
1328 TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { | |
1329 uint8_t kFrame[kMaxPacketLength]; | 1313 uint8_t kFrame[kMaxPacketLength]; |
1330 RTPVideoHeader hdr = {0}; | |
1331 hdr.rotation = kVideoRotation_90; | |
1332 | |
1333 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 1314 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
1334 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 1315 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
1335 EXPECT_EQ( | |
1336 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), | |
1337 rtp_sender_->RtpHeaderExtensionLength()); | |
1338 | 1316 |
| 1317 RTPVideoHeader hdr = {0}; |
| 1318 hdr.rotation = kVideoRotation_0; |
1339 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, | 1319 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, |
1340 kTimestamp, 0, kFrame, sizeof(kFrame), nullptr, | 1320 kTimestamp, 0, kFrame, sizeof(kFrame), nullptr, |
1341 &hdr); | 1321 &hdr); |
1342 | 1322 |
1343 // Verify that this packet does have CVO byte. | 1323 VideoRotation rotation; |
1344 VerifyCVOPacket(transport_.sent_packets_[0], true, kSeqNum, hdr.rotation); | 1324 EXPECT_TRUE( |
| 1325 transport_.last_sent_packet().GetExtension<VideoOrientation>(&rotation)); |
| 1326 EXPECT_EQ(kVideoRotation_0, rotation); |
| 1327 } |
1345 | 1328 |
1346 // Verify that this packet does have CVO byte. | 1329 TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenChanged) { |
1347 VerifyCVOPacket(transport_.sent_packets_[1], true, kSeqNum + 1, hdr.rotation); | 1330 uint8_t kFrame[kMaxPacketLength]; |
| 1331 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| 1332 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
| 1333 |
| 1334 RTPVideoHeader hdr = {0}; |
| 1335 hdr.rotation = kVideoRotation_90; |
| 1336 EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, |
| 1337 kPayload, kTimestamp, 0, kFrame, |
| 1338 sizeof(kFrame), nullptr, &hdr)); |
| 1339 |
| 1340 hdr.rotation = kVideoRotation_0; |
| 1341 EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameDelta, |
| 1342 kPayload, kTimestamp + 1, 0, kFrame, |
| 1343 sizeof(kFrame), nullptr, &hdr)); |
| 1344 |
| 1345 VideoRotation rotation; |
| 1346 EXPECT_TRUE( |
| 1347 transport_.last_sent_packet().GetExtension<VideoOrientation>(&rotation)); |
| 1348 EXPECT_EQ(kVideoRotation_0, rotation); |
| 1349 } |
| 1350 |
| 1351 TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenNonZero) { |
| 1352 uint8_t kFrame[kMaxPacketLength]; |
| 1353 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| 1354 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
| 1355 |
| 1356 RTPVideoHeader hdr = {0}; |
| 1357 hdr.rotation = kVideoRotation_90; |
| 1358 EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, |
| 1359 kPayload, kTimestamp, 0, kFrame, |
| 1360 sizeof(kFrame), nullptr, &hdr)); |
| 1361 |
| 1362 EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameDelta, |
| 1363 kPayload, kTimestamp + 1, 0, kFrame, |
| 1364 sizeof(kFrame), nullptr, &hdr)); |
| 1365 |
| 1366 VideoRotation rotation; |
| 1367 EXPECT_TRUE( |
| 1368 transport_.last_sent_packet().GetExtension<VideoOrientation>(&rotation)); |
| 1369 EXPECT_EQ(kVideoRotation_90, rotation); |
1348 } | 1370 } |
1349 | 1371 |
1350 // Make sure rotation is parsed correctly when the Camera (C) and Flip (F) bits | 1372 // Make sure rotation is parsed correctly when the Camera (C) and Flip (F) bits |
1351 // are set in the CVO byte. | 1373 // are set in the CVO byte. |
1352 TEST_F(RtpSenderVideoTest, SendVideoWithCameraAndFlipCVO) { | 1374 TEST_F(RtpSenderVideoTest, SendVideoWithCameraAndFlipCVO) { |
1353 // Test extracting rotation when Camera (C) and Flip (F) bits are zero. | 1375 // Test extracting rotation when Camera (C) and Flip (F) bits are zero. |
1354 EXPECT_EQ(kVideoRotation_0, ConvertCVOByteToVideoRotation(0)); | 1376 EXPECT_EQ(kVideoRotation_0, ConvertCVOByteToVideoRotation(0)); |
1355 EXPECT_EQ(kVideoRotation_90, ConvertCVOByteToVideoRotation(1)); | 1377 EXPECT_EQ(kVideoRotation_90, ConvertCVOByteToVideoRotation(1)); |
1356 EXPECT_EQ(kVideoRotation_180, ConvertCVOByteToVideoRotation(2)); | 1378 EXPECT_EQ(kVideoRotation_180, ConvertCVOByteToVideoRotation(2)); |
1357 EXPECT_EQ(kVideoRotation_270, ConvertCVOByteToVideoRotation(3)); | 1379 EXPECT_EQ(kVideoRotation_270, ConvertCVOByteToVideoRotation(3)); |
1358 // Test extracting rotation when Camera (C) and Flip (F) bits are set. | 1380 // Test extracting rotation when Camera (C) and Flip (F) bits are set. |
1359 const int flip_bit = 1 << 2; | 1381 const int flip_bit = 1 << 2; |
1360 const int camera_bit = 1 << 3; | 1382 const int camera_bit = 1 << 3; |
1361 EXPECT_EQ(kVideoRotation_0, | 1383 EXPECT_EQ(kVideoRotation_0, |
1362 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 0)); | 1384 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 0)); |
1363 EXPECT_EQ(kVideoRotation_90, | 1385 EXPECT_EQ(kVideoRotation_90, |
1364 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 1)); | 1386 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 1)); |
1365 EXPECT_EQ(kVideoRotation_180, | 1387 EXPECT_EQ(kVideoRotation_180, |
1366 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 2)); | 1388 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 2)); |
1367 EXPECT_EQ(kVideoRotation_270, | 1389 EXPECT_EQ(kVideoRotation_270, |
1368 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 3)); | 1390 ConvertCVOByteToVideoRotation(flip_bit | camera_bit | 3)); |
1369 } | 1391 } |
1370 | 1392 |
1371 } // namespace webrtc | 1393 } // namespace webrtc |
OLD | NEW |