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 <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "webrtc/api/video/video_timing.h" | |
15 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" | 14 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" |
16 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 15 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
17 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" |
18 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 .Times(0); // Not called because packet should not be protected. | 987 .Times(0); // Not called because packet should not be protected. |
989 | 988 |
990 const uint32_t kTimestamp = 1234; | 989 const uint32_t kTimestamp = 1234; |
991 const uint8_t kPayloadType = 127; | 990 const uint8_t kPayloadType = 127; |
992 const int64_t kCaptureTimeMs = fake_clock_.TimeInMilliseconds(); | 991 const int64_t kCaptureTimeMs = fake_clock_.TimeInMilliseconds(); |
993 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; | 992 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; |
994 EXPECT_EQ(0, rtp_sender_->RegisterPayload(payload_name, kPayloadType, 90000, | 993 EXPECT_EQ(0, rtp_sender_->RegisterPayload(payload_name, kPayloadType, 90000, |
995 0, 1500)); | 994 0, 1500)); |
996 RTPVideoHeader video_header; | 995 RTPVideoHeader video_header; |
997 memset(&video_header, 0, sizeof(RTPVideoHeader)); | 996 memset(&video_header, 0, sizeof(RTPVideoHeader)); |
998 video_header.video_timing.flags = TimingFrameFlags::kTriggeredByTimer; | 997 video_header.video_timing.is_timing_frame = true; |
999 EXPECT_TRUE(rtp_sender_->SendOutgoingData( | 998 EXPECT_TRUE(rtp_sender_->SendOutgoingData( |
1000 kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs, kPayloadData, | 999 kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs, kPayloadData, |
1001 sizeof(kPayloadData), nullptr, &video_header, nullptr)); | 1000 sizeof(kPayloadData), nullptr, &video_header, nullptr)); |
1002 | 1001 |
1003 EXPECT_CALL(mock_rtc_event_log_, | 1002 EXPECT_CALL(mock_rtc_event_log_, |
1004 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) | 1003 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) |
1005 .Times(1); | 1004 .Times(1); |
1006 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum, | 1005 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum, |
1007 fake_clock_.TimeInMilliseconds(), | 1006 fake_clock_.TimeInMilliseconds(), |
1008 false, PacedPacketInfo())); | 1007 false, PacedPacketInfo())); |
1009 ASSERT_EQ(1, transport_.packets_sent()); | 1008 ASSERT_EQ(1, transport_.packets_sent()); |
1010 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; | 1009 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; |
1011 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); | 1010 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); |
1012 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber()); | 1011 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber()); |
1013 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); | 1012 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); |
1014 | 1013 |
1015 // Now try to send not a timing frame. | 1014 // Now try to send not a timing frame. |
1016 uint16_t flexfec_seq_num; | 1015 uint16_t flexfec_seq_num; |
1017 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority, | 1016 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority, |
1018 kFlexfecSsrc, _, _, _, false)) | 1017 kFlexfecSsrc, _, _, _, false)) |
1019 .WillOnce(testing::SaveArg<2>(&flexfec_seq_num)); | 1018 .WillOnce(testing::SaveArg<2>(&flexfec_seq_num)); |
1020 EXPECT_CALL(mock_paced_sender_, | 1019 EXPECT_CALL(mock_paced_sender_, |
1021 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc, | 1020 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc, |
1022 kSeqNum + 1, _, _, false)); | 1021 kSeqNum + 1, _, _, false)); |
1023 video_header.video_timing.flags = TimingFrameFlags::kInvalid; | 1022 video_header.video_timing.is_timing_frame = false; |
1024 EXPECT_TRUE(rtp_sender_->SendOutgoingData( | 1023 EXPECT_TRUE(rtp_sender_->SendOutgoingData( |
1025 kVideoFrameKey, kPayloadType, kTimestamp + 1, kCaptureTimeMs + 1, | 1024 kVideoFrameKey, kPayloadType, kTimestamp + 1, kCaptureTimeMs + 1, |
1026 kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr)); | 1025 kPayloadData, sizeof(kPayloadData), nullptr, &video_header, nullptr)); |
1027 | 1026 |
1028 EXPECT_CALL(mock_rtc_event_log_, | 1027 EXPECT_CALL(mock_rtc_event_log_, |
1029 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) | 1028 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) |
1030 .Times(2); | 1029 .Times(2); |
1031 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum + 1, | 1030 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum + 1, |
1032 fake_clock_.TimeInMilliseconds(), | 1031 fake_clock_.TimeInMilliseconds(), |
1033 false, PacedPacketInfo())); | 1032 false, PacedPacketInfo())); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 uint8_t kFrame[kMaxPacketLength]; | 1564 uint8_t kFrame[kMaxPacketLength]; |
1566 const int64_t kPacketizationTimeMs = 100; | 1565 const int64_t kPacketizationTimeMs = 100; |
1567 const int64_t kEncodeStartDeltaMs = 10; | 1566 const int64_t kEncodeStartDeltaMs = 10; |
1568 const int64_t kEncodeFinishDeltaMs = 50; | 1567 const int64_t kEncodeFinishDeltaMs = 50; |
1569 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 1568 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
1570 kRtpExtensionVideoTiming, kVideoTimingExtensionId)); | 1569 kRtpExtensionVideoTiming, kVideoTimingExtensionId)); |
1571 | 1570 |
1572 const int64_t kCaptureTimestamp = fake_clock_.TimeInMilliseconds(); | 1571 const int64_t kCaptureTimestamp = fake_clock_.TimeInMilliseconds(); |
1573 | 1572 |
1574 RTPVideoHeader hdr = {0}; | 1573 RTPVideoHeader hdr = {0}; |
1575 hdr.video_timing.flags = TimingFrameFlags::kTriggeredByTimer; | 1574 hdr.video_timing.is_timing_frame = true; |
1576 hdr.video_timing.encode_start_delta_ms = kEncodeStartDeltaMs; | 1575 hdr.video_timing.encode_start_delta_ms = kEncodeStartDeltaMs; |
1577 hdr.video_timing.encode_finish_delta_ms = kEncodeFinishDeltaMs; | 1576 hdr.video_timing.encode_finish_delta_ms = kEncodeFinishDeltaMs; |
1578 | 1577 |
1579 fake_clock_.AdvanceTimeMilliseconds(kPacketizationTimeMs); | 1578 fake_clock_.AdvanceTimeMilliseconds(kPacketizationTimeMs); |
1580 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, | 1579 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, |
1581 kTimestamp, kCaptureTimestamp, kFrame, | 1580 kTimestamp, kCaptureTimestamp, kFrame, |
1582 sizeof(kFrame), nullptr, &hdr); | 1581 sizeof(kFrame), nullptr, &hdr); |
1583 VideoSendTiming timing; | 1582 VideoSendTiming timing; |
1584 EXPECT_TRUE(transport_.last_sent_packet().GetExtension<VideoTimingExtension>( | 1583 EXPECT_TRUE(transport_.last_sent_packet().GetExtension<VideoTimingExtension>( |
1585 &timing)); | 1584 &timing)); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, | 1752 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, |
1754 RtpSenderTestWithoutPacer, | 1753 RtpSenderTestWithoutPacer, |
1755 ::testing::Bool()); | 1754 ::testing::Bool()); |
1756 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, | 1755 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, |
1757 RtpSenderVideoTest, | 1756 RtpSenderVideoTest, |
1758 ::testing::Bool()); | 1757 ::testing::Bool()); |
1759 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, | 1758 INSTANTIATE_TEST_CASE_P(WithAndWithoutOverhead, |
1760 RtpSenderAudioTest, | 1759 RtpSenderAudioTest, |
1761 ::testing::Bool()); | 1760 ::testing::Bool()); |
1762 } // namespace webrtc | 1761 } // namespace webrtc |
OLD | NEW |