Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc

Issue 1376673004: Add a PacketOptions struct to webrtc::Transport. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment added Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 public: 71 public:
72 LoopbackTransportTest() 72 LoopbackTransportTest()
73 : packets_sent_(0), 73 : packets_sent_(0),
74 last_sent_packet_len_(0), 74 last_sent_packet_len_(0),
75 total_bytes_sent_(0), 75 total_bytes_sent_(0),
76 last_sent_packet_(nullptr) {} 76 last_sent_packet_(nullptr) {}
77 77
78 ~LoopbackTransportTest() { 78 ~LoopbackTransportTest() {
79 STLDeleteContainerPointers(sent_packets_.begin(), sent_packets_.end()); 79 STLDeleteContainerPointers(sent_packets_.begin(), sent_packets_.end());
80 } 80 }
81 bool SendRtp(const uint8_t *data, size_t len) override { 81 bool SendRtp(const uint8_t* data,
82 size_t len,
83 const PacketOptions& options) override {
82 packets_sent_++; 84 packets_sent_++;
83 rtc::Buffer* buffer = 85 rtc::Buffer* buffer =
84 new rtc::Buffer(reinterpret_cast<const uint8_t*>(data), len); 86 new rtc::Buffer(reinterpret_cast<const uint8_t*>(data), len);
85 last_sent_packet_ = buffer->data(); 87 last_sent_packet_ = buffer->data();
86 last_sent_packet_len_ = len; 88 last_sent_packet_len_ = len;
87 total_bytes_sent_ += len; 89 total_bytes_sent_ += len;
88 sent_packets_.push_back(buffer); 90 sent_packets_.push_back(buffer);
89 return true; 91 return true;
90 } 92 }
91 bool SendRtcp(const uint8_t* data, size_t len) override { 93 bool SendRtcp(const uint8_t* data, size_t len) override {
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 kTransmissionTimeOffsetExtensionId); 859 kTransmissionTimeOffsetExtensionId);
858 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, 860 rtp_parser->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
859 kAbsoluteSendTimeExtensionId); 861 kAbsoluteSendTimeExtensionId);
860 rtp_sender_->SetTargetBitrate(300000); 862 rtp_sender_->SetTargetBitrate(300000);
861 const size_t kNumPayloadSizes = 10; 863 const size_t kNumPayloadSizes = 10;
862 const size_t kPayloadSizes[kNumPayloadSizes] = {500, 550, 600, 650, 700, 750, 864 const size_t kPayloadSizes[kNumPayloadSizes] = {500, 550, 600, 650, 700, 750,
863 800, 850, 900, 950}; 865 800, 850, 900, 950};
864 // Send 10 packets of increasing size. 866 // Send 10 packets of increasing size.
865 for (size_t i = 0; i < kNumPayloadSizes; ++i) { 867 for (size_t i = 0; i < kNumPayloadSizes; ++i) {
866 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); 868 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
867 EXPECT_CALL(transport, SendRtp(_, _)).WillOnce(testing::Return(true)); 869 EXPECT_CALL(transport, SendRtp(_, _, _)).WillOnce(testing::Return(true));
868 SendPacket(capture_time_ms, kPayloadSizes[i]); 870 SendPacket(capture_time_ms, kPayloadSizes[i]);
869 rtp_sender_->TimeToSendPacket(seq_num++, capture_time_ms, false); 871 rtp_sender_->TimeToSendPacket(seq_num++, capture_time_ms, false);
870 fake_clock_.AdvanceTimeMilliseconds(33); 872 fake_clock_.AdvanceTimeMilliseconds(33);
871 } 873 }
872 // The amount of padding to send it too small to send a payload packet. 874 // The amount of padding to send it too small to send a payload packet.
873 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len)) 875 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _))
874 .WillOnce(testing::Return(true)); 876 .WillOnce(testing::Return(true));
875 EXPECT_EQ(kMaxPaddingSize, rtp_sender_->TimeToSendPadding(49)); 877 EXPECT_EQ(kMaxPaddingSize, rtp_sender_->TimeToSendPadding(49));
876 878
877 EXPECT_CALL(transport, 879 EXPECT_CALL(transport,
878 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize)) 880 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _))
879 .WillOnce(testing::Return(true)); 881 .WillOnce(testing::Return(true));
880 EXPECT_EQ(kPayloadSizes[0], rtp_sender_->TimeToSendPadding(500)); 882 EXPECT_EQ(kPayloadSizes[0], rtp_sender_->TimeToSendPadding(500));
881 883
882 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] + 884 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] +
883 rtp_header_len + kRtxHeaderSize)) 885 rtp_header_len + kRtxHeaderSize,
886 _))
884 .WillOnce(testing::Return(true)); 887 .WillOnce(testing::Return(true));
885 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len)) 888 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _))
886 .WillOnce(testing::Return(true)); 889 .WillOnce(testing::Return(true));
887 EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, 890 EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize,
888 rtp_sender_->TimeToSendPadding(999)); 891 rtp_sender_->TimeToSendPadding(999));
889 } 892 }
890 893
891 TEST_F(RtpSenderTest, SendGenericVideo) { 894 TEST_F(RtpSenderTest, SendGenericVideo) {
892 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; 895 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC";
893 const uint8_t payload_type = 127; 896 const uint8_t payload_type = 127;
894 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, 897 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000,
895 0, 1500)); 898 0, 1500));
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), 1405 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()),
1403 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); 1406 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation);
1404 1407
1405 // Verify that this packet does have CVO byte. 1408 // Verify that this packet does have CVO byte.
1406 VerifyCVOPacket( 1409 VerifyCVOPacket(
1407 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), 1410 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()),
1408 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, 1411 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1,
1409 hdr.rotation); 1412 hdr.rotation);
1410 } 1413 }
1411 } // namespace webrtc 1414 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/modules/rtp_rtcp/test/testAPI/test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698