2012-01-10 14:09:18 +00:00
|
|
|
/*
|
2012-05-11 11:08:54 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2012-01-10 14:09:18 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2015-12-09 03:32:40 -08:00
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
|
2012-01-10 14:09:18 +00:00
|
|
|
|
2016-09-28 17:42:01 -07:00
|
|
|
#include "webrtc/test/gtest.h"
|
2013-03-15 23:21:52 +00:00
|
|
|
#include "webrtc/common_types.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2015-09-28 09:59:31 -07:00
|
|
|
#include "webrtc/transport.h"
|
2012-01-10 14:09:18 +00:00
|
|
|
|
2012-01-10 15:33:40 +00:00
|
|
|
namespace webrtc {
|
2012-01-10 14:09:18 +00:00
|
|
|
|
|
|
|
|
// This class sends all its packet straight to the provided RtpRtcp module.
|
|
|
|
|
// with optional packet loss.
|
2015-09-28 09:59:31 -07:00
|
|
|
class LoopBackTransport : public Transport {
|
2012-01-10 14:09:18 +00:00
|
|
|
public:
|
2012-05-11 11:08:54 +00:00
|
|
|
LoopBackTransport()
|
2015-01-20 05:42:52 +00:00
|
|
|
: count_(0),
|
|
|
|
|
packet_loss_(0),
|
|
|
|
|
rtp_payload_registry_(NULL),
|
|
|
|
|
rtp_receiver_(NULL),
|
|
|
|
|
rtp_rtcp_module_(NULL) {}
|
|
|
|
|
void SetSendModule(RtpRtcp* rtp_rtcp_module,
|
2013-08-15 23:38:54 +00:00
|
|
|
RTPPayloadRegistry* payload_registry,
|
|
|
|
|
RtpReceiver* receiver,
|
2015-01-20 05:42:52 +00:00
|
|
|
ReceiveStatistics* receive_statistics);
|
|
|
|
|
void DropEveryNthPacket(int n);
|
2015-10-02 03:39:33 -07:00
|
|
|
bool SendRtp(const uint8_t* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const PacketOptions& options) override;
|
2015-09-28 09:59:31 -07:00
|
|
|
bool SendRtcp(const uint8_t* data, size_t len) override;
|
2015-01-20 05:42:52 +00:00
|
|
|
|
2012-01-10 14:09:18 +00:00
|
|
|
private:
|
2015-01-20 05:42:52 +00:00
|
|
|
int count_;
|
|
|
|
|
int packet_loss_;
|
2013-08-15 23:38:54 +00:00
|
|
|
ReceiveStatistics* receive_statistics_;
|
|
|
|
|
RTPPayloadRegistry* rtp_payload_registry_;
|
|
|
|
|
RtpReceiver* rtp_receiver_;
|
2015-01-20 05:42:52 +00:00
|
|
|
RtpRtcp* rtp_rtcp_module_;
|
2012-01-10 14:09:18 +00:00
|
|
|
};
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
class TestRtpReceiver : public NullRtpData {
|
2012-01-10 14:09:18 +00:00
|
|
|
public:
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t OnReceivedPayloadData(
|
2015-01-20 05:42:52 +00:00
|
|
|
const uint8_t* payload_data,
|
2016-06-14 12:52:54 +02:00
|
|
|
size_t payload_size,
|
2015-03-04 12:58:35 +00:00
|
|
|
const webrtc::WebRtcRTPHeader* rtp_header) override;
|
2012-12-03 14:01:46 +00:00
|
|
|
|
2015-01-20 05:42:52 +00:00
|
|
|
const uint8_t* payload_data() const { return payload_data_; }
|
|
|
|
|
size_t payload_size() const { return payload_size_; }
|
|
|
|
|
webrtc::WebRtcRTPHeader rtp_header() const { return rtp_header_; }
|
2012-12-03 14:01:46 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-01-20 05:42:52 +00:00
|
|
|
uint8_t payload_data_[1500];
|
|
|
|
|
size_t payload_size_;
|
|
|
|
|
webrtc::WebRtcRTPHeader rtp_header_;
|
2012-01-10 14:09:18 +00:00
|
|
|
};
|
|
|
|
|
|
2012-01-10 15:33:40 +00:00
|
|
|
} // namespace webrtc
|
2015-12-09 03:32:40 -08:00
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_TEST_TESTAPI_TEST_API_H_
|