Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 1 | /* |
| 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öm | 5c389d3 | 2015-09-25 13:58:30 +0200 | [diff] [blame] | 11 | #ifndef WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_ |
| 12 | #define WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_ |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 13 | |
kwiberg | fffa42b | 2016-02-23 10:46:32 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 16 | #include "webrtc/api/audio/audio_mixer.h" |
kjellander | a69d973 | 2016-08-31 07:33:05 -0700 | [diff] [blame] | 17 | #include "webrtc/api/call/audio_receive_stream.h" |
| 18 | #include "webrtc/api/call/audio_state.h" |
aleloi | 04c0722 | 2016-11-22 06:42:53 -0800 | [diff] [blame^] | 19 | #include "webrtc/audio/audio_state.h" |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 20 | #include "webrtc/base/constructormagic.h" |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 21 | #include "webrtc/base/thread_checker.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 22 | #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
Stefan Holmer | 3842c5c | 2016-01-12 13:55:00 +0100 | [diff] [blame] | 25 | class CongestionController; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 26 | class RemoteBitrateEstimator; |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 27 | class RtcEventLog; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 28 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 29 | namespace voe { |
| 30 | class ChannelProxy; |
| 31 | } // namespace voe |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 32 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 33 | namespace internal { |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 34 | class AudioSendStream; |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 35 | |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 36 | class AudioReceiveStream final : public webrtc::AudioReceiveStream, |
| 37 | public AudioMixer::Source { |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 38 | public: |
Stefan Holmer | 3842c5c | 2016-01-12 13:55:00 +0100 | [diff] [blame] | 39 | AudioReceiveStream(CongestionController* congestion_controller, |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 40 | const webrtc::AudioReceiveStream::Config& config, |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 41 | const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 42 | webrtc::RtcEventLog* event_log); |
pbos | a2f30de | 2015-10-15 05:22:13 -0700 | [diff] [blame] | 43 | ~AudioReceiveStream() override; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 44 | |
pbos | 1ba8d39 | 2016-05-01 20:18:34 -0700 | [diff] [blame] | 45 | // webrtc::AudioReceiveStream implementation. |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 46 | void Start() override; |
| 47 | void Stop() override; |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 48 | webrtc::AudioReceiveStream::Stats GetStats() const override; |
kwiberg | fffa42b | 2016-02-23 10:46:32 -0800 | [diff] [blame] | 49 | void SetSink(std::unique_ptr<AudioSinkInterface> sink) override; |
solenberg | 217fb66 | 2016-06-17 08:30:54 -0700 | [diff] [blame] | 50 | void SetGain(float gain) override; |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 51 | |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 52 | void AssociateSendStream(AudioSendStream* send_stream); |
pbos | 1ba8d39 | 2016-05-01 20:18:34 -0700 | [diff] [blame] | 53 | 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); |
pbos | a2f30de | 2015-10-15 05:22:13 -0700 | [diff] [blame] | 58 | const webrtc::AudioReceiveStream::Config& config() const; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 59 | |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 60 | // AudioMixer::Source |
aleloi | 6c27849 | 2016-10-20 14:24:39 -0700 | [diff] [blame] | 61 | AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz, |
| 62 | AudioFrame* audio_frame) override; |
aleloi | 051f678 | 2016-10-31 03:26:40 -0700 | [diff] [blame] | 63 | int PreferredSampleRate() const override; |
| 64 | int Ssrc() const override; |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 65 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 66 | private: |
solenberg | 7add058 | 2015-11-20 09:59:34 -0800 | [diff] [blame] | 67 | VoiceEngine* voice_engine() const; |
aleloi | 04c0722 | 2016-11-22 06:42:53 -0800 | [diff] [blame^] | 68 | AudioState* audio_state() const; |
| 69 | int SetVoiceEnginePlayout(bool playout); |
solenberg | 7add058 | 2015-11-20 09:59:34 -0800 | [diff] [blame] | 70 | |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 71 | rtc::ThreadChecker thread_checker_; |
Stefan Holmer | 3842c5c | 2016-01-12 13:55:00 +0100 | [diff] [blame] | 72 | RemoteBitrateEstimator* remote_bitrate_estimator_ = nullptr; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 73 | const webrtc::AudioReceiveStream::Config config_; |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 74 | rtc::scoped_refptr<webrtc::AudioState> audio_state_; |
kwiberg | fffa42b | 2016-02-23 10:46:32 -0800 | [diff] [blame] | 75 | std::unique_ptr<RtpHeaderParser> rtp_header_parser_; |
| 76 | std::unique_ptr<voe::ChannelProxy> channel_proxy_; |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 77 | |
aleloi | 04c0722 | 2016-11-22 06:42:53 -0800 | [diff] [blame^] | 78 | bool playing_ ACCESS_ON(thread_checker_) = false; |
| 79 | |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 80 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioReceiveStream); |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 81 | }; |
| 82 | } // namespace internal |
| 83 | } // namespace webrtc |
| 84 | |
Peter Boström | 5c389d3 | 2015-09-25 13:58:30 +0200 | [diff] [blame] | 85 | #endif // WEBRTC_AUDIO_AUDIO_RECEIVE_STREAM_H_ |