blob: b09a56c302d49374e28eeceff8eebdb98c4ef46c [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;
Stefan Holmerb86d4e42015-12-07 10:26:18 +010030class RtpPacketSender;
mflodman3d7db262016-04-29 00:57:13 -070031class Transport;
Stefan Holmerb86d4e42015-12-07 10:26:18 +010032class TransportFeedbackObserver;
33
solenberg13725082015-11-25 08:16:52 -080034namespace voe {
35
solenberg358057b2015-11-27 10:46:42 -080036class Channel;
37
solenberg13725082015-11-25 08:16:52 -080038// This class provides the "view" of a voe::Channel that we need to implement
39// webrtc::AudioSendStream and webrtc::AudioReceiveStream. It serves two
40// purposes:
41// 1. Allow mocking just the interfaces used, instead of the entire
42// voe::Channel class.
43// 2. Provide a refined interface for the stream classes, including assumptions
44// on return values and input adaptation.
45class ChannelProxy {
46 public:
47 ChannelProxy();
48 explicit ChannelProxy(const ChannelOwner& channel_owner);
Tommif888bb52015-12-12 01:37:01 +010049 virtual ~ChannelProxy();
solenberg13725082015-11-25 08:16:52 -080050
51 virtual void SetRTCPStatus(bool enable);
52 virtual void SetLocalSSRC(uint32_t ssrc);
53 virtual void SetRTCP_CNAME(const std::string& c_name);
solenberg971cab02016-06-14 10:02:41 -070054 virtual void SetNACKStatus(bool enable, int max_packets);
solenberg358057b2015-11-27 10:46:42 -080055 virtual void SetSendAbsoluteSenderTimeStatus(bool enable, int id);
56 virtual void SetSendAudioLevelIndicationStatus(bool enable, int id);
57 virtual void SetReceiveAbsoluteSenderTimeStatus(bool enable, int id);
58 virtual void SetReceiveAudioLevelIndicationStatus(bool enable, int id);
stefan3313ec92016-01-21 06:32:43 -080059 virtual void EnableSendTransportSequenceNumber(int id);
60 virtual void EnableReceiveTransportSequenceNumber(int id);
stefanbba9dec2016-02-01 04:39:55 -080061 virtual void RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010062 RtpPacketSender* rtp_packet_sender,
63 TransportFeedbackObserver* transport_feedback_observer,
64 PacketRouter* packet_router);
stefanbba9dec2016-02-01 04:39:55 -080065 virtual void RegisterReceiverCongestionControlObjects(
66 PacketRouter* packet_router);
67 virtual void ResetCongestionControlObjects();
solenberg358057b2015-11-27 10:46:42 -080068
69 virtual CallStatistics GetRTCPStatistics() const;
70 virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const;
71 virtual NetworkStatistics GetNetworkStatistics() const;
72 virtual AudioDecodingCallStats GetDecodingCallStatistics() const;
73 virtual int32_t GetSpeechOutputLevelFullRange() const;
74 virtual uint32_t GetDelayEstimate() const;
solenberg13725082015-11-25 08:16:52 -080075
Fredrik Solenbergb5727682015-12-04 15:22:19 +010076 virtual bool SetSendTelephoneEventPayloadType(int payload_type);
solenberg8842c3e2016-03-11 03:06:41 -080077 virtual bool SendTelephoneEventOutband(int event, int duration_ms);
mflodman86cc6ff2016-07-26 04:44:06 -070078 virtual void SetBitrate(int bitrate_bps);
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);
Tommif888bb52015-12-12 01:37:01 +010081
mflodman3d7db262016-04-29 00:57:13 -070082 virtual void RegisterExternalTransport(Transport* transport);
83 virtual void DeRegisterExternalTransport();
84 virtual bool ReceivedRTPPacket(const uint8_t* packet,
85 size_t length,
86 const PacketTime& packet_time);
87 virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length);
88
ossu29b1a8d2016-06-13 07:34:51 -070089 virtual const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -070090 GetAudioDecoderFactory() const;
91
92 virtual void SetChannelOutputVolumeScaling(float scaling);
ossu29b1a8d2016-06-13 07:34:51 -070093
ivoc14d5dbe2016-07-04 07:06:55 -070094 virtual void SetRtcEventLog(RtcEventLog* event_log);
95
aleloiaed581a2016-10-20 06:32:39 -070096 virtual AudioMixer::Source::AudioFrameWithInfo GetAudioFrameWithInfo(
97 int sample_rate_hz);
98
solenberg13725082015-11-25 08:16:52 -080099 private:
solenberg358057b2015-11-27 10:46:42 -0800100 Channel* channel() const;
101
102 rtc::ThreadChecker thread_checker_;
aleloiaed581a2016-10-20 06:32:39 -0700103 rtc::RaceChecker race_checker_;
solenberg13725082015-11-25 08:16:52 -0800104 ChannelOwner channel_owner_;
solenbergff976312016-03-30 23:28:51 -0700105
106 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy);
solenberg13725082015-11-25 08:16:52 -0800107};
108} // namespace voe
109} // namespace webrtc
110
111#endif // WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_