OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
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 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_ | |
12 #define WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_ | |
13 | |
14 #include "webrtc/base/platform_thread.h" | |
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | |
16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | |
17 #include "webrtc/test/channel_transport/udp_transport.h" | |
18 #include "webrtc/typedefs.h" | |
19 | |
20 class TestLoadGenerator; | |
21 namespace webrtc { | |
22 class CriticalSectionWrapper; | |
23 class EventWrapper; | |
24 | |
25 #define MAX_BITRATE_KBPS 50000 | |
26 | |
27 | |
28 class SendRecCB | |
29 { | |
30 public: | |
31 virtual void OnOnNetworkChanged(const uint32_t bitrateTarget, | |
32 const uint8_t fractionLost, | |
33 const uint16_t roundTripTimeMs, | |
34 const uint16_t bwEstimateKbitMin, | |
35 const uint16_t bwEstimateKbitMax) = 0; | |
36 | |
37 virtual ~SendRecCB() {}; | |
38 }; | |
39 | |
40 | |
41 class TestSenderReceiver : public RtpFeedback, public RtpData, public UdpTranspo
rtData, public RtpVideoFeedback | |
42 { | |
43 | |
44 public: | |
45 TestSenderReceiver (void); | |
46 | |
47 ~TestSenderReceiver (void); | |
48 | |
49 void SetCallback (SendRecCB *cb) { _sendRecCB = cb; }; | |
50 | |
51 int32_t Start(); | |
52 | |
53 int32_t Stop(); | |
54 | |
55 bool ProcLoop(); | |
56 | |
57 ///////////////////////////////////////////// | |
58 // Receiver methods | |
59 | |
60 int32_t InitReceiver (const uint16_t rtpPort, | |
61 const uint16_t rtcpPort = 0, | |
62 const int8_t payloadType = 127); | |
63 | |
64 int32_t ReceiveBitrateKbps (); | |
65 | |
66 int32_t SetPacketTimeout(const uint32_t timeoutMS); | |
67 | |
68 // Inherited from RtpFeedback | |
69 int32_t OnInitializeDecoder(const int32_t id, | |
70 const int8_t payloadType, | |
71 const int8_t payloadName[RTP_PAYLOAD_NAME_SIZE], | |
72 const uint32_t frequency, | |
73 const uint8_t channels, | |
74 const uint32_t rate) override { | |
75 return 0; | |
76 } | |
77 | |
78 void OnIncomingSSRCChanged(const int32_t id, const uint32_t SSRC) override { | |
79 } | |
80 | |
81 void OnIncomingCSRCChanged(const int32_t id, | |
82 const uint32_t CSRC, | |
83 const bool added) override {} | |
84 | |
85 // Inherited from RtpData | |
86 int32_t OnReceivedPayloadData( | |
87 const uint8_t* payloadData, | |
88 const size_t payloadSize, | |
89 const webrtc::WebRtcRTPHeader* rtpHeader) override; | |
90 | |
91 // Inherited from UdpTransportData | |
92 void IncomingRTPPacket(const int8_t* incomingRtpPacket, | |
93 const size_t rtpPacketLength, | |
94 const int8_t* fromIP, | |
95 const uint16_t fromPort) override; | |
96 | |
97 void IncomingRTCPPacket(const int8_t* incomingRtcpPacket, | |
98 const size_t rtcpPacketLength, | |
99 const int8_t* fromIP, | |
100 const uint16_t fromPort) override; | |
101 | |
102 ///////////////////////////////// | |
103 // Sender methods | |
104 | |
105 int32_t InitSender (const uint32_t startBitrateKbps, | |
106 const int8_t* ipAddr, | |
107 const uint16_t rtpPort, | |
108 const uint16_t rtcpPort = 0, | |
109 const int8_t payloadType = 127); | |
110 | |
111 int32_t SendOutgoingData(const uint32_t timeStamp, | |
112 const uint8_t* payloadData, | |
113 const size_t payloadSize, | |
114 const webrtc::FrameType frameType = webrtc::kVideoFrameDelta); | |
115 | |
116 int32_t SetLoadGenerator(TestLoadGenerator *generator); | |
117 | |
118 uint32_t BitrateSent() { return (_rtp->BitrateSent()); }; | |
119 | |
120 | |
121 // Inherited from RtpVideoFeedback | |
122 virtual void OnReceivedIntraFrameRequest(const int32_t id, | |
123 const uint8_t message = 0) {}; | |
124 | |
125 virtual void OnNetworkChanged(const int32_t id, | |
126 const uint32_t minBitrateBps, | |
127 const uint32_t maxBitrateBps, | |
128 const uint8_t fractionLost, | |
129 const uint16_t roundTripTimeMs, | |
130 const uint16_t bwEstimateKbitMin, | |
131 const uint16_t bwEstimateKbitMax); | |
132 | |
133 private: | |
134 RtpRtcp* _rtp; | |
135 UdpTransport* _transport; | |
136 webrtc::CriticalSectionWrapper* _critSect; | |
137 webrtc::EventWrapper *_eventPtr; | |
138 rtc::PlatformThread _procThread; | |
139 bool _running; | |
140 int8_t _payloadType; | |
141 TestLoadGenerator* _loadGenerator; | |
142 bool _isSender; | |
143 bool _isReceiver; | |
144 SendRecCB * _sendRecCB; | |
145 size_t _lastBytesReceived; | |
146 int64_t _lastTime; | |
147 | |
148 }; | |
149 } // namespace webrtc | |
150 #endif // WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTSENDERRECEIVER_H_ | |
OLD | NEW |