blob: 240a4279aa6768e5819459898b8e0d50a490c76e [file] [log] [blame]
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +00001/*
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
11#define MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "api/call/transport.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020014#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#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.org8281e7d2012-01-10 14:09:18 +000022
pwestin@webrtc.orga1783592012-01-10 15:33:40 +000023namespace webrtc {
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000024
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000025// This class sends all its packet straight to the provided RtpRtcp module.
26// with optional packet loss.
pbos2d566682015-09-28 09:59:31 -070027class LoopBackTransport : public Transport {
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000028 public:
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000029 LoopBackTransport()
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000030 : 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.org822fbd82013-08-15 23:38:54 +000036 RTPPayloadRegistry* payload_registry,
37 RtpReceiver* receiver,
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000038 ReceiveStatistics* receive_statistics);
39 void DropEveryNthPacket(int n);
stefan1d8a5062015-10-02 03:39:33 -070040 bool SendRtp(const uint8_t* data,
41 size_t len,
42 const PacketOptions& options) override;
pbos2d566682015-09-28 09:59:31 -070043 bool SendRtcp(const uint8_t* data, size_t len) override;
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000044
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000045 private:
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000046 int count_;
47 int packet_loss_;
wu@webrtc.org822fbd82013-08-15 23:38:54 +000048 ReceiveStatistics* receive_statistics_;
49 RTPPayloadRegistry* rtp_payload_registry_;
50 RtpReceiver* rtp_receiver_;
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000051 RtpRtcp* rtp_rtcp_module_;
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000052};
53
nisse7fcdb6d2017-06-01 00:30:55 -070054class TestRtpReceiver : public RtpData {
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000055 public:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000056 int32_t OnReceivedPayloadData(
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000057 const uint8_t* payload_data,
Peter Boström02083222016-06-14 12:52:54 +020058 size_t payload_size,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000059 const webrtc::WebRtcRTPHeader* rtp_header) override;
stefan@webrtc.org8d0cd072012-12-03 14:01:46 +000060
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000061 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.org8d0cd072012-12-03 14:01:46 +000064
65 private:
changbin.shao@intel.com9691b362015-01-20 05:42:52 +000066 uint8_t payload_data_[1500];
67 size_t payload_size_;
68 webrtc::WebRtcRTPHeader rtp_header_;
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +000069};
70
pwestin@webrtc.orga1783592012-01-10 15:33:40 +000071} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020072#endif // MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_