blob: 82c642a13708490afdaf4f90456a575e4d87cc00 [file] [log] [blame]
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +02001/*
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
Peter Boström5c389d32015-09-25 13:58:30 +020011#ifndef WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_
12#define WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020013
kwibergfffa42b2016-02-23 10:46:32 -080014#include <memory>
15
aleloiaed581a2016-10-20 06:32:39 -070016#include "webrtc/api/audio/audio_mixer.h"
kjellandera69d9732016-08-31 07:33:05 -070017#include "webrtc/api/call/audio_receive_stream.h"
18#include "webrtc/api/call/audio_state.h"
kwiberg4485ffb2016-04-26 08:14:39 -070019#include "webrtc/base/constructormagic.h"
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020020#include "webrtc/base/thread_checker.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010021#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020022
23namespace webrtc {
Stefan Holmer3842c5c2016-01-12 13:55:00 +010024class CongestionController;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020025class RemoteBitrateEstimator;
ivoc14d5dbe2016-07-04 07:06:55 -070026class RtcEventLog;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020027
solenberg13725082015-11-25 08:16:52 -080028namespace voe {
29class ChannelProxy;
30} // namespace voe
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020031
solenberg13725082015-11-25 08:16:52 -080032namespace internal {
Tommif888bb52015-12-12 01:37:01 +010033
aleloiaed581a2016-10-20 06:32:39 -070034class AudioReceiveStream final : public webrtc::AudioReceiveStream,
35 public AudioMixer::Source {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020036 public:
Stefan Holmer3842c5c2016-01-12 13:55:00 +010037 AudioReceiveStream(CongestionController* congestion_controller,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020038 const webrtc::AudioReceiveStream::Config& config,
ivoc14d5dbe2016-07-04 07:06:55 -070039 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
40 webrtc::RtcEventLog* event_log);
pbosa2f30de2015-10-15 05:22:13 -070041 ~AudioReceiveStream() override;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020042
pbos1ba8d392016-05-01 20:18:34 -070043 // webrtc::AudioReceiveStream implementation.
Jelena Marusiccd670222015-07-16 09:30:09 +020044 void Start() override;
45 void Stop() override;
Jelena Marusiccd670222015-07-16 09:30:09 +020046 webrtc::AudioReceiveStream::Stats GetStats() const override;
kwibergfffa42b2016-02-23 10:46:32 -080047 void SetSink(std::unique_ptr<AudioSinkInterface> sink) override;
solenberg217fb662016-06-17 08:30:54 -070048 void SetGain(float gain) override;
Tommif888bb52015-12-12 01:37:01 +010049
pbos1ba8d392016-05-01 20:18:34 -070050 void SignalNetworkState(NetworkState state);
51 bool DeliverRtcp(const uint8_t* packet, size_t length);
52 bool DeliverRtp(const uint8_t* packet,
53 size_t length,
54 const PacketTime& packet_time);
pbosa2f30de2015-10-15 05:22:13 -070055 const webrtc::AudioReceiveStream::Config& config() const;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020056
aleloiaed581a2016-10-20 06:32:39 -070057 // AudioMixer::Source
58 AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) override;
59 int Ssrc() override;
60
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020061 private:
solenberg7add0582015-11-20 09:59:34 -080062 VoiceEngine* voice_engine() const;
63
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020064 rtc::ThreadChecker thread_checker_;
Stefan Holmer3842c5c2016-01-12 13:55:00 +010065 RemoteBitrateEstimator* remote_bitrate_estimator_ = nullptr;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020066 const webrtc::AudioReceiveStream::Config config_;
solenberg566ef242015-11-06 15:34:49 -080067 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
kwibergfffa42b2016-02-23 10:46:32 -080068 std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
69 std::unique_ptr<voe::ChannelProxy> channel_proxy_;
solenberg85a04962015-10-27 03:35:21 -070070
71 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioReceiveStream);
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020072};
73} // namespace internal
74} // namespace webrtc
75
Peter Boström5c389d32015-09-25 13:58:30 +020076#endif // WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_