Chromium Code Reviews| Index: webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc |
| diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc |
| index 2f664d74fcba57b4cd0673341fe7966a80f66ec1..28f4f04536bca2bb37c6ce4909dc5363e6764205 100644 |
| --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc |
| +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc |
| @@ -21,6 +21,7 @@ |
| #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
| +#include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" |
| @@ -1424,35 +1425,76 @@ TEST_F(RtpSenderTestWithoutPacer, RespectsNackBitrateLimit) { |
| EXPECT_EQ(kNumPackets * 2, transport_.packets_sent_); |
| } |
| -// Verify that all packets of a frame have CVO byte set. |
| -TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { |
| +TEST_F(RtpSenderVideoTest, KeyFrameHasCVO) { |
| uint8_t kFrame[kMaxPacketLength]; |
| - RTPVideoHeader hdr = {0}; |
| - hdr.rotation = kVideoRotation_90; |
| - |
| EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
| - EXPECT_EQ( |
| - RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), |
| - rtp_sender_->RtpHeaderExtensionLength()); |
| + RTPVideoHeader hdr = {0}; |
| + hdr.rotation = kVideoRotation_0; |
| rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, |
| kTimestamp, 0, kFrame, sizeof(kFrame), nullptr, |
| &hdr); |
| RtpHeaderExtensionMap map; |
| map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); |
| + const auto& last_raw_packet = *transport_.sent_packets_.back(); |
| + RtpPacketReceived last_parsed_packet(&map); |
| + last_parsed_packet.Parse(last_raw_packet.data(), last_raw_packet.size()); |
| + VideoRotation rotation; |
| + EXPECT_TRUE(last_parsed_packet.GetExtension<VideoOrientation>(&rotation)); |
| + EXPECT_EQ(kVideoRotation_0, rotation); |
| +} |
| + |
| +TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenChanged) { |
| + uint8_t kFrame[kMaxPacketLength]; |
| + EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| + kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
| + |
| + RTPVideoHeader hdr = {0}; |
| + hdr.rotation = kVideoRotation_90; |
| + EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, |
| + kPayload, kTimestamp, 0, kFrame, |
| + sizeof(kFrame), nullptr, &hdr)); |
| - // Verify that this packet does have CVO byte. |
| - VerifyCVOPacket( |
| - reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
| - transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
| + hdr.rotation = kVideoRotation_0; |
| + EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameDelta, |
| + kPayload, kTimestamp + 1, 0, kFrame, |
| + sizeof(kFrame), nullptr, &hdr)); |
| - // Verify that this packet does have CVO byte. |
| - VerifyCVOPacket( |
| - reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
| - transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
| - hdr.rotation); |
| + RtpHeaderExtensionMap map; |
| + map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); |
| + const auto& last_raw_packet = *transport_.sent_packets_.back(); |
| + RtpPacketReceived last_parsed_packet(&map); |
| + last_parsed_packet.Parse(last_raw_packet.data(), last_raw_packet.size()); |
| + VideoRotation rotation; |
| + EXPECT_TRUE(last_parsed_packet.GetExtension<VideoOrientation>(&rotation)); |
| + EXPECT_EQ(kVideoRotation_0, rotation); |
| +} |
| + |
| +TEST_F(RtpSenderVideoTest, DeltaFrameHasCVOWhenNonZero) { |
| + uint8_t kFrame[kMaxPacketLength]; |
| + EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
| + kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
| + |
| + RTPVideoHeader hdr = {0}; |
| + hdr.rotation = kVideoRotation_90; |
| + EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, |
| + kPayload, kTimestamp, 0, kFrame, |
| + sizeof(kFrame), nullptr, &hdr)); |
| + |
| + EXPECT_TRUE(rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameDelta, |
| + kPayload, kTimestamp + 1, 0, kFrame, |
| + sizeof(kFrame), nullptr, &hdr)); |
| + |
| + RtpHeaderExtensionMap map; |
| + map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); |
| + const auto& last_raw_packet = *transport_.sent_packets_.back(); |
| + RtpPacketReceived last_parsed_packet(&map); |
| + last_parsed_packet.Parse(last_raw_packet.data(), last_raw_packet.size()); |
| + VideoRotation rotation; |
| + EXPECT_TRUE(last_parsed_packet.GetExtension<VideoOrientation>(&rotation)); |
| + EXPECT_EQ(kVideoRotation_90, rotation); |
|
sprang_webrtc
2016/10/25 13:39:02
There seems to be a bunch of code duplication betw
|
| } |
| // Make sure rotation is parsed correctly when the Camera (C) and Flip (F) bits |