| 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 "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webrtc/base/scoped_ptr.h" | 12 #include "webrtc/base/scoped_ptr.h" |
| 13 #include "webrtc/common_types.h" | 13 #include "webrtc/common_types.h" |
| 14 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" | 14 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
| 15 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" | 15 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" |
| 16 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" | 16 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" |
| 17 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" | 17 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" |
| 18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" | 18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
| 19 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" | 19 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 20 #include "webrtc/transport.h" |
| 20 | 21 |
| 21 namespace webrtc { | 22 namespace webrtc { |
| 22 | 23 |
| 23 // This class sends all its packet straight to the provided RtpRtcp module. | 24 // This class sends all its packet straight to the provided RtpRtcp module. |
| 24 // with optional packet loss. | 25 // with optional packet loss. |
| 25 class LoopBackTransport : public webrtc::Transport { | 26 class LoopBackTransport : public Transport { |
| 26 public: | 27 public: |
| 27 LoopBackTransport() | 28 LoopBackTransport() |
| 28 : count_(0), | 29 : count_(0), |
| 29 packet_loss_(0), | 30 packet_loss_(0), |
| 30 rtp_payload_registry_(NULL), | 31 rtp_payload_registry_(NULL), |
| 31 rtp_receiver_(NULL), | 32 rtp_receiver_(NULL), |
| 32 rtp_rtcp_module_(NULL) {} | 33 rtp_rtcp_module_(NULL) {} |
| 33 void SetSendModule(RtpRtcp* rtp_rtcp_module, | 34 void SetSendModule(RtpRtcp* rtp_rtcp_module, |
| 34 RTPPayloadRegistry* payload_registry, | 35 RTPPayloadRegistry* payload_registry, |
| 35 RtpReceiver* receiver, | 36 RtpReceiver* receiver, |
| 36 ReceiveStatistics* receive_statistics); | 37 ReceiveStatistics* receive_statistics); |
| 37 void DropEveryNthPacket(int n); | 38 void DropEveryNthPacket(int n); |
| 38 int SendPacket(const void* data, size_t len) override; | 39 bool SendRtp(const uint8_t* data, size_t len) override; |
| 39 int SendRTCPPacket(const void* data, size_t len) override; | 40 bool SendRtcp(const uint8_t* data, size_t len) override; |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 int count_; | 43 int count_; |
| 43 int packet_loss_; | 44 int packet_loss_; |
| 44 ReceiveStatistics* receive_statistics_; | 45 ReceiveStatistics* receive_statistics_; |
| 45 RTPPayloadRegistry* rtp_payload_registry_; | 46 RTPPayloadRegistry* rtp_payload_registry_; |
| 46 RtpReceiver* rtp_receiver_; | 47 RtpReceiver* rtp_receiver_; |
| 47 RtpRtcp* rtp_rtcp_module_; | 48 RtpRtcp* rtp_rtcp_module_; |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 class TestRtpReceiver : public NullRtpData { | 51 class TestRtpReceiver : public NullRtpData { |
| 51 public: | 52 public: |
| 52 int32_t OnReceivedPayloadData( | 53 int32_t OnReceivedPayloadData( |
| 53 const uint8_t* payload_data, | 54 const uint8_t* payload_data, |
| 54 const size_t payload_size, | 55 const size_t payload_size, |
| 55 const webrtc::WebRtcRTPHeader* rtp_header) override; | 56 const webrtc::WebRtcRTPHeader* rtp_header) override; |
| 56 | 57 |
| 57 const uint8_t* payload_data() const { return payload_data_; } | 58 const uint8_t* payload_data() const { return payload_data_; } |
| 58 size_t payload_size() const { return payload_size_; } | 59 size_t payload_size() const { return payload_size_; } |
| 59 webrtc::WebRtcRTPHeader rtp_header() const { return rtp_header_; } | 60 webrtc::WebRtcRTPHeader rtp_header() const { return rtp_header_; } |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 uint8_t payload_data_[1500]; | 63 uint8_t payload_data_[1500]; |
| 63 size_t payload_size_; | 64 size_t payload_size_; |
| 64 webrtc::WebRtcRTPHeader rtp_header_; | 65 webrtc::WebRtcRTPHeader rtp_header_; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace webrtc | 68 } // namespace webrtc |
| OLD | NEW |