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.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-01-17 11:18:31 +01:00
|
|
|
#ifndef AUDIO_CHANNEL_PROXY_H_
|
|
|
|
|
#define AUDIO_CHANNEL_PROXY_H_
|
2015-11-25 08:16:52 -08:00
|
|
|
|
2018-01-17 11:18:31 +01:00
|
|
|
#include <map>
|
2018-01-11 13:52:30 +01:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio/audio_mixer.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder.h"
|
|
|
|
|
#include "api/rtpreceiverinterface.h"
|
2018-01-17 11:18:31 +01:00
|
|
|
#include "audio/channel.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/rtp_packet_sink_interface.h"
|
|
|
|
|
#include "rtc_base/constructormagic.h"
|
|
|
|
|
#include "rtc_base/race_checker.h"
|
|
|
|
|
#include "rtc_base/thread_checker.h"
|
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 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 {
|
|
|
|
|
|
|
|
|
|
// 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.
|
2017-06-21 01:05:22 -07:00
|
|
|
class ChannelProxy : public RtpPacketSinkInterface {
|
2015-11-25 08:16:52 -08:00
|
|
|
public:
|
|
|
|
|
ChannelProxy();
|
2018-01-11 13:52:30 +01:00
|
|
|
explicit ChannelProxy(std::unique_ptr<Channel> channel);
|
2015-12-12 01:37:01 +01:00
|
|
|
virtual ~ChannelProxy();
|
2015-11-25 08:16:52 -08:00
|
|
|
|
2017-04-06 12:05:04 -07:00
|
|
|
virtual bool SetEncoder(int payload_type,
|
|
|
|
|
std::unique_ptr<AudioEncoder> encoder);
|
2017-04-27 02:08:52 -07:00
|
|
|
virtual void ModifyEncoder(
|
|
|
|
|
rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier);
|
2017-04-06 12:05:04 -07:00
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
virtual void SetRTCPStatus(bool enable);
|
|
|
|
|
virtual void SetLocalSSRC(uint32_t ssrc);
|
2018-03-26 10:24:32 -07:00
|
|
|
virtual void SetMid(const std::string& mid, int extension_id);
|
2015-11-25 08:16:52 -08:00
|
|
|
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);
|
2016-01-21 06:32:43 -08:00
|
|
|
virtual void EnableSendTransportSequenceNumber(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);
|
2017-03-31 05:44:52 -07:00
|
|
|
virtual void ResetSenderCongestionControlObjects();
|
|
|
|
|
virtual void ResetReceiverCongestionControlObjects();
|
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-09-08 08:13:19 -07:00
|
|
|
virtual ANAStats GetANAStatistics() const;
|
2017-03-08 01:52:20 -08:00
|
|
|
virtual int GetSpeechOutputLevelFullRange() const;
|
2017-07-14 12:17:49 -07:00
|
|
|
// See description of "totalAudioEnergy" in the WebRTC stats spec:
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
|
|
|
|
|
virtual double GetTotalOutputEnergy() const;
|
|
|
|
|
virtual double GetTotalOutputDuration() 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-03-27 07:15:49 -07:00
|
|
|
virtual void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs);
|
2018-01-11 13:52:30 +01:00
|
|
|
virtual void SetSink(AudioSinkInterface* sink);
|
2016-06-16 10:53:22 -07:00
|
|
|
virtual void SetInputMute(bool muted);
|
2017-09-29 06:00:28 -07:00
|
|
|
virtual void RegisterTransport(Transport* transport);
|
2017-06-21 01:05:22 -07:00
|
|
|
|
|
|
|
|
// Implements RtpPacketSinkInterface
|
|
|
|
|
void OnRtpPacket(const RtpPacketReceived& packet) override;
|
2016-04-29 00:57:13 -07:00
|
|
|
virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length);
|
2016-06-17 08:30:54 -07:00
|
|
|
virtual void SetChannelOutputVolumeScaling(float scaling);
|
2016-10-20 14:24:39 -07:00
|
|
|
virtual AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
|
|
|
|
|
int sample_rate_hz,
|
|
|
|
|
AudioFrame* audio_frame);
|
2017-09-22 06:48:10 -07:00
|
|
|
virtual int PreferredSampleRate() const;
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
virtual void ProcessAndEncodeAudio(std::unique_ptr<AudioFrame> audio_frame);
|
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();
|
2018-08-08 10:49:16 +02:00
|
|
|
virtual RtpRtcp* GetRtpRtcp() const;
|
|
|
|
|
|
|
|
|
|
// Produces the transport-related timestamps; current_delay_ms is left unset.
|
|
|
|
|
absl::optional<Syncable::Info> GetSyncInfo() const;
|
2017-01-31 03:58:40 -08:00
|
|
|
virtual uint32_t GetPlayoutTimestamp() const;
|
|
|
|
|
virtual void SetMinimumPlayoutDelay(int delay_ms);
|
2017-02-06 12:53:57 -08:00
|
|
|
virtual bool GetRecCodec(CodecInst* codec_inst) const;
|
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);
|
Reland of Implemented the GetSources() in native code. (patchset #1 id:1 of https://codereview.webrtc.org/2809613002/ )
Reason for revert:
Re-land, reverting did not fix bug.
https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
Original issue's description:
> Revert of Implemented the GetSources() in native code. (patchset #11 id:510001 of https://codereview.webrtc.org/2770233003/ )
>
> Reason for revert:
> Suspected of WebRtcApprtcBrowserTest.MANUAL_WorksOnApprtc breakage, see
>
> https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
>
> Original issue's description:
> > Added the GetSources() to the RtpReceiverInterface and implemented
> > it for the AudioRtpReceiver.
> >
> > This method returns a vector of RtpSource(both CSRC source and SSRC
> > source) which contains the ID of a source, the timestamp, the source
> > type (SSRC or CSRC) and the audio level.
> >
> > The RtpSource objects are buffered and maintained by the
> > RtpReceiver in webrtc/modules/rtp_rtcp/. When the method is called,
> > the info of the contributing source will be pulled along the object
> > chain:
> > AudioRtpReceiver -> VoiceChannel -> WebRtcVoiceMediaChannel ->
> > AudioReceiveStream -> voe::Channel -> RtpRtcp module
> >
> > Spec:https://w3c.github.io/webrtc-pc/archives/20151006/webrtc.html#widl-RTCRtpReceiver-getContributingSources-sequence-RTCRtpContributingSource
> >
> > BUG=chromium:703122
> > TBR=stefan@webrtc.org, danilchap@webrtc.org
> >
> > Review-Url: https://codereview.webrtc.org/2770233003
> > Cr-Commit-Position: refs/heads/master@{#17591}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/292084c3765d9f3ee406ca2ec86eae206b540053
>
> TBR=deadbeef@webrtc.org,solenberg@webrtc.org,hbos@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=chromium:703122
>
> Review-Url: https://codereview.webrtc.org/2809613002
> Cr-Commit-Position: refs/heads/master@{#17616}
> Committed: https://chromium.googlesource.com/external/webrtc/+/fbcc5cb3869d1370008e40f24fc03ac8fb69c675
TBR=deadbeef@webrtc.org,solenberg@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org,olka@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:703122
Review-Url: https://codereview.webrtc.org/2810623003
Cr-Commit-Position: refs/heads/master@{#17621}
2017-04-10 07:39:05 -07:00
|
|
|
virtual std::vector<webrtc::RtpSource> GetSources() const;
|
2017-12-18 13:09:12 +01:00
|
|
|
virtual void StartSend();
|
|
|
|
|
virtual void StopSend();
|
2017-12-18 22:41:03 +01:00
|
|
|
virtual void StartPlayout();
|
|
|
|
|
virtual void StopPlayout();
|
2016-11-30 07:51:13 -08:00
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
private:
|
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_;
|
2018-01-11 13:52:30 +01:00
|
|
|
std::unique_ptr<Channel> channel_;
|
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
|
|
|
|
|
|
2018-01-17 11:18:31 +01:00
|
|
|
#endif // AUDIO_CHANNEL_PROXY_H_
|