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