• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #ifndef AUDIO_MOCK_VOE_CHANNEL_PROXY_H_
12 #define AUDIO_MOCK_VOE_CHANNEL_PROXY_H_
13 
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <utility>
18 #include <vector>
19 
20 #include "api/crypto/frame_decryptor_interface.h"
21 #include "api/test/mock_frame_encryptor.h"
22 #include "audio/channel_receive.h"
23 #include "audio/channel_send.h"
24 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
25 #include "test/gmock.h"
26 
27 namespace webrtc {
28 namespace test {
29 
30 class MockChannelReceive : public voe::ChannelReceiveInterface {
31  public:
32   MOCK_METHOD(void, SetNACKStatus, (bool enable, int max_packets), (override));
33   MOCK_METHOD(void, SetNonSenderRttMeasurement, (bool enabled), (override));
34   MOCK_METHOD(void,
35               RegisterReceiverCongestionControlObjects,
36               (PacketRouter*),
37               (override));
38   MOCK_METHOD(void, ResetReceiverCongestionControlObjects, (), (override));
39   MOCK_METHOD(CallReceiveStatistics, GetRTCPStatistics, (), (const, override));
40   MOCK_METHOD(NetworkStatistics,
41               GetNetworkStatistics,
42               (bool),
43               (const, override));
44   MOCK_METHOD(AudioDecodingCallStats,
45               GetDecodingCallStatistics,
46               (),
47               (const, override));
48   MOCK_METHOD(int, GetSpeechOutputLevelFullRange, (), (const, override));
49   MOCK_METHOD(double, GetTotalOutputEnergy, (), (const, override));
50   MOCK_METHOD(double, GetTotalOutputDuration, (), (const, override));
51   MOCK_METHOD(uint32_t, GetDelayEstimate, (), (const, override));
52   MOCK_METHOD(void, SetSink, (AudioSinkInterface*), (override));
53   MOCK_METHOD(void, OnRtpPacket, (const RtpPacketReceived& packet), (override));
54   MOCK_METHOD(void,
55               ReceivedRTCPPacket,
56               (const uint8_t*, size_t length),
57               (override));
58   MOCK_METHOD(void, SetChannelOutputVolumeScaling, (float scaling), (override));
59   MOCK_METHOD(AudioMixer::Source::AudioFrameInfo,
60               GetAudioFrameWithInfo,
61               (int sample_rate_hz, AudioFrame*),
62               (override));
63   MOCK_METHOD(int, PreferredSampleRate, (), (const, override));
64   MOCK_METHOD(void, SetSourceTracker, (SourceTracker*), (override));
65   MOCK_METHOD(void,
66               SetAssociatedSendChannel,
67               (const voe::ChannelSendInterface*),
68               (override));
69   MOCK_METHOD(bool,
70               GetPlayoutRtpTimestamp,
71               (uint32_t*, int64_t*),
72               (const, override));
73   MOCK_METHOD(void,
74               SetEstimatedPlayoutNtpTimestampMs,
75               (int64_t ntp_timestamp_ms, int64_t time_ms),
76               (override));
77   MOCK_METHOD(absl::optional<int64_t>,
78               GetCurrentEstimatedPlayoutNtpTimestampMs,
79               (int64_t now_ms),
80               (const, override));
81   MOCK_METHOD(absl::optional<Syncable::Info>,
82               GetSyncInfo,
83               (),
84               (const, override));
85   MOCK_METHOD(bool, SetMinimumPlayoutDelay, (int delay_ms), (override));
86   MOCK_METHOD(bool, SetBaseMinimumPlayoutDelayMs, (int delay_ms), (override));
87   MOCK_METHOD(int, GetBaseMinimumPlayoutDelayMs, (), (const, override));
88   MOCK_METHOD((absl::optional<std::pair<int, SdpAudioFormat>>),
89               GetReceiveCodec,
90               (),
91               (const, override));
92   MOCK_METHOD(void,
93               SetReceiveCodecs,
94               ((const std::map<int, SdpAudioFormat>& codecs)),
95               (override));
96   MOCK_METHOD(void, StartPlayout, (), (override));
97   MOCK_METHOD(void, StopPlayout, (), (override));
98   MOCK_METHOD(
99       void,
100       SetDepacketizerToDecoderFrameTransformer,
101       (rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer),
102       (override));
103   MOCK_METHOD(
104       void,
105       SetFrameDecryptor,
106       (rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor),
107       (override));
108   MOCK_METHOD(void, OnLocalSsrcChange, (uint32_t local_ssrc), (override));
109   MOCK_METHOD(uint32_t, GetLocalSsrc, (), (const, override));
110 };
111 
112 class MockChannelSend : public voe::ChannelSendInterface {
113  public:
114   MOCK_METHOD(void,
115               SetEncoder,
116               (int payload_type, std::unique_ptr<AudioEncoder> encoder),
117               (override));
118   MOCK_METHOD(
119       void,
120       ModifyEncoder,
121       (rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier),
122       (override));
123   MOCK_METHOD(void,
124               CallEncoder,
125               (rtc::FunctionView<void(AudioEncoder*)> modifier),
126               (override));
127   MOCK_METHOD(void, SetRTCP_CNAME, (absl::string_view c_name), (override));
128   MOCK_METHOD(void,
129               SetSendAudioLevelIndicationStatus,
130               (bool enable, int id),
131               (override));
132   MOCK_METHOD(void,
133               RegisterSenderCongestionControlObjects,
134               (RtpTransportControllerSendInterface*, RtcpBandwidthObserver*),
135               (override));
136   MOCK_METHOD(void, ResetSenderCongestionControlObjects, (), (override));
137   MOCK_METHOD(CallSendStatistics, GetRTCPStatistics, (), (const, override));
138   MOCK_METHOD(std::vector<ReportBlock>,
139               GetRemoteRTCPReportBlocks,
140               (),
141               (const, override));
142   MOCK_METHOD(ANAStats, GetANAStatistics, (), (const, override));
143   MOCK_METHOD(void,
144               RegisterCngPayloadType,
145               (int payload_type, int payload_frequency),
146               (override));
147   MOCK_METHOD(void,
148               SetSendTelephoneEventPayloadType,
149               (int payload_type, int payload_frequency),
150               (override));
151   MOCK_METHOD(bool,
152               SendTelephoneEventOutband,
153               (int event, int duration_ms),
154               (override));
155   MOCK_METHOD(void,
156               OnBitrateAllocation,
157               (BitrateAllocationUpdate update),
158               (override));
159   MOCK_METHOD(void, SetInputMute, (bool muted), (override));
160   MOCK_METHOD(void,
161               ReceivedRTCPPacket,
162               (const uint8_t*, size_t length),
163               (override));
164   MOCK_METHOD(void,
165               ProcessAndEncodeAudio,
166               (std::unique_ptr<AudioFrame>),
167               (override));
168   MOCK_METHOD(RtpRtcpInterface*, GetRtpRtcp, (), (const, override));
169   MOCK_METHOD(int, GetTargetBitrate, (), (const, override));
170   MOCK_METHOD(int64_t, GetRTT, (), (const, override));
171   MOCK_METHOD(void, StartSend, (), (override));
172   MOCK_METHOD(void, StopSend, (), (override));
173   MOCK_METHOD(void,
174               SetFrameEncryptor,
175               (rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor),
176               (override));
177   MOCK_METHOD(
178       void,
179       SetEncoderToPacketizerFrameTransformer,
180       (rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer),
181       (override));
182 };
183 }  // namespace test
184 }  // namespace webrtc
185 
186 #endif  // AUDIO_MOCK_VOE_CHANNEL_PROXY_H_
187