blob: 4bd76a4bede331b23350ae8b168ea7aeb13279de [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
11#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
12#define WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
13
aleloiaed581a2016-10-20 06:32:39 -070014#include "webrtc/api/audio/audio_mixer.h"
solenbergff976312016-03-30 23:28:51 -070015#include "webrtc/base/constructormagic.h"
aleloiaed581a2016-10-20 06:32:39 -070016#include "webrtc/base/race_checker.h"
solenberg358057b2015-11-27 10:46:42 -080017#include "webrtc/base/thread_checker.h"
solenberg13725082015-11-25 08:16:52 -080018#include "webrtc/voice_engine/channel_manager.h"
solenberg358057b2015-11-27 10:46:42 -080019#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
solenberg13725082015-11-25 08:16:52 -080020
kwibergb7f89d62016-02-17 10:04:18 -080021#include <memory>
solenberg13725082015-11-25 08:16:52 -080022#include <string>
solenberg358057b2015-11-27 10:46:42 -080023#include <vector>
solenberg13725082015-11-25 08:16:52 -080024
25namespace webrtc {
Stefan Holmerb86d4e42015-12-07 10:26:18 +010026
Tommif888bb52015-12-12 01:37:01 +010027class AudioSinkInterface;
Stefan Holmerb86d4e42015-12-07 10:26:18 +010028class PacketRouter;
ivoc14d5dbe2016-07-04 07:06:55 -070029class RtcEventLog;
michaelt9332b7d2016-11-30 07:51:13 -080030class RtcpRttStats;
Stefan Holmerb86d4e42015-12-07 10:26:18 +010031class RtpPacketSender;
mflodman3d7db262016-04-29 00:57:13 -070032class Transport;
Stefan Holmerb86d4e42015-12-07 10:26:18 +010033class TransportFeedbackObserver;
34
solenberg13725082015-11-25 08:16:52 -080035namespace voe {
36
solenberg358057b2015-11-27 10:46:42 -080037class Channel;
38
solenberg13725082015-11-25 08:16:52 -080039// This class provides the "view" of a voe::Channel that we need to implement
40// webrtc::AudioSendStream and webrtc::AudioReceiveStream. It serves two
41// purposes:
42// 1. Allow mocking just the interfaces used, instead of the entire
43// voe::Channel class.
44// 2. Provide a refined interface for the stream classes, including assumptions
45// on return values and input adaptation.
46class ChannelProxy {
47 public:
48 ChannelProxy();
49 explicit ChannelProxy(const ChannelOwner& channel_owner);
Tommif888bb52015-12-12 01:37:01 +010050 virtual ~ChannelProxy();
solenberg13725082015-11-25 08:16:52 -080051
52 virtual void SetRTCPStatus(bool enable);
53 virtual void SetLocalSSRC(uint32_t ssrc);
54 virtual void SetRTCP_CNAME(const std::string& c_name);
solenberg971cab02016-06-14 10:02:41 -070055 virtual void SetNACKStatus(bool enable, int max_packets);
solenberg358057b2015-11-27 10:46:42 -080056 virtual void SetSendAudioLevelIndicationStatus(bool enable, int id);
solenberg358057b2015-11-27 10:46:42 -080057 virtual void SetReceiveAudioLevelIndicationStatus(bool enable, int id);
stefan3313ec92016-01-21 06:32:43 -080058 virtual void EnableSendTransportSequenceNumber(int id);
59 virtual void EnableReceiveTransportSequenceNumber(int id);
stefanbba9dec2016-02-01 04:39:55 -080060 virtual void RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010061 RtpPacketSender* rtp_packet_sender,
62 TransportFeedbackObserver* transport_feedback_observer,
63 PacketRouter* packet_router);
stefanbba9dec2016-02-01 04:39:55 -080064 virtual void RegisterReceiverCongestionControlObjects(
65 PacketRouter* packet_router);
66 virtual void ResetCongestionControlObjects();
solenberg358057b2015-11-27 10:46:42 -080067 virtual CallStatistics GetRTCPStatistics() const;
68 virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const;
69 virtual NetworkStatistics GetNetworkStatistics() const;
70 virtual AudioDecodingCallStats GetDecodingCallStatistics() const;
71 virtual int32_t GetSpeechOutputLevelFullRange() const;
72 virtual uint32_t GetDelayEstimate() const;
solenbergffbbcac2016-11-17 05:25:37 -080073 virtual bool SetSendTelephoneEventPayloadType(int payload_type,
74 int payload_frequency);
solenberg8842c3e2016-03-11 03:06:41 -080075 virtual bool SendTelephoneEventOutband(int event, int duration_ms);
minyue78b4d562016-11-30 04:47:39 -080076 virtual void SetBitrate(int bitrate_bps, int64_t probing_interval_ms);
kwibergd32bf752017-01-19 07:03:59 -080077 virtual void SetRecPayloadType(int payload_type,
78 const SdpAudioFormat& format);
kwibergb7f89d62016-02-17 10:04:18 -080079 virtual void SetSink(std::unique_ptr<AudioSinkInterface> sink);
solenberg94218532016-06-16 10:53:22 -070080 virtual void SetInputMute(bool muted);
mflodman3d7db262016-04-29 00:57:13 -070081 virtual void RegisterExternalTransport(Transport* transport);
82 virtual void DeRegisterExternalTransport();
83 virtual bool ReceivedRTPPacket(const uint8_t* packet,
84 size_t length,
85 const PacketTime& packet_time);
86 virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length);
ossu29b1a8d2016-06-13 07:34:51 -070087 virtual const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -070088 GetAudioDecoderFactory() const;
solenberg217fb662016-06-17 08:30:54 -070089 virtual void SetChannelOutputVolumeScaling(float scaling);
ivoc14d5dbe2016-07-04 07:06:55 -070090 virtual void SetRtcEventLog(RtcEventLog* event_log);
minyue6b825df2016-10-31 04:08:32 -070091 virtual void EnableAudioNetworkAdaptor(const std::string& config_string);
92 virtual void DisableAudioNetworkAdaptor();
93 virtual void SetReceiverFrameLengthRange(int min_frame_length_ms,
94 int max_frame_length_ms);
aleloi6c278492016-10-20 14:24:39 -070095 virtual AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
96 int sample_rate_hz,
97 AudioFrame* audio_frame);
aleloi051f6782016-10-31 03:26:40 -070098 virtual int NeededFrequency() const;
michaelt79e05882016-11-08 02:50:09 -080099 virtual void SetTransportOverhead(int transport_overhead_per_packet);
solenberg7602aab2016-11-14 11:30:07 -0800100 virtual void AssociateSendChannel(const ChannelProxy& send_channel_proxy);
101 virtual void DisassociateSendChannel();
michaelt79e05882016-11-08 02:50:09 -0800102
michaelt9332b7d2016-11-30 07:51:13 -0800103 virtual void SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats);
104
solenberg13725082015-11-25 08:16:52 -0800105 private:
solenberg358057b2015-11-27 10:46:42 -0800106 Channel* channel() const;
107
108 rtc::ThreadChecker thread_checker_;
aleloiaed581a2016-10-20 06:32:39 -0700109 rtc::RaceChecker race_checker_;
solenberg13725082015-11-25 08:16:52 -0800110 ChannelOwner channel_owner_;
solenbergff976312016-03-30 23:28:51 -0700111
112 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy);
solenberg13725082015-11-25 08:16:52 -0800113};
114} // namespace voe
115} // namespace webrtc
116
117#endif // WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_