2015-11-25 08:16:52 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
|
|
|
|
|
#define WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
|
|
|
|
|
|
2016-10-20 06:32:39 -07:00
|
|
|
#include "webrtc/api/audio/audio_mixer.h"
|
2016-03-30 23:28:51 -07:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2016-10-20 06:32:39 -07:00
|
|
|
#include "webrtc/base/race_checker.h"
|
2015-11-27 10:46:42 -08:00
|
|
|
#include "webrtc/base/thread_checker.h"
|
2015-11-25 08:16:52 -08:00
|
|
|
#include "webrtc/voice_engine/channel_manager.h"
|
2015-11-27 10:46:42 -08:00
|
|
|
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
|
2015-11-25 08:16:52 -08:00
|
|
|
|
2016-02-17 10:04:18 -08:00
|
|
|
#include <memory>
|
2015-11-25 08:16:52 -08:00
|
|
|
#include <string>
|
2015-11-27 10:46:42 -08:00
|
|
|
#include <vector>
|
2015-11-25 08:16:52 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2015-12-07 10:26:18 +01:00
|
|
|
|
2015-12-12 01:37:01 +01:00
|
|
|
class AudioSinkInterface;
|
2015-12-07 10:26:18 +01:00
|
|
|
class PacketRouter;
|
2016-07-04 07:06:55 -07:00
|
|
|
class RtcEventLog;
|
2017-02-07 07:14:08 -08:00
|
|
|
class RtcpBandwidthObserver;
|
2016-11-30 07:51:13 -08:00
|
|
|
class RtcpRttStats;
|
2015-12-07 10:26:18 +01:00
|
|
|
class RtpPacketSender;
|
2017-02-21 06:28:10 -08:00
|
|
|
class RtpPacketReceived;
|
2017-01-31 03:58:40 -08:00
|
|
|
class RtpReceiver;
|
|
|
|
|
class RtpRtcp;
|
2017-03-27 05:36:15 -07:00
|
|
|
class RtpTransportControllerSendInterface;
|
2016-04-29 00:57:13 -07:00
|
|
|
class Transport;
|
2015-12-07 10:26:18 +01:00
|
|
|
class TransportFeedbackObserver;
|
|
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
namespace voe {
|
|
|
|
|
|
2015-11-27 10:46:42 -08:00
|
|
|
class Channel;
|
|
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
// This class provides the "view" of a voe::Channel that we need to implement
|
|
|
|
|
// webrtc::AudioSendStream and webrtc::AudioReceiveStream. It serves two
|
|
|
|
|
// purposes:
|
|
|
|
|
// 1. Allow mocking just the interfaces used, instead of the entire
|
|
|
|
|
// voe::Channel class.
|
|
|
|
|
// 2. Provide a refined interface for the stream classes, including assumptions
|
|
|
|
|
// on return values and input adaptation.
|
|
|
|
|
class ChannelProxy {
|
|
|
|
|
public:
|
|
|
|
|
ChannelProxy();
|
|
|
|
|
explicit ChannelProxy(const ChannelOwner& channel_owner);
|
2015-12-12 01:37:01 +01:00
|
|
|
virtual ~ChannelProxy();
|
2015-11-25 08:16:52 -08:00
|
|
|
|
|
|
|
|
virtual void SetRTCPStatus(bool enable);
|
|
|
|
|
virtual void SetLocalSSRC(uint32_t ssrc);
|
|
|
|
|
virtual void SetRTCP_CNAME(const std::string& c_name);
|
2016-06-14 10:02:41 -07:00
|
|
|
virtual void SetNACKStatus(bool enable, int max_packets);
|
2015-11-27 10:46:42 -08:00
|
|
|
virtual void SetSendAudioLevelIndicationStatus(bool enable, int id);
|
|
|
|
|
virtual void SetReceiveAudioLevelIndicationStatus(bool enable, int id);
|
2016-01-21 06:32:43 -08:00
|
|
|
virtual void EnableSendTransportSequenceNumber(int id);
|
|
|
|
|
virtual void EnableReceiveTransportSequenceNumber(int id);
|
2016-02-01 04:39:55 -08:00
|
|
|
virtual void RegisterSenderCongestionControlObjects(
|
2017-03-27 05:36:15 -07:00
|
|
|
RtpTransportControllerSendInterface* transport,
|
2017-02-07 07:14:08 -08:00
|
|
|
RtcpBandwidthObserver* bandwidth_observer);
|
2016-02-01 04:39:55 -08:00
|
|
|
virtual void RegisterReceiverCongestionControlObjects(
|
|
|
|
|
PacketRouter* packet_router);
|
|
|
|
|
virtual void ResetCongestionControlObjects();
|
2015-11-27 10:46:42 -08:00
|
|
|
virtual CallStatistics GetRTCPStatistics() const;
|
|
|
|
|
virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const;
|
|
|
|
|
virtual NetworkStatistics GetNetworkStatistics() const;
|
|
|
|
|
virtual AudioDecodingCallStats GetDecodingCallStatistics() const;
|
2017-03-08 01:52:20 -08:00
|
|
|
virtual int GetSpeechOutputLevel() const;
|
|
|
|
|
virtual int GetSpeechOutputLevelFullRange() const;
|
2015-11-27 10:46:42 -08:00
|
|
|
virtual uint32_t GetDelayEstimate() const;
|
2016-11-17 05:25:37 -08:00
|
|
|
virtual bool SetSendTelephoneEventPayloadType(int payload_type,
|
|
|
|
|
int payload_frequency);
|
2016-03-11 03:06:41 -08:00
|
|
|
virtual bool SendTelephoneEventOutband(int event, int duration_ms);
|
2016-11-30 04:47:39 -08:00
|
|
|
virtual void SetBitrate(int bitrate_bps, int64_t probing_interval_ms);
|
2017-01-19 07:03:59 -08:00
|
|
|
virtual void SetRecPayloadType(int payload_type,
|
|
|
|
|
const SdpAudioFormat& format);
|
2017-03-27 07:15:49 -07:00
|
|
|
virtual void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs);
|
2016-02-17 10:04:18 -08:00
|
|
|
virtual void SetSink(std::unique_ptr<AudioSinkInterface> sink);
|
2016-06-16 10:53:22 -07:00
|
|
|
virtual void SetInputMute(bool muted);
|
2016-04-29 00:57:13 -07:00
|
|
|
virtual void RegisterExternalTransport(Transport* transport);
|
|
|
|
|
virtual void DeRegisterExternalTransport();
|
2017-02-21 06:28:10 -08:00
|
|
|
virtual void OnRtpPacket(const RtpPacketReceived& packet);
|
2016-04-29 00:57:13 -07:00
|
|
|
virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length);
|
2016-06-13 07:34:51 -07:00
|
|
|
virtual const rtc::scoped_refptr<AudioDecoderFactory>&
|
2016-06-17 08:30:54 -07:00
|
|
|
GetAudioDecoderFactory() const;
|
|
|
|
|
virtual void SetChannelOutputVolumeScaling(float scaling);
|
2016-07-04 07:06:55 -07:00
|
|
|
virtual void SetRtcEventLog(RtcEventLog* event_log);
|
2016-10-31 04:08:32 -07:00
|
|
|
virtual void EnableAudioNetworkAdaptor(const std::string& config_string);
|
|
|
|
|
virtual void DisableAudioNetworkAdaptor();
|
|
|
|
|
virtual void SetReceiverFrameLengthRange(int min_frame_length_ms,
|
|
|
|
|
int max_frame_length_ms);
|
2016-10-20 14:24:39 -07:00
|
|
|
virtual AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
|
|
|
|
|
int sample_rate_hz,
|
|
|
|
|
AudioFrame* audio_frame);
|
2016-10-31 03:26:40 -07:00
|
|
|
virtual int NeededFrequency() const;
|
2016-11-08 02:50:09 -08:00
|
|
|
virtual void SetTransportOverhead(int transport_overhead_per_packet);
|
2016-11-14 11:30:07 -08:00
|
|
|
virtual void AssociateSendChannel(const ChannelProxy& send_channel_proxy);
|
|
|
|
|
virtual void DisassociateSendChannel();
|
2017-01-31 03:58:40 -08:00
|
|
|
virtual void GetRtpRtcp(RtpRtcp** rtp_rtcp,
|
|
|
|
|
RtpReceiver** rtp_receiver) const;
|
|
|
|
|
virtual uint32_t GetPlayoutTimestamp() const;
|
|
|
|
|
virtual void SetMinimumPlayoutDelay(int delay_ms);
|
2016-11-30 07:51:13 -08:00
|
|
|
virtual void SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats);
|
2017-02-06 12:53:57 -08:00
|
|
|
virtual bool GetRecCodec(CodecInst* codec_inst) const;
|
|
|
|
|
virtual bool GetSendCodec(CodecInst* codec_inst) const;
|
|
|
|
|
virtual bool SetVADStatus(bool enable);
|
|
|
|
|
virtual bool SetCodecFECStatus(bool enable);
|
|
|
|
|
virtual bool SetOpusDtx(bool enable);
|
|
|
|
|
virtual bool SetOpusMaxPlaybackRate(int frequency_hz);
|
|
|
|
|
virtual bool SetSendCodec(const CodecInst& codec_inst);
|
|
|
|
|
virtual bool SetSendCNPayloadType(int type, PayloadFrequencies frequency);
|
2017-03-23 11:04:48 -07:00
|
|
|
virtual void OnTwccBasedUplinkPacketLossRate(float packet_loss_rate);
|
2017-03-23 15:29:50 -07:00
|
|
|
virtual void OnRecoverableUplinkPacketLossRate(
|
|
|
|
|
float recoverable_packet_loss_rate);
|
2017-03-27 07:15:49 -07:00
|
|
|
virtual void RegisterLegacyReceiveCodecs();
|
2016-11-30 07:51:13 -08:00
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
private:
|
2015-11-27 10:46:42 -08:00
|
|
|
Channel* channel() const;
|
|
|
|
|
|
2017-02-15 00:42:31 -08:00
|
|
|
// Thread checkers document and lock usage of some methods on voe::Channel to
|
|
|
|
|
// specific threads we know about. The goal is to eventually split up
|
|
|
|
|
// voe::Channel into parts with single-threaded semantics, and thereby reduce
|
|
|
|
|
// the need for locks.
|
|
|
|
|
rtc::ThreadChecker worker_thread_checker_;
|
|
|
|
|
rtc::ThreadChecker module_process_thread_checker_;
|
|
|
|
|
// Methods accessed from audio and video threads are checked for sequential-
|
|
|
|
|
// only access. We don't necessarily own and control these threads, so thread
|
|
|
|
|
// checkers cannot be used. E.g. Chromium may transfer "ownership" from one
|
|
|
|
|
// audio thread to another, but access is still sequential.
|
|
|
|
|
rtc::RaceChecker audio_thread_race_checker_;
|
|
|
|
|
rtc::RaceChecker video_capture_thread_race_checker_;
|
2015-11-25 08:16:52 -08:00
|
|
|
ChannelOwner channel_owner_;
|
2016-03-30 23:28:51 -07:00
|
|
|
|
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy);
|
2015-11-25 08:16:52 -08:00
|
|
|
};
|
|
|
|
|
} // namespace voe
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_VOICE_ENGINE_CHANNEL_PROXY_H_
|