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 "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" | 11 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
| 17 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/rate_limiter.h" | 18 #include "webrtc/base/rate_limiter.h" |
18 #include "webrtc/test/null_transport.h" | 19 #include "webrtc/test/null_transport.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, | 23 void LoopBackTransport::SetSendModule(RtpRtcp* rtp_rtcp_module, |
23 RTPPayloadRegistry* payload_registry, | 24 RTPPayloadRegistry* payload_registry, |
24 RtpReceiver* receiver, | 25 RtpReceiver* receiver, |
25 ReceiveStatistics* receive_statistics) { | 26 ReceiveStatistics* receive_statistics) { |
26 rtp_rtcp_module_ = rtp_rtcp_module; | 27 rtp_rtcp_module_ = rtp_rtcp_module; |
(...skipping 10 matching lines...) Expand all Loading... |
37 size_t len, | 38 size_t len, |
38 const PacketOptions& options) { | 39 const PacketOptions& options) { |
39 count_++; | 40 count_++; |
40 if (packet_loss_ > 0) { | 41 if (packet_loss_ > 0) { |
41 if ((count_ % packet_loss_) == 0) { | 42 if ((count_ % packet_loss_) == 0) { |
42 return true; | 43 return true; |
43 } | 44 } |
44 } | 45 } |
45 RTPHeader header; | 46 RTPHeader header; |
46 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 47 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
47 if (!parser->Parse(static_cast<const uint8_t*>(data), len, &header)) { | 48 if (!parser->Parse(data, len, &header)) { |
48 return false; | 49 return false; |
49 } | 50 } |
50 PayloadUnion payload_specific; | 51 PayloadUnion payload_specific; |
51 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, | 52 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, |
52 &payload_specific)) { | 53 &payload_specific)) { |
53 return false; | 54 return false; |
54 } | 55 } |
| 56 const uint8_t* payload = data + header.headerLength; |
| 57 RTC_CHECK_GE(len, header.headerLength); |
| 58 const size_t payload_length = len - header.headerLength; |
55 receive_statistics_->IncomingPacket(header, len, false); | 59 receive_statistics_->IncomingPacket(header, len, false); |
56 if (!rtp_receiver_->IncomingRtpPacket(header, | 60 if (!rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, |
57 static_cast<const uint8_t*>(data), len, | |
58 payload_specific, true)) { | 61 payload_specific, true)) { |
59 return false; | 62 return false; |
60 } | 63 } |
61 return true; | 64 return true; |
62 } | 65 } |
63 | 66 |
64 bool LoopBackTransport::SendRtcp(const uint8_t* data, size_t len) { | 67 bool LoopBackTransport::SendRtcp(const uint8_t* data, size_t len) { |
65 if (rtp_rtcp_module_->IncomingRtcpPacket((const uint8_t*)data, len) < 0) { | 68 if (rtp_rtcp_module_->IncomingRtcpPacket((const uint8_t*)data, len) < 0) { |
66 return false; | 69 return false; |
67 } | 70 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 rtx_header.payloadType = kRtxPayloadType; | 185 rtx_header.payloadType = kRtxPayloadType; |
183 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 186 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
184 rtx_header.ssrc = 0; | 187 rtx_header.ssrc = 0; |
185 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); | 188 EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header)); |
186 rtx_header.ssrc = kRtxSsrc; | 189 rtx_header.ssrc = kRtxSsrc; |
187 rtx_header.payloadType = 0; | 190 rtx_header.payloadType = 0; |
188 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); | 191 EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header)); |
189 } | 192 } |
190 | 193 |
191 } // namespace webrtc | 194 } // namespace webrtc |
OLD | NEW |