blob: 6e7da09d1ddf42d3b3916f312175af7f5db60bf3 [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"
aleloi04c07222016-11-22 06:42:53 -080019#include "webrtc/audio/audio_state.h"
kwiberg4485ffb2016-04-26 08:14:39 -070020#include "webrtc/base/constructormagic.h"
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020021#include "webrtc/base/thread_checker.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010022#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020023
24namespace webrtc {
Stefan Holmer3842c5c2016-01-12 13:55:00 +010025class CongestionController;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020026class RemoteBitrateEstimator;
ivoc14d5dbe2016-07-04 07:06:55 -070027class RtcEventLog;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020028
solenberg13725082015-11-25 08:16:52 -080029namespace voe {
30class ChannelProxy;
31} // namespace voe
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020032
solenberg13725082015-11-25 08:16:52 -080033namespace internal {
solenberg7602aab2016-11-14 11:30:07 -080034class AudioSendStream;
Tommif888bb52015-12-12 01:37:01 +010035
aleloiaed581a2016-10-20 06:32:39 -070036class AudioReceiveStream final : public webrtc::AudioReceiveStream,
37 public AudioMixer::Source {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020038 public:
Stefan Holmer3842c5c2016-01-12 13:55:00 +010039 AudioReceiveStream(CongestionController* congestion_controller,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020040 const webrtc::AudioReceiveStream::Config& config,
ivoc14d5dbe2016-07-04 07:06:55 -070041 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
42 webrtc::RtcEventLog* event_log);
pbosa2f30de2015-10-15 05:22:13 -070043 ~AudioReceiveStream() override;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020044
pbos1ba8d392016-05-01 20:18:34 -070045 // webrtc::AudioReceiveStream implementation.
Jelena Marusiccd670222015-07-16 09:30:09 +020046 void Start() override;
47 void Stop() override;
Jelena Marusiccd670222015-07-16 09:30:09 +020048 webrtc::AudioReceiveStream::Stats GetStats() const override;
kwibergfffa42b2016-02-23 10:46:32 -080049 void SetSink(std::unique_ptr<AudioSinkInterface> sink) override;
solenberg217fb662016-06-17 08:30:54 -070050 void SetGain(float gain) override;
Tommif888bb52015-12-12 01:37:01 +010051
solenberg7602aab2016-11-14 11:30:07 -080052 void AssociateSendStream(AudioSendStream* send_stream);
pbos1ba8d392016-05-01 20:18:34 -070053 void SignalNetworkState(NetworkState state);
54 bool DeliverRtcp(const uint8_t* packet, size_t length);
55 bool DeliverRtp(const uint8_t* packet,
56 size_t length,
57 const PacketTime& packet_time);
pbosa2f30de2015-10-15 05:22:13 -070058 const webrtc::AudioReceiveStream::Config& config() const;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020059
aleloiaed581a2016-10-20 06:32:39 -070060 // AudioMixer::Source
aleloi6c278492016-10-20 14:24:39 -070061 AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
62 AudioFrame* audio_frame) override;
aleloi051f6782016-10-31 03:26:40 -070063 int PreferredSampleRate() const override;
64 int Ssrc() const override;
aleloiaed581a2016-10-20 06:32:39 -070065
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020066 private:
solenberg7add0582015-11-20 09:59:34 -080067 VoiceEngine* voice_engine() const;
aleloi04c07222016-11-22 06:42:53 -080068 AudioState* audio_state() const;
69 int SetVoiceEnginePlayout(bool playout);
solenberg7add0582015-11-20 09:59:34 -080070
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020071 rtc::ThreadChecker thread_checker_;
Stefan Holmer3842c5c2016-01-12 13:55:00 +010072 RemoteBitrateEstimator* remote_bitrate_estimator_ = nullptr;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020073 const webrtc::AudioReceiveStream::Config config_;
solenberg566ef242015-11-06 15:34:49 -080074 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
kwibergfffa42b2016-02-23 10:46:32 -080075 std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
76 std::unique_ptr<voe::ChannelProxy> channel_proxy_;
solenberg85a04962015-10-27 03:35:21 -070077
aleloi04c07222016-11-22 06:42:53 -080078 bool playing_ ACCESS_ON(thread_checker_) = false;
79
solenberg85a04962015-10-27 03:35:21 -070080 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioReceiveStream);
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020081};
82} // namespace internal
83} // namespace webrtc
84
Peter Boström5c389d32015-09-25 13:58:30 +020085#endif // WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_