Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 AUDIO_CHANNEL_RECEIVE_H_ |
| 12 | #define AUDIO_CHANNEL_RECEIVE_H_ |
| 13 | |
| 14 | #include <map> |
| 15 | #include <memory> |
| 16 | #include <vector> |
| 17 | |
| 18 | #include "absl/types/optional.h" |
| 19 | #include "api/audio/audio_mixer.h" |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 20 | #include "api/audio_codecs/audio_decoder_factory.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 21 | #include "api/call/audio_sink.h" |
| 22 | #include "api/call/transport.h" |
Benjamin Wright | bfb444c | 2018-10-15 10:20:24 -0700 | [diff] [blame] | 23 | #include "api/crypto/cryptooptions.h" |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 24 | #include "api/media_transport_interface.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 25 | #include "api/rtpreceiverinterface.h" |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 26 | #include "call/rtp_packet_sink_interface.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 27 | #include "call/syncable.h" |
| 28 | #include "common_types.h" // NOLINT(build/include) |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 29 | |
| 30 | // TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 31 | // warnings about use of unsigned short. |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 32 | // These need cleanup, in a separate cl. |
| 33 | |
| 34 | namespace rtc { |
| 35 | class TimestampWrapAroundHandler; |
| 36 | } |
| 37 | |
| 38 | namespace webrtc { |
| 39 | |
| 40 | class AudioDeviceModule; |
Benjamin Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 41 | class FrameDecryptorInterface; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 42 | class PacketRouter; |
| 43 | class ProcessThread; |
| 44 | class RateLimiter; |
| 45 | class ReceiveStatistics; |
| 46 | class RtcEventLog; |
| 47 | class RtpPacketReceived; |
| 48 | class RtpRtcp; |
| 49 | |
| 50 | struct CallReceiveStatistics { |
| 51 | unsigned short fractionLost; // NOLINT |
| 52 | unsigned int cumulativeLost; |
| 53 | unsigned int extendedMax; |
| 54 | unsigned int jitterSamples; |
| 55 | int64_t rttMs; |
| 56 | size_t bytesReceived; |
| 57 | int packetsReceived; |
| 58 | // The capture ntp time (in local timebase) of the first played out audio |
| 59 | // frame. |
| 60 | int64_t capture_start_ntp_time_ms_; |
| 61 | }; |
| 62 | |
| 63 | namespace voe { |
| 64 | |
| 65 | class ChannelSend; |
| 66 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 67 | // Interface class needed for AudioReceiveStream tests that use a |
| 68 | // MockChannelReceive. |
| 69 | |
| 70 | class ChannelReceiveInterface : public RtpPacketSinkInterface { |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 71 | public: |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 72 | virtual ~ChannelReceiveInterface() = default; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 73 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 74 | virtual void SetSink(AudioSinkInterface* sink) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 75 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 76 | virtual void SetReceiveCodecs( |
| 77 | const std::map<int, SdpAudioFormat>& codecs) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 78 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 79 | virtual void StartPlayout() = 0; |
| 80 | virtual void StopPlayout() = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 81 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 82 | virtual bool GetRecCodec(CodecInst* codec) const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 83 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 84 | virtual bool ReceivedRTCPPacket(const uint8_t* data, size_t length) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 85 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 86 | virtual void SetChannelOutputVolumeScaling(float scaling) = 0; |
| 87 | virtual int GetSpeechOutputLevelFullRange() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 88 | // See description of "totalAudioEnergy" in the WebRTC stats spec: |
| 89 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 90 | virtual double GetTotalOutputEnergy() const = 0; |
| 91 | virtual double GetTotalOutputDuration() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 92 | |
| 93 | // Stats. |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 94 | virtual NetworkStatistics GetNetworkStatistics() const = 0; |
| 95 | virtual AudioDecodingCallStats GetDecodingCallStatistics() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 96 | |
| 97 | // Audio+Video Sync. |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 98 | virtual uint32_t GetDelayEstimate() const = 0; |
| 99 | virtual void SetMinimumPlayoutDelay(int delay_ms) = 0; |
| 100 | virtual uint32_t GetPlayoutTimestamp() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 101 | |
| 102 | // Produces the transport-related timestamps; current_delay_ms is left unset. |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 103 | virtual absl::optional<Syncable::Info> GetSyncInfo() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 104 | |
| 105 | // RTP+RTCP |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 106 | virtual void SetLocalSSRC(uint32_t ssrc) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 107 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 108 | virtual void RegisterReceiverCongestionControlObjects( |
| 109 | PacketRouter* packet_router) = 0; |
| 110 | virtual void ResetReceiverCongestionControlObjects() = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 111 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 112 | virtual CallReceiveStatistics GetRTCPStatistics() const = 0; |
| 113 | virtual void SetNACKStatus(bool enable, int max_packets) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 114 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 115 | virtual AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 116 | int sample_rate_hz, |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 117 | AudioFrame* audio_frame) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 118 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 119 | virtual int PreferredSampleRate() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 120 | |
| 121 | // Associate to a send channel. |
| 122 | // Used for obtaining RTT for a receive-only channel. |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 123 | virtual void SetAssociatedSendChannel(const ChannelSend* channel) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 124 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 125 | virtual std::vector<RtpSource> GetSources() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 126 | }; |
| 127 | |
Niels Möller | 349ade3 | 2018-11-16 09:50:42 +0100 | [diff] [blame^] | 128 | std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive( |
| 129 | ProcessThread* module_process_thread, |
| 130 | AudioDeviceModule* audio_device_module, |
| 131 | MediaTransportInterface* media_transport, |
| 132 | Transport* rtcp_send_transport, |
| 133 | RtcEventLog* rtc_event_log, |
| 134 | uint32_t remote_ssrc, |
| 135 | size_t jitter_buffer_max_packets, |
| 136 | bool jitter_buffer_fast_playout, |
| 137 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, |
| 138 | absl::optional<AudioCodecPairId> codec_pair_id, |
| 139 | rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor, |
| 140 | const webrtc::CryptoOptions& crypto_options); |
| 141 | |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 142 | } // namespace voe |
| 143 | } // namespace webrtc |
| 144 | |
| 145 | #endif // AUDIO_CHANNEL_RECEIVE_H_ |