1 /* 2 * Copyright (c) 2012 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_MOCKS_MOCK_RTP_RTCP_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_MOCKS_MOCK_RTP_RTCP_H_ 13 14 #include <set> 15 #include <utility> 16 #include <vector> 17 18 #include "testing/gmock/include/gmock/gmock.h" 19 20 #include "webrtc/modules/include/module.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 24 25 namespace webrtc { 26 27 class MockRtpData : public RtpData { 28 public: 29 MOCK_METHOD3(OnReceivedPayloadData, 30 int32_t(const uint8_t* payloadData, 31 const size_t payloadSize, 32 const WebRtcRTPHeader* rtpHeader)); 33 34 MOCK_METHOD2(OnRecoveredPacket, 35 bool(const uint8_t* packet, size_t packet_length)); 36 }; 37 38 class MockRtpRtcp : public RtpRtcp { 39 public: 40 MOCK_METHOD1(RegisterDefaultModule, 41 int32_t(RtpRtcp* module)); 42 MOCK_METHOD0(DeRegisterDefaultModule, 43 int32_t()); 44 MOCK_METHOD0(DefaultModuleRegistered, 45 bool()); 46 MOCK_METHOD0(NumberChildModules, 47 uint32_t()); 48 MOCK_METHOD1(RegisterSyncModule, 49 int32_t(RtpRtcp* module)); 50 MOCK_METHOD0(DeRegisterSyncModule, 51 int32_t()); 52 MOCK_METHOD2(IncomingRtcpPacket, 53 int32_t(const uint8_t* incomingPacket, size_t packetLength)); 54 MOCK_METHOD1(SetRemoteSSRC, void(const uint32_t ssrc)); 55 MOCK_METHOD4(IncomingAudioNTP, 56 int32_t(const uint32_t audioReceivedNTPsecs, 57 const uint32_t audioReceivedNTPfrac, 58 const uint32_t audioRTCPArrivalTimeSecs, 59 const uint32_t audioRTCPArrivalTimeFrac)); 60 MOCK_METHOD0(InitSender, 61 int32_t()); 62 MOCK_METHOD1(RegisterSendTransport, 63 int32_t(Transport* outgoingTransport)); 64 MOCK_METHOD1(SetMaxTransferUnit, 65 int32_t(const uint16_t size)); 66 MOCK_METHOD3(SetTransportOverhead, 67 int32_t(const bool TCP, const bool IPV6, 68 const uint8_t authenticationOverhead)); 69 MOCK_CONST_METHOD0(MaxPayloadLength, 70 uint16_t()); 71 MOCK_CONST_METHOD0(MaxDataPayloadLength, 72 uint16_t()); 73 MOCK_METHOD1(RegisterSendPayload, 74 int32_t(const CodecInst& voiceCodec)); 75 MOCK_METHOD1(RegisterSendPayload, 76 int32_t(const VideoCodec& videoCodec)); 77 MOCK_METHOD1(DeRegisterSendPayload, 78 int32_t(const int8_t payloadType)); 79 MOCK_METHOD2(RegisterSendRtpHeaderExtension, 80 int32_t(const RTPExtensionType type, const uint8_t id)); 81 MOCK_METHOD1(DeregisterSendRtpHeaderExtension, 82 int32_t(const RTPExtensionType type)); 83 MOCK_CONST_METHOD0(StartTimestamp, 84 uint32_t()); 85 MOCK_METHOD1(SetStartTimestamp, void(const uint32_t timestamp)); 86 MOCK_CONST_METHOD0(SequenceNumber, 87 uint16_t()); 88 MOCK_METHOD1(SetSequenceNumber, void(const uint16_t seq)); 89 MOCK_METHOD2(SetRtpStateForSsrc, 90 bool(uint32_t ssrc, const RtpState& rtp_state)); 91 MOCK_METHOD2(GetRtpStateForSsrc, bool(uint32_t ssrc, RtpState* rtp_state)); 92 MOCK_CONST_METHOD0(SSRC, 93 uint32_t()); 94 MOCK_METHOD1(SetSSRC, 95 void(const uint32_t ssrc)); 96 MOCK_CONST_METHOD1(CSRCs, 97 int32_t(uint32_t arrOfCSRC[kRtpCsrcSize])); 98 MOCK_METHOD1(SetCsrcs, void(const std::vector<uint32_t>& csrcs)); 99 MOCK_METHOD1(SetCSRCStatus, 100 int32_t(const bool include)); 101 MOCK_METHOD1(SetRtxSendStatus, void(int modes)); 102 MOCK_CONST_METHOD0(RtxSendStatus, int()); 103 MOCK_METHOD1(SetRtxSsrc, 104 void(uint32_t)); 105 MOCK_METHOD2(SetRtxSendPayloadType, void(int, int)); 106 MOCK_CONST_METHOD0(RtxSendPayloadType, std::pair<int, int>()); 107 MOCK_METHOD1(SetSendingStatus, 108 int32_t(const bool sending)); 109 MOCK_CONST_METHOD0(Sending, 110 bool()); 111 MOCK_METHOD1(SetSendingMediaStatus, void(const bool sending)); 112 MOCK_CONST_METHOD0(SendingMedia, 113 bool()); 114 MOCK_CONST_METHOD4(BitrateSent, 115 void(uint32_t* totalRate, 116 uint32_t* videoRate, 117 uint32_t* fecRate, 118 uint32_t* nackRate)); 119 MOCK_METHOD1(RegisterVideoBitrateObserver, void(BitrateStatisticsObserver*)); 120 MOCK_CONST_METHOD0(GetVideoBitrateObserver, BitrateStatisticsObserver*(void)); 121 MOCK_CONST_METHOD1(EstimatedReceiveBandwidth, 122 int(uint32_t* available_bandwidth)); 123 MOCK_METHOD8(SendOutgoingData, 124 int32_t(const FrameType frameType, 125 const int8_t payloadType, 126 const uint32_t timeStamp, 127 int64_t capture_time_ms, 128 const uint8_t* payloadData, 129 const size_t payloadSize, 130 const RTPFragmentationHeader* fragmentation, 131 const RTPVideoHeader* rtpVideoHdr)); 132 MOCK_METHOD4(TimeToSendPacket, 133 bool(uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, 134 bool retransmission)); 135 MOCK_METHOD1(TimeToSendPadding, 136 size_t(size_t bytes)); 137 MOCK_METHOD2(RegisterRtcpObservers, 138 void(RtcpIntraFrameObserver* intraFrameCallback, 139 RtcpBandwidthObserver* bandwidthCallback)); 140 MOCK_CONST_METHOD0(RTCP, RtcpMode()); 141 MOCK_METHOD1(SetRTCPStatus, void(const RtcpMode method)); 142 MOCK_METHOD1(SetCNAME, 143 int32_t(const char cName[RTCP_CNAME_SIZE])); 144 MOCK_CONST_METHOD2(RemoteCNAME, 145 int32_t(const uint32_t remoteSSRC, 146 char cName[RTCP_CNAME_SIZE])); 147 MOCK_CONST_METHOD5(RemoteNTP, 148 int32_t(uint32_t *ReceivedNTPsecs, 149 uint32_t *ReceivedNTPfrac, 150 uint32_t *RTCPArrivalTimeSecs, 151 uint32_t *RTCPArrivalTimeFrac, 152 uint32_t *rtcp_timestamp)); 153 MOCK_METHOD2(AddMixedCNAME, 154 int32_t(const uint32_t SSRC, 155 const char cName[RTCP_CNAME_SIZE])); 156 MOCK_METHOD1(RemoveMixedCNAME, 157 int32_t(const uint32_t SSRC)); 158 MOCK_CONST_METHOD5(RTT, 159 int32_t(const uint32_t remoteSSRC, 160 int64_t* RTT, 161 int64_t* avgRTT, 162 int64_t* minRTT, 163 int64_t* maxRTT)); 164 MOCK_METHOD1(SendRTCP, int32_t(RTCPPacketType packetType)); 165 MOCK_METHOD1(SendCompoundRTCP, 166 int32_t(const std::set<RTCPPacketType>& packetTypes)); 167 MOCK_METHOD1(SendRTCPReferencePictureSelection, 168 int32_t(const uint64_t pictureID)); 169 MOCK_METHOD1(SendRTCPSliceLossIndication, 170 int32_t(const uint8_t pictureID)); 171 MOCK_CONST_METHOD2(DataCountersRTP, 172 int32_t(size_t *bytesSent, uint32_t *packetsSent)); 173 MOCK_CONST_METHOD2(GetSendStreamDataCounters, 174 void(StreamDataCounters*, StreamDataCounters*)); 175 MOCK_CONST_METHOD3(GetRtpPacketLossStats, 176 void(bool, uint32_t, struct RtpPacketLossStats*)); 177 MOCK_METHOD1(RemoteRTCPStat, 178 int32_t(RTCPSenderInfo* senderInfo)); 179 MOCK_CONST_METHOD1(RemoteRTCPStat, 180 int32_t(std::vector<RTCPReportBlock>* receiveBlocks)); 181 MOCK_METHOD4(SetRTCPApplicationSpecificData, 182 int32_t(const uint8_t subType, 183 const uint32_t name, 184 const uint8_t* data, 185 const uint16_t length)); 186 MOCK_METHOD1(SetRTCPVoIPMetrics, 187 int32_t(const RTCPVoIPMetric* VoIPMetric)); 188 MOCK_METHOD1(SetRtcpXrRrtrStatus, 189 void(bool enable)); 190 MOCK_CONST_METHOD0(RtcpXrRrtrStatus, 191 bool()); 192 MOCK_CONST_METHOD0(REMB, 193 bool()); 194 MOCK_METHOD1(SetREMBStatus, void(const bool enable)); 195 MOCK_METHOD2(SetREMBData, 196 void(const uint32_t bitrate, 197 const std::vector<uint32_t>& ssrcs)); 198 MOCK_CONST_METHOD0(TMMBR, 199 bool()); 200 MOCK_METHOD1(SetTMMBRStatus, void(const bool enable)); 201 MOCK_METHOD1(OnBandwidthEstimateUpdate, 202 void(uint16_t bandWidthKbit)); 203 MOCK_CONST_METHOD0(NACK, 204 NACKMethod()); 205 MOCK_METHOD2(SetNACKStatus, 206 int32_t(const NACKMethod method, int oldestSequenceNumberToNack)); 207 MOCK_CONST_METHOD0(SelectiveRetransmissions, 208 int()); 209 MOCK_METHOD1(SetSelectiveRetransmissions, 210 int(uint8_t settings)); 211 MOCK_METHOD2(SendNACK, 212 int32_t(const uint16_t* nackList, const uint16_t size)); 213 MOCK_METHOD2(SetStorePacketsStatus, 214 void(const bool enable, const uint16_t numberToStore)); 215 MOCK_CONST_METHOD0(StorePackets, bool()); 216 MOCK_METHOD1(RegisterRtcpStatisticsCallback, void(RtcpStatisticsCallback*)); 217 MOCK_METHOD0(GetRtcpStatisticsCallback, RtcpStatisticsCallback*()); 218 MOCK_METHOD1(SendFeedbackPacket, bool(const rtcp::TransportFeedback& packet)); 219 MOCK_METHOD1(RegisterAudioCallback, 220 int32_t(RtpAudioFeedback* messagesCallback)); 221 MOCK_METHOD1(SetAudioPacketSize, 222 int32_t(const uint16_t packetSizeSamples)); 223 MOCK_METHOD3(SendTelephoneEventOutband, 224 int32_t(const uint8_t key, const uint16_t time_ms, const uint8_t level)); 225 MOCK_METHOD1(SetSendREDPayloadType, 226 int32_t(const int8_t payloadType)); 227 MOCK_CONST_METHOD1(SendREDPayloadType, int32_t(int8_t* payloadType)); 228 MOCK_METHOD2(SetRTPAudioLevelIndicationStatus, 229 int32_t(const bool enable, const uint8_t ID)); 230 MOCK_METHOD1(SetAudioLevel, 231 int32_t(const uint8_t level_dBov)); 232 MOCK_METHOD1(SetTargetSendBitrate, 233 void(uint32_t bitrate_bps)); 234 MOCK_METHOD3(SetGenericFECStatus, 235 void(const bool enable, 236 const uint8_t payload_type_red, 237 const uint8_t payload_type_fec)); 238 MOCK_METHOD3(GenericFECStatus, 239 void(bool* enable, 240 uint8_t* payloadTypeRED, 241 uint8_t* payloadTypeFEC)); 242 MOCK_METHOD2(SetFecParameters, 243 int32_t(const FecProtectionParams* delta_params, 244 const FecProtectionParams* key_params)); 245 MOCK_METHOD1(SetKeyFrameRequestMethod, 246 int32_t(const KeyFrameRequestMethod method)); 247 MOCK_METHOD0(RequestKeyFrame, 248 int32_t()); 249 MOCK_METHOD0(TimeUntilNextProcess, 250 int64_t()); 251 MOCK_METHOD0(Process, 252 int32_t()); 253 MOCK_METHOD1(RegisterSendFrameCountObserver, 254 void(FrameCountObserver*)); 255 MOCK_CONST_METHOD0(GetSendFrameCountObserver, 256 FrameCountObserver*(void)); 257 MOCK_METHOD1(RegisterSendChannelRtpStatisticsCallback, 258 void(StreamDataCountersCallback*)); 259 MOCK_CONST_METHOD0(GetSendChannelRtpStatisticsCallback, 260 StreamDataCountersCallback*(void)); 261 // Members. 262 unsigned int remote_ssrc_; 263 }; 264 265 } // namespace webrtc 266 267 #endif // WEBRTC_MODULES_RTP_RTCP_MOCKS_MOCK_RTP_RTCP_H_ 268