blob: e4c60a1a4b7b1d07b9cd9ae7098380afc0144ba3 [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:
Niels Möllerb222f492018-10-03 16:50:08 +020031 MOCK_METHOD2(SetNACKStatus, void(bool enable, int max_packets));
32 MOCK_METHOD1(RegisterReceiverCongestionControlObjects,
33 void(PacketRouter* packet_router));
34 MOCK_METHOD0(ResetReceiverCongestionControlObjects, void());
Niels Möller530ead42018-10-04 14:28:39 +020035 MOCK_CONST_METHOD0(GetRTCPStatistics, CallReceiveStatistics());
Niels Möllerb222f492018-10-03 16:50:08 +020036 MOCK_CONST_METHOD0(GetNetworkStatistics, NetworkStatistics());
37 MOCK_CONST_METHOD0(GetDecodingCallStatistics, AudioDecodingCallStats());
38 MOCK_CONST_METHOD0(GetSpeechOutputLevelFullRange, int());
39 MOCK_CONST_METHOD0(GetTotalOutputEnergy, double());
40 MOCK_CONST_METHOD0(GetTotalOutputDuration, double());
41 MOCK_CONST_METHOD0(GetDelayEstimate, uint32_t());
42 MOCK_METHOD1(SetSink, void(AudioSinkInterface* sink));
Niels Möllerb222f492018-10-03 16:50:08 +020043 MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet));
Niels Möller8fb1a6a2019-03-05 14:29:42 +010044 MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length));
Niels Möllerb222f492018-10-03 16:50:08 +020045 MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling));
46 MOCK_METHOD2(GetAudioFrameWithInfo,
47 AudioMixer::Source::AudioFrameInfo(int sample_rate_hz,
48 AudioFrame* audio_frame));
49 MOCK_CONST_METHOD0(PreferredSampleRate, int());
Niels Möller349ade32018-11-16 09:50:42 +010050 MOCK_METHOD1(SetAssociatedSendChannel,
Niels Möllerdced9f62018-11-19 10:27:07 +010051 void(const voe::ChannelSendInterface* send_channel));
Åsa Perssonfcf79cc2019-10-22 15:23:44 +020052 MOCK_CONST_METHOD2(GetPlayoutRtpTimestamp,
53 bool(uint32_t* rtp_timestamp, int64_t* time_ms));
54 MOCK_METHOD2(SetEstimatedPlayoutNtpTimestampMs,
55 void(int64_t ntp_timestamp_ms, int64_t time_ms));
56 MOCK_CONST_METHOD1(GetCurrentEstimatedPlayoutNtpTimestampMs,
57 absl::optional<int64_t>(int64_t now_ms));
Niels Möller349ade32018-11-16 09:50:42 +010058 MOCK_CONST_METHOD0(GetSyncInfo, absl::optional<Syncable::Info>());
Niels Möllerb222f492018-10-03 16:50:08 +020059 MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms));
Ruslan Burakov3b50f9f2019-02-06 09:45:56 +010060 MOCK_METHOD1(SetBaseMinimumPlayoutDelayMs, bool(int delay_ms));
61 MOCK_CONST_METHOD0(GetBaseMinimumPlayoutDelayMs, int());
Fredrik Solenbergf693bfa2018-12-11 12:22:10 +010062 MOCK_CONST_METHOD0(GetReceiveCodec,
63 absl::optional<std::pair<int, SdpAudioFormat>>());
Niels Möllerb222f492018-10-03 16:50:08 +020064 MOCK_METHOD1(SetReceiveCodecs,
65 void(const std::map<int, SdpAudioFormat>& codecs));
66 MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>());
67 MOCK_METHOD0(StartPlayout, void());
68 MOCK_METHOD0(StopPlayout, void());
69};
70
Niels Möllerdced9f62018-11-19 10:27:07 +010071class MockChannelSend : public voe::ChannelSendInterface {
solenberg13725082015-11-25 08:16:52 -080072 public:
Fredrik Solenberg2a877972017-12-15 16:42:15 +010073 // GMock doesn't like move-only types, like std::unique_ptr.
Niels Möller8fb1a6a2019-03-05 14:29:42 +010074 virtual void SetEncoder(int payload_type,
Fredrik Solenberg2a877972017-12-15 16:42:15 +010075 std::unique_ptr<AudioEncoder> encoder) {
ossu1ffbd6c2017-04-06 12:05:04 -070076 return SetEncoderForMock(payload_type, &encoder);
77 }
78 MOCK_METHOD2(SetEncoderForMock,
Niels Möller8fb1a6a2019-03-05 14:29:42 +010079 void(int payload_type, std::unique_ptr<AudioEncoder>* encoder));
ossu20a4b3f2017-04-27 02:08:52 -070080 MOCK_METHOD1(
81 ModifyEncoder,
82 void(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier));
Sebastian Jansson14a7cf92019-02-13 15:11:42 +010083 MOCK_METHOD1(CallEncoder,
84 void(rtc::FunctionView<void(AudioEncoder*)> modifier));
Niels Möller26815232018-11-16 09:32:40 +010085 MOCK_METHOD1(SetRTCP_CNAME, void(absl::string_view c_name));
solenberg358057b2015-11-27 10:46:42 -080086 MOCK_METHOD2(SetSendAudioLevelIndicationStatus, void(bool enable, int id));
nisseb8f9a322017-03-27 05:36:15 -070087 MOCK_METHOD2(RegisterSenderCongestionControlObjects,
88 void(RtpTransportControllerSendInterface* transport,
stefan7de8d642017-02-07 07:14:08 -080089 RtcpBandwidthObserver* bandwidth_observer));
nissefdbfdc92017-03-31 05:44:52 -070090 MOCK_METHOD0(ResetSenderCongestionControlObjects, void());
Niels Möller530ead42018-10-04 14:28:39 +020091 MOCK_CONST_METHOD0(GetRTCPStatistics, CallSendStatistics());
solenberg358057b2015-11-27 10:46:42 -080092 MOCK_CONST_METHOD0(GetRemoteRTCPReportBlocks, std::vector<ReportBlock>());
ivoce1198e02017-09-08 08:13:19 -070093 MOCK_CONST_METHOD0(GetANAStatistics, ANAStats());
Niels Mölleree5ccbc2019-03-06 16:47:29 +010094 MOCK_METHOD2(RegisterCngPayloadType,
95 void(int payload_type, int payload_frequency));
Yves Gerey665174f2018-06-19 15:03:05 +020096 MOCK_METHOD2(SetSendTelephoneEventPayloadType,
Niels Möller8fb1a6a2019-03-05 14:29:42 +010097 void(int payload_type, int payload_frequency));
solenberg8842c3e2016-03-11 03:06:41 -080098 MOCK_METHOD2(SendTelephoneEventOutband, bool(int event, int duration_ms));
Sebastian Jansson254d8692018-11-21 19:19:00 +010099 MOCK_METHOD1(OnBitrateAllocation, void(BitrateAllocationUpdate update));
solenberg7602aab2016-11-14 11:30:07 -0800100 MOCK_METHOD1(SetInputMute, void(bool muted));
Niels Möller8fb1a6a2019-03-05 14:29:42 +0100101 MOCK_METHOD2(ReceivedRTCPPacket, void(const uint8_t* packet, size_t length));
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100102 // GMock doesn't like move-only types, like std::unique_ptr.
103 virtual void ProcessAndEncodeAudio(std::unique_ptr<AudioFrame> audio_frame) {
104 ProcessAndEncodeAudioForMock(&audio_frame);
105 }
106 MOCK_METHOD1(ProcessAndEncodeAudioForMock,
107 void(std::unique_ptr<AudioFrame>* audio_frame));
Niels Möllerdced9f62018-11-19 10:27:07 +0100108 MOCK_METHOD1(SetTransportOverhead,
109 void(size_t transport_overhead_per_packet));
Niels Möller848d6d32018-08-08 10:49:16 +0200110 MOCK_CONST_METHOD0(GetRtpRtcp, RtpRtcp*());
Sebastian Jansson359d60a2018-10-25 16:22:02 +0200111 MOCK_CONST_METHOD0(GetBitrate, int());
elad.alond12a8e12017-03-23 11:04:48 -0700112 MOCK_METHOD1(OnTwccBasedUplinkPacketLossRate, void(float packet_loss_rate));
elad.alondadb4dc2017-03-23 15:29:50 -0700113 MOCK_METHOD1(OnRecoverableUplinkPacketLossRate,
114 void(float recoverable_packet_loss_rate));
Niels Möllerdced9f62018-11-19 10:27:07 +0100115 MOCK_CONST_METHOD0(GetRTT, int64_t());
Fredrik Solenbergaaedf752017-12-18 13:09:12 +0100116 MOCK_METHOD0(StartSend, void());
117 MOCK_METHOD0(StopSend, void());
Benjamin Wright78410ad2018-10-25 09:52:57 -0700118 MOCK_METHOD1(
119 SetFrameEncryptor,
120 void(rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor));
solenberg13725082015-11-25 08:16:52 -0800121};
122} // namespace test
123} // namespace webrtc
124
Fredrik Solenberga8b7c7f2018-01-17 11:18:31 +0100125#endif // AUDIO_MOCK_VOE_CHANNEL_PROXY_H_