pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | 2853dde | 2012-05-11 11:08:54 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_ |
| 11 | #define MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_ |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/call/transport.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 14 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "modules/rtp_rtcp/include/receive_statistics.h" |
| 16 | #include "modules/rtp_rtcp/include/rtp_header_parser.h" |
| 17 | #include "modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 18 | #include "modules/rtp_rtcp/include/rtp_receiver.h" |
| 19 | #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
| 20 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 21 | #include "test/gtest.h" |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 22 | |
pwestin@webrtc.org | a178359 | 2012-01-10 15:33:40 +0000 | [diff] [blame] | 23 | namespace webrtc { |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 24 | |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 25 | // This class sends all its packet straight to the provided RtpRtcp module. |
| 26 | // with optional packet loss. |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 27 | class LoopBackTransport : public Transport { |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 28 | public: |
pwestin@webrtc.org | 2853dde | 2012-05-11 11:08:54 +0000 | [diff] [blame] | 29 | LoopBackTransport() |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 30 | : count_(0), |
| 31 | packet_loss_(0), |
| 32 | rtp_payload_registry_(NULL), |
| 33 | rtp_receiver_(NULL), |
| 34 | rtp_rtcp_module_(NULL) {} |
| 35 | void SetSendModule(RtpRtcp* rtp_rtcp_module, |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 36 | RTPPayloadRegistry* payload_registry, |
| 37 | RtpReceiver* receiver, |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 38 | ReceiveStatistics* receive_statistics); |
| 39 | void DropEveryNthPacket(int n); |
stefan | 1d8a506 | 2015-10-02 03:39:33 -0700 | [diff] [blame] | 40 | bool SendRtp(const uint8_t* data, |
| 41 | size_t len, |
| 42 | const PacketOptions& options) override; |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 43 | bool SendRtcp(const uint8_t* data, size_t len) override; |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 44 | |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 45 | private: |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 46 | int count_; |
| 47 | int packet_loss_; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 48 | ReceiveStatistics* receive_statistics_; |
| 49 | RTPPayloadRegistry* rtp_payload_registry_; |
| 50 | RtpReceiver* rtp_receiver_; |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 51 | RtpRtcp* rtp_rtcp_module_; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
nisse | 7fcdb6d | 2017-06-01 00:30:55 -0700 | [diff] [blame] | 54 | class TestRtpReceiver : public RtpData { |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 55 | public: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 56 | int32_t OnReceivedPayloadData( |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 57 | const uint8_t* payload_data, |
Peter Boström | 0208322 | 2016-06-14 12:52:54 +0200 | [diff] [blame] | 58 | size_t payload_size, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 59 | const webrtc::WebRtcRTPHeader* rtp_header) override; |
stefan@webrtc.org | 8d0cd07 | 2012-12-03 14:01:46 +0000 | [diff] [blame] | 60 | |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 61 | const uint8_t* payload_data() const { return payload_data_; } |
| 62 | size_t payload_size() const { return payload_size_; } |
| 63 | webrtc::WebRtcRTPHeader rtp_header() const { return rtp_header_; } |
stefan@webrtc.org | 8d0cd07 | 2012-12-03 14:01:46 +0000 | [diff] [blame] | 64 | |
| 65 | private: |
changbin.shao@intel.com | 9691b36 | 2015-01-20 05:42:52 +0000 | [diff] [blame] | 66 | uint8_t payload_data_[1500]; |
| 67 | size_t payload_size_; |
| 68 | webrtc::WebRtcRTPHeader rtp_header_; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
pwestin@webrtc.org | a178359 | 2012-01-10 15:33:40 +0000 | [diff] [blame] | 71 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 72 | #endif // MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_ |