2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_
12 #define WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_
14 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
15 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
16 #include "webrtc/test/channel_transport/udp_transport.h"
17 #include "webrtc/typedefs.h"
19 class TestLoadGenerator;
21 class CriticalSectionWrapper;
26 using namespace webrtc;
28 #define MAX_BITRATE_KBPS 50000
34 virtual void OnOnNetworkChanged(const uint32_t bitrateTarget,
35 const uint8_t fractionLost,
36 const uint16_t roundTripTimeMs,
37 const uint16_t bwEstimateKbitMin,
38 const uint16_t bwEstimateKbitMax) = 0;
40 virtual ~SendRecCB() {};
44 class TestSenderReceiver : public RtpFeedback, public RtpData, public UdpTransportData, public RtpVideoFeedback
48 TestSenderReceiver (void);
50 ~TestSenderReceiver (void);
52 void SetCallback (SendRecCB *cb) { _sendRecCB = cb; };
60 /////////////////////////////////////////////
63 int32_t InitReceiver (const uint16_t rtpPort,
64 const uint16_t rtcpPort = 0,
65 const int8_t payloadType = 127);
67 int32_t ReceiveBitrateKbps ();
69 int32_t SetPacketTimeout(const uint32_t timeoutMS);
71 bool timeOutTriggered () { return (_timeOut); };
73 // Inherited from RtpFeedback
74 virtual int32_t OnInitializeDecoder(
76 const int8_t payloadType,
77 const int8_t payloadName[RTP_PAYLOAD_NAME_SIZE],
78 const uint32_t frequency,
79 const uint8_t channels,
80 const uint32_t rate) OVERRIDE {
84 virtual void OnPacketTimeout(const int32_t id);
86 virtual void OnReceivedPacket(const int32_t id,
87 const RtpRtcpPacketType packetType);
89 virtual void OnPeriodicDeadOrAlive(const int32_t id,
90 const RTPAliveType alive) {};
92 virtual void OnIncomingSSRCChanged(const int32_t id,
93 const uint32_t SSRC) OVERRIDE {}
95 virtual void OnIncomingCSRCChanged(const int32_t id,
97 const bool added) OVERRIDE {}
100 // Inherited from RtpData
101 virtual int32_t OnReceivedPayloadData(
102 const uint8_t* payloadData,
103 const uint16_t payloadSize,
104 const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE;
107 // Inherited from UdpTransportData
108 virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket,
109 const int32_t rtpPacketLength,
110 const int8_t* fromIP,
111 const uint16_t fromPort) OVERRIDE;
113 virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
114 const int32_t rtcpPacketLength,
115 const int8_t* fromIP,
116 const uint16_t fromPort) OVERRIDE;
120 /////////////////////////////////
123 int32_t InitSender (const uint32_t startBitrateKbps,
124 const int8_t* ipAddr,
125 const uint16_t rtpPort,
126 const uint16_t rtcpPort = 0,
127 const int8_t payloadType = 127);
129 int32_t SendOutgoingData(const uint32_t timeStamp,
130 const uint8_t* payloadData,
131 const uint32_t payloadSize,
132 const webrtc::FrameType frameType = webrtc::kVideoFrameDelta);
134 int32_t SetLoadGenerator(TestLoadGenerator *generator);
136 uint32_t BitrateSent() { return (_rtp->BitrateSent()); };
139 // Inherited from RtpVideoFeedback
140 virtual void OnReceivedIntraFrameRequest(const int32_t id,
141 const uint8_t message = 0) {};
143 virtual void OnNetworkChanged(const int32_t id,
144 const uint32_t minBitrateBps,
145 const uint32_t maxBitrateBps,
146 const uint8_t fractionLost,
147 const uint16_t roundTripTimeMs,
148 const uint16_t bwEstimateKbitMin,
149 const uint16_t bwEstimateKbitMax);
153 UdpTransport* _transport;
154 webrtc::CriticalSectionWrapper* _critSect;
155 webrtc::EventWrapper *_eventPtr;
156 webrtc::ThreadWrapper* _procThread;
159 TestLoadGenerator* _loadGenerator;
163 SendRecCB * _sendRecCB;
164 uint32_t _lastBytesReceived;
169 #endif // WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_