blob: cf2fe8874a5e595a9d0e429fe57d0c140d4a6884 [file] [log] [blame]
solenberg13725082015-11-25 08:16:52 -08001/*
2 * Copyright (c) 2015 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
Fredrik Solenberga8b7c7f2018-01-17 11:18:31 +010011#ifndef AUDIO_MOCK_VOE_CHANNEL_PROXY_H_
12#define AUDIO_MOCK_VOE_CHANNEL_PROXY_H_
solenberg13725082015-11-25 08:16:52 -080013
Fredrik Solenberga8b7c7f2018-01-17 11:18:31 +010014#include <map>
15#include <memory>
solenberg13725082015-11-25 08:16:52 -080016#include <string>
Fredrik Solenbergf693bfa2018-12-11 12:22:10 +010017#include <utility>
Fredrik Solenberga8b7c7f2018-01-17 11:18:31 +010018#include <vector>
kwibergac9f8762016-09-30 22:29:43 -070019
Benjamin Wright78410ad2018-10-25 09:52:57 -070020#include "api/test/mock_frame_encryptor.h"
Niels Möller349ade32018-11-16 09:50:42 +010021#include "audio/channel_receive.h"
Niels Möllerdced9f62018-11-19 10:27:07 +010022#include "audio/channel_send.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "modules/rtp_rtcp/source/rtp_packet_received.h"
24#include "test/gmock.h"
solenberg13725082015-11-25 08:16:52 -080025
26namespace webrtc {
27namespace test {
28
Niels Möller349ade32018-11-16 09:50:42 +010029class MockChannelReceive : public voe::ChannelReceiveInterface {
Niels Möllerb222f492018-10-03 16:50:08 +020030 public:
31 MOCK_METHOD1(SetLocalSSRC, void(uint32_t ssrc));
32 MOCK_METHOD2(SetNACKStatus, void(bool enable, int max_packets));
33 MOCK_METHOD1(RegisterReceiverCongestionControlObjects,
34 void(PacketRouter* packet_router));
35 MOCK_METHOD0(ResetReceiverCongestionControlObjects, void());
Niels Möller530ead42018-10-04 14:28:39 +020036 MOCK_CONST_METHOD0(GetRTCPStatistics, CallReceiveStatistics());
Niels Möllerb222f492018-10-03 16:50:08 +020037 MOCK_CONST_METHOD0(GetNetworkStatistics, NetworkStatistics());
38 MOCK_CONST_METHOD0(GetDecodingCallStatistics, AudioDecodingCallStats());
39 MOCK_CONST_METHOD0(GetSpeechOutputLevelFullRange, int());
40 MOCK_CONST_METHOD0(GetTotalOutputEnergy, double());
41 MOCK_CONST_METHOD0(GetTotalOutputDuration, double());
42 MOCK_CONST_METHOD0(GetDelayEstimate, uint32_t());
43 MOCK_METHOD1(SetSink, void(AudioSinkInterface* sink));
Niels Möllerb222f492018-10-03 16:50:08 +020044 MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet));
Niels Möller8fb1a6a2019-03-05 14:29:42 +010045 MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length));
Niels Möllerb222f492018-10-03 16:50:08 +020046 MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling));
47 MOCK_METHOD2(GetAudioFrameWithInfo,
48 AudioMixer::Source::AudioFrameInfo(int sample_rate_hz,
49 AudioFrame* audio_frame));
50 MOCK_CONST_METHOD0(PreferredSampleRate, int());
Niels Möller349ade32018-11-16 09:50:42 +010051 MOCK_METHOD1(SetAssociatedSendChannel,
Niels Möllerdced9f62018-11-19 10:27:07 +010052 void(const voe::ChannelSendInterface* send_channel));
Niels Möllerb222f492018-10-03 16:50:08 +020053 MOCK_CONST_METHOD0(GetPlayoutTimestamp, uint32_t());
Niels Möller349ade32018-11-16 09:50:42 +010054 MOCK_CONST_METHOD0(GetSyncInfo, absl::optional<Syncable::Info>());
Niels Möllerb222f492018-10-03 16:50:08 +020055 MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms));
Ruslan Burakov3b50f9f2019-02-06 09:45:56 +010056 MOCK_METHOD1(SetBaseMinimumPlayoutDelayMs, bool(int delay_ms));
57 MOCK_CONST_METHOD0(GetBaseMinimumPlayoutDelayMs, int());
Fredrik Solenbergf693bfa2018-12-11 12:22:10 +010058 MOCK_CONST_METHOD0(GetReceiveCodec,
59 absl::optional<std::pair<int, SdpAudioFormat>>());
Niels Möllerb222f492018-10-03 16:50:08 +020060 MOCK_METHOD1(SetReceiveCodecs,
61 void(const std::map<int, SdpAudioFormat>& codecs));
62 MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>());
63 MOCK_METHOD0(StartPlayout, void());
64 MOCK_METHOD0(StopPlayout, void());
65};
66
Niels Möllerdced9f62018-11-19 10:27:07 +010067class MockChannelSend : public voe::ChannelSendInterface {
solenberg13725082015-11-25 08:16:52 -080068 public:
Fredrik Solenberg2a877972017-12-15 16:42:15 +010069 // GMock doesn't like move-only types, like std::unique_ptr.
Niels Möller8fb1a6a2019-03-05 14:29:42 +010070 virtual void SetEncoder(int payload_type,
Fredrik Solenberg2a877972017-12-15 16:42:15 +010071 std::unique_ptr<AudioEncoder> encoder) {
ossu1ffbd6c2017-04-06 12:05:04 -070072 return SetEncoderForMock(payload_type, &encoder);
73 }
74 MOCK_METHOD2(SetEncoderForMock,
Niels Möller8fb1a6a2019-03-05 14:29:42 +010075 void(int payload_type, std::unique_ptr<AudioEncoder>* encoder));
ossu20a4b3f2017-04-27 02:08:52 -070076 MOCK_METHOD1(
77 ModifyEncoder,
78 void(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier));
Sebastian Jansson14a7cf92019-02-13 15:11:42 +010079 MOCK_METHOD1(CallEncoder,
80 void(rtc::FunctionView<void(AudioEncoder*)> modifier));
Amit Hilbuch77938e62018-12-21 09:23:38 -080081 MOCK_METHOD3(SetRid,
82 void(const std::string& rid,
83 int extension_id,
84 int repaired_extension_id));
Niels Möllerdced9f62018-11-19 10:27:07 +010085 MOCK_METHOD2(SetMid, void(const std::string& mid, int extension_id));
solenberg13725082015-11-25 08:16:52 -080086 MOCK_METHOD1(SetLocalSSRC, void(uint32_t ssrc));
Niels Möller26815232018-11-16 09:32:40 +010087 MOCK_METHOD1(SetRTCP_CNAME, void(absl::string_view c_name));
Johannes Kron9190b822018-10-29 11:22:05 +010088 MOCK_METHOD1(SetExtmapAllowMixed, void(bool extmap_allow_mixed));
solenberg358057b2015-11-27 10:46:42 -080089 MOCK_METHOD2(SetSendAudioLevelIndicationStatus, void(bool enable, int id));
stefan3313ec92016-01-21 06:32:43 -080090 MOCK_METHOD1(EnableSendTransportSequenceNumber, void(int id));
nisseb8f9a322017-03-27 05:36:15 -070091 MOCK_METHOD2(RegisterSenderCongestionControlObjects,
92 void(RtpTransportControllerSendInterface* transport,
stefan7de8d642017-02-07 07:14:08 -080093 RtcpBandwidthObserver* bandwidth_observer));
nissefdbfdc92017-03-31 05:44:52 -070094 MOCK_METHOD0(ResetSenderCongestionControlObjects, void());
Niels Möller530ead42018-10-04 14:28:39 +020095 MOCK_CONST_METHOD0(GetRTCPStatistics, CallSendStatistics());
solenberg358057b2015-11-27 10:46:42 -080096 MOCK_CONST_METHOD0(GetRemoteRTCPReportBlocks, std::vector<ReportBlock>());
ivoce1198e02017-09-08 08:13:19 -070097 MOCK_CONST_METHOD0(GetANAStatistics, ANAStats());
Niels Mölleree5ccbc2019-03-06 16:47:29 +010098 MOCK_METHOD2(RegisterCngPayloadType,
99 void(int payload_type, int payload_frequency));
Yves Gerey665174f2018-06-19 15:03:05 +0200100 MOCK_METHOD2(SetSendTelephoneEventPayloadType,
Niels Möller8fb1a6a2019-03-05 14:29:42 +0100101 void(int payload_type, int payload_frequency));
solenberg8842c3e2016-03-11 03:06:41 -0800102 MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms));
Sebastian Jansson254d8692018-11-21 19:19:00 +0100103 MOCK_METHOD1(OnBitrateAllocation, void(BitrateAllocationUpdate update));
solenberg7602aab2016-11-14 11:30:07 -0800104 MOCK_METHOD1(SetInputMute, void(bool muted));
Niels Möller8fb1a6a2019-03-05 14:29:42 +0100105 MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length));
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100106 // GMock doesn't like move-only types, like std::unique_ptr.
107 virtual void ProcessAndEncodeAudio(std::unique_ptr<AudioFrame> audio_frame) {
108 ProcessAndEncodeAudioForMock(&audio_frame);
109 }
110 MOCK_METHOD1(ProcessAndEncodeAudioForMock,
111 void(std::unique_ptr<AudioFrame>* audio_frame));
Niels Möllerdced9f62018-11-19 10:27:07 +0100112 MOCK_METHOD1(SetTransportOverhead,
113 void(size_t transport_overhead_per_packet));
Niels Möller848d6d32018-08-08 10:49:16 +0200114 MOCK_CONST_METHOD0(GetRtpRtcp, RtpRtcp*());
Sebastian Jansson359d60a2018-10-25 16:22:02 +0200115 MOCK_CONST_METHOD0(GetBitrate, int());
elad.alond12a8e12017-03-23 11:04:48 -0700116 MOCK_METHOD1(OnTwccBasedUplinkPacketLossRate, void(float packet_loss_rate));
elad.alondadb4dc2017-03-23 15:29:50 -0700117 MOCK_METHOD1(OnRecoverableUplinkPacketLossRate,
118 void(float recoverable_packet_loss_rate));
Niels Möllerdced9f62018-11-19 10:27:07 +0100119 MOCK_CONST_METHOD0(GetRTT, int64_t());
Fredrik Solenbergaaedf752017-12-18 13:09:12 +0100120 MOCK_METHOD0(StartSend, void());
121 MOCK_METHOD0(StopSend, void());
Benjamin Wright78410ad2018-10-25 09:52:57 -0700122 MOCK_METHOD1(
123 SetFrameEncryptor,
124 void(rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor));
solenberg13725082015-11-25 08:16:52 -0800125};
126} // namespace test
127} // namespace webrtc
128
Fredrik Solenberga8b7c7f2018-01-17 11:18:31 +0100129#endif // AUDIO_MOCK_VOE_CHANNEL_PROXY_H_