2015-04-29 15:24:01 +02: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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef CALL_AUDIO_RECEIVE_STREAM_H_
|
|
|
|
|
#define CALL_AUDIO_RECEIVE_STREAM_H_
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
#include <map>
|
2016-02-23 10:46:32 -08:00
|
|
|
#include <memory>
|
2015-04-29 15:24:01 +02:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-06-15 12:28:07 +02:00
|
|
|
#include "absl/types/optional.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
|
|
|
|
#include "api/call/transport.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/crypto_options.h"
|
2019-09-02 15:16:49 +02:00
|
|
|
#include "api/crypto/frame_decryptor_interface.h"
|
2020-04-01 07:46:16 +02:00
|
|
|
#include "api/frame_transformer_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/rtp_parameters.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2019-09-02 15:16:49 +02:00
|
|
|
#include "api/transport/rtp/rtp_source.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/rtp_config.h"
|
2015-04-29 15:24:01 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2015-12-12 01:37:01 +01:00
|
|
|
class AudioSinkInterface;
|
2015-06-08 13:04:56 +02:00
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
class AudioReceiveStream {
|
2015-04-29 15:24:01 +02:00
|
|
|
public:
|
2015-10-22 10:49:27 +02:00
|
|
|
struct Stats {
|
2018-04-09 14:24:52 +02:00
|
|
|
Stats();
|
|
|
|
|
~Stats();
|
2015-10-22 10:49:27 +02:00
|
|
|
uint32_t remote_ssrc = 0;
|
2019-10-09 15:01:33 +02:00
|
|
|
int64_t payload_bytes_rcvd = 0;
|
|
|
|
|
int64_t header_and_padding_bytes_rcvd = 0;
|
2015-10-22 10:49:27 +02:00
|
|
|
uint32_t packets_rcvd = 0;
|
2019-04-30 09:45:21 +02:00
|
|
|
uint64_t fec_packets_received = 0;
|
|
|
|
|
uint64_t fec_packets_discarded = 0;
|
2015-10-22 10:49:27 +02:00
|
|
|
uint32_t packets_lost = 0;
|
|
|
|
|
std::string codec_name;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<int> codec_payload_type;
|
2015-10-22 10:49:27 +02:00
|
|
|
uint32_t jitter_ms = 0;
|
|
|
|
|
uint32_t jitter_buffer_ms = 0;
|
|
|
|
|
uint32_t jitter_buffer_preferred_ms = 0;
|
|
|
|
|
uint32_t delay_estimate_ms = 0;
|
|
|
|
|
int32_t audio_level = -1;
|
2017-09-18 09:28:20 +02:00
|
|
|
// Stats below correspond to similarly-named fields in the WebRTC stats
|
|
|
|
|
// spec. https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
|
2017-07-14 12:17:49 -07:00
|
|
|
double total_output_energy = 0.0;
|
2017-08-24 17:15:13 -07:00
|
|
|
uint64_t total_samples_received = 0;
|
2017-07-14 12:17:49 -07:00
|
|
|
double total_output_duration = 0.0;
|
2017-08-24 17:15:13 -07:00
|
|
|
uint64_t concealed_samples = 0;
|
2019-04-30 09:45:21 +02:00
|
|
|
uint64_t silent_concealed_samples = 0;
|
2017-09-18 09:28:20 +02:00
|
|
|
uint64_t concealment_events = 0;
|
2017-10-02 12:00:34 +02:00
|
|
|
double jitter_buffer_delay_seconds = 0.0;
|
2019-01-15 15:46:29 +01:00
|
|
|
uint64_t jitter_buffer_emitted_count = 0;
|
2020-03-11 11:18:54 +01:00
|
|
|
double jitter_buffer_target_delay_seconds = 0.0;
|
2019-04-30 09:45:21 +02:00
|
|
|
uint64_t inserted_samples_for_deceleration = 0;
|
|
|
|
|
uint64_t removed_samples_for_acceleration = 0;
|
2017-09-18 09:28:20 +02:00
|
|
|
// Stats below DO NOT correspond directly to anything in the WebRTC stats
|
2015-10-22 10:49:27 +02:00
|
|
|
float expand_rate = 0.0f;
|
|
|
|
|
float speech_expand_rate = 0.0f;
|
|
|
|
|
float secondary_decoded_rate = 0.0f;
|
2017-08-28 13:51:27 +02:00
|
|
|
float secondary_discarded_rate = 0.0f;
|
2015-10-22 10:49:27 +02:00
|
|
|
float accelerate_rate = 0.0f;
|
|
|
|
|
float preemptive_expand_rate = 0.0f;
|
2018-11-27 12:52:16 +01:00
|
|
|
uint64_t delayed_packet_outage_samples = 0;
|
2015-10-22 10:49:27 +02:00
|
|
|
int32_t decoding_calls_to_silence_generator = 0;
|
|
|
|
|
int32_t decoding_calls_to_neteq = 0;
|
|
|
|
|
int32_t decoding_normal = 0;
|
2019-08-07 18:15:08 +02:00
|
|
|
// TODO(alexnarest): Consider decoding_neteq_plc for consistency
|
2015-10-22 10:49:27 +02:00
|
|
|
int32_t decoding_plc = 0;
|
2019-08-07 18:15:08 +02:00
|
|
|
int32_t decoding_codec_plc = 0;
|
2015-10-22 10:49:27 +02:00
|
|
|
int32_t decoding_cng = 0;
|
|
|
|
|
int32_t decoding_plc_cng = 0;
|
2016-09-20 01:47:12 -07:00
|
|
|
int32_t decoding_muted_output = 0;
|
2015-10-22 10:49:27 +02:00
|
|
|
int64_t capture_start_ntp_time_ms = 0;
|
2019-04-15 17:32:00 +02:00
|
|
|
// The timestamp at which the last packet was received, i.e. the time of the
|
|
|
|
|
// local clock when it was received - not the RTP timestamp of that packet.
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
|
|
|
|
|
absl::optional<int64_t> last_packet_received_timestamp_ms;
|
2018-11-22 17:21:10 +01:00
|
|
|
uint64_t jitter_buffer_flushes = 0;
|
2019-03-06 09:18:40 +01:00
|
|
|
double relative_packet_arrival_delay_seconds = 0.0;
|
2019-04-29 17:00:46 +02:00
|
|
|
int32_t interruption_count = 0;
|
|
|
|
|
int32_t total_interruption_duration_ms = 0;
|
2019-10-22 15:23:44 +02:00
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp
|
|
|
|
|
absl::optional<int64_t> estimated_playout_ntp_timestamp_ms;
|
2015-10-22 10:49:27 +02:00
|
|
|
};
|
2015-06-08 13:04:56 +02:00
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
struct Config {
|
2018-04-09 14:24:52 +02:00
|
|
|
Config();
|
|
|
|
|
~Config();
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
// Receive-stream specific RTP settings.
|
|
|
|
|
struct Rtp {
|
2018-04-09 14:24:52 +02:00
|
|
|
Rtp();
|
|
|
|
|
~Rtp();
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
// Synchronization source (stream identifier) to be received.
|
2015-06-08 13:04:56 +02:00
|
|
|
uint32_t remote_ssrc = 0;
|
|
|
|
|
|
|
|
|
|
// Sender SSRC used for sending RTCP (such as receiver reports).
|
|
|
|
|
uint32_t local_ssrc = 0;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2016-01-12 13:55:00 +01:00
|
|
|
// Enable feedback for send side bandwidth estimation.
|
|
|
|
|
// See
|
|
|
|
|
// https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions
|
|
|
|
|
// for details.
|
|
|
|
|
bool transport_cc = false;
|
|
|
|
|
|
2016-06-14 12:13:00 -07:00
|
|
|
// See NackConfig for description.
|
|
|
|
|
NackConfig nack;
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
// RTP header extensions used for the received stream.
|
|
|
|
|
std::vector<RtpExtension> extensions;
|
|
|
|
|
} rtp;
|
2015-06-08 13:04:56 +02:00
|
|
|
|
2015-10-01 08:13:42 -07:00
|
|
|
Transport* rtcp_send_transport = nullptr;
|
|
|
|
|
|
2018-01-11 13:52:30 +01:00
|
|
|
// NetEq settings.
|
2019-03-15 10:37:31 +01:00
|
|
|
size_t jitter_buffer_max_packets = 200;
|
2018-01-11 13:52:30 +01:00
|
|
|
bool jitter_buffer_fast_accelerate = false;
|
2018-11-27 15:45:20 +01:00
|
|
|
int jitter_buffer_min_delay_ms = 0;
|
2019-01-10 15:58:36 +01:00
|
|
|
bool jitter_buffer_enable_rtx_handling = false;
|
2018-01-11 13:52:30 +01:00
|
|
|
|
2015-07-15 08:02:58 -07:00
|
|
|
// Identifier for an A/V synchronization group. Empty string to disable.
|
|
|
|
|
// TODO(pbos): Synchronize streams in a sync group, not just one video
|
|
|
|
|
// stream to one audio stream. Tracked by issue webrtc:4762.
|
|
|
|
|
std::string sync_group;
|
|
|
|
|
|
2017-01-19 07:03:59 -08:00
|
|
|
// Decoder specifications for every payload type that we can receive.
|
|
|
|
|
std::map<int, SdpAudioFormat> decoder_map;
|
2016-06-13 07:34:51 -07:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
|
2018-03-20 19:18:55 +01:00
|
|
|
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<AudioCodecPairId> codec_pair_id;
|
2018-10-04 14:22:34 -07:00
|
|
|
|
2018-10-15 10:20:24 -07:00
|
|
|
// Per PeerConnection crypto options.
|
|
|
|
|
webrtc::CryptoOptions crypto_options;
|
|
|
|
|
|
2018-10-04 14:22:34 -07:00
|
|
|
// An optional custom frame decryptor that allows the entire frame to be
|
|
|
|
|
// decrypted in whatever way the caller choses. This is not required by
|
|
|
|
|
// default.
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor;
|
2020-04-01 07:46:16 +02:00
|
|
|
|
|
|
|
|
// An optional frame transformer used by insertable streams to transform
|
|
|
|
|
// encoded frames.
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer;
|
2015-04-29 15:24:01 +02:00
|
|
|
};
|
|
|
|
|
|
2018-01-10 15:17:10 +01:00
|
|
|
// Reconfigure the stream according to the Configuration.
|
|
|
|
|
virtual void Reconfigure(const Config& config) = 0;
|
|
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
// Starts stream activity.
|
|
|
|
|
// When a stream is active, it can receive, process and deliver packets.
|
|
|
|
|
virtual void Start() = 0;
|
|
|
|
|
// Stops stream activity.
|
|
|
|
|
// When a stream is stopped, it can't receive, process or deliver packets.
|
|
|
|
|
virtual void Stop() = 0;
|
|
|
|
|
|
2021-01-17 14:36:44 +01:00
|
|
|
// Returns true if the stream has been started.
|
|
|
|
|
virtual bool IsRunning() const = 0;
|
|
|
|
|
|
2020-09-14 10:47:50 +02:00
|
|
|
virtual Stats GetStats(bool get_and_clear_legacy_stats) const = 0;
|
|
|
|
|
Stats GetStats() { return GetStats(/*get_and_clear_legacy_stats=*/true); }
|
2015-12-12 01:37:01 +01:00
|
|
|
|
|
|
|
|
// Sets an audio sink that receives unmixed audio from the receive stream.
|
2018-01-11 13:52:30 +01:00
|
|
|
// Ownership of the sink is managed by the caller.
|
2016-01-15 09:20:04 -08:00
|
|
|
// Only one sink can be set and passing a null sink clears an existing one.
|
2015-12-12 01:37:01 +01:00
|
|
|
// NOTE: Audio must still somehow be pulled through AudioTransport for audio
|
|
|
|
|
// to stream through this sink. In practice, this happens if mixed audio
|
|
|
|
|
// is being pulled+rendered and/or if audio is being pulled for the purposes
|
|
|
|
|
// of feeding to the AEC.
|
2018-01-11 13:52:30 +01:00
|
|
|
virtual void SetSink(AudioSinkInterface* sink) = 0;
|
2016-05-01 20:18:34 -07:00
|
|
|
|
2016-06-17 08:30:54 -07:00
|
|
|
// Sets playback gain of the stream, applied when mixing, and thus after it
|
|
|
|
|
// is potentially forwarded to any attached AudioSinkInterface implementation.
|
|
|
|
|
virtual void SetGain(float gain) = 0;
|
|
|
|
|
|
2019-02-06 09:45:56 +01:00
|
|
|
// Sets a base minimum for the playout delay. Base minimum delay sets lower
|
|
|
|
|
// bound on minimum delay value determining lower bound on playout delay.
|
|
|
|
|
//
|
|
|
|
|
// Returns true if value was successfully set, false overwise.
|
|
|
|
|
virtual bool SetBaseMinimumPlayoutDelayMs(int delay_ms) = 0;
|
|
|
|
|
|
|
|
|
|
// Returns current value of base minimum delay in milliseconds.
|
|
|
|
|
virtual int GetBaseMinimumPlayoutDelayMs() const = 0;
|
|
|
|
|
|
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<RtpSource> GetSources() const = 0;
|
|
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
protected:
|
|
|
|
|
virtual ~AudioReceiveStream() {}
|
2015-04-29 15:24:01 +02:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // CALL_AUDIO_RECEIVE_STREAM_H_
|