blob: 436c49824cc2325921c560e59f2f56bc3d439f99 [file] [log] [blame]
solenbergc7a8b082015-10-16 14:35:07 -07001/*
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
11#ifndef WEBRTC_AUDIO_AUDIO_SEND_STREAM_H_
12#define WEBRTC_AUDIO_AUDIO_SEND_STREAM_H_
13
kwibergfffa42b2016-02-23 10:46:32 -080014#include <memory>
15
kwiberg4485ffb2016-04-26 08:14:39 -070016#include "webrtc/base/constructormagic.h"
solenberg85a04962015-10-27 03:35:21 -070017#include "webrtc/base/thread_checker.h"
ossuf515ab82016-12-07 04:52:58 -080018#include "webrtc/call/audio_send_stream.h"
19#include "webrtc/call/audio_state.h"
mflodman86cc6ff2016-07-26 04:44:06 -070020#include "webrtc/call/bitrate_allocator.h"
solenbergc7a8b082015-10-16 14:35:07 -070021
22namespace webrtc {
nisse559af382017-03-21 06:41:12 -070023class SendSideCongestionController;
solenberg3a941542015-11-16 07:34:50 -080024class VoiceEngine;
tereliuse035e2d2016-09-21 06:51:47 -070025class RtcEventLog;
stefan7de8d642017-02-07 07:14:08 -080026class RtcpBandwidthObserver;
michaelt9332b7d2016-11-30 07:51:13 -080027class RtcpRttStats;
nisse0245da02016-11-30 03:35:20 -080028class PacketRouter;
solenberg3a941542015-11-16 07:34:50 -080029
solenberg13725082015-11-25 08:16:52 -080030namespace voe {
31class ChannelProxy;
32} // namespace voe
solenbergc7a8b082015-10-16 14:35:07 -070033
solenberg13725082015-11-25 08:16:52 -080034namespace internal {
mflodman86cc6ff2016-07-26 04:44:06 -070035class AudioSendStream final : public webrtc::AudioSendStream,
36 public webrtc::BitrateAllocatorObserver {
solenbergc7a8b082015-10-16 14:35:07 -070037 public:
solenberg85a04962015-10-27 03:35:21 -070038 AudioSendStream(const webrtc::AudioSendStream::Config& config,
Stefan Holmerb86d4e42015-12-07 10:26:18 +010039 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
perkj26091b12016-09-01 01:17:40 -070040 rtc::TaskQueue* worker_queue,
nisse0245da02016-11-30 03:35:20 -080041 PacketRouter* packet_router,
nisse559af382017-03-21 06:41:12 -070042 SendSideCongestionController* send_side_cc,
tereliuse035e2d2016-09-21 06:51:47 -070043 BitrateAllocator* bitrate_allocator,
michaelt9332b7d2016-11-30 07:51:13 -080044 RtcEventLog* event_log,
45 RtcpRttStats* rtcp_rtt_stats);
solenbergc7a8b082015-10-16 14:35:07 -070046 ~AudioSendStream() override;
47
pbos1ba8d392016-05-01 20:18:34 -070048 // webrtc::AudioSendStream implementation.
solenbergc7a8b082015-10-16 14:35:07 -070049 void Start() override;
50 void Stop() override;
solenbergffbbcac2016-11-17 05:25:37 -080051 bool SendTelephoneEvent(int payload_type, int payload_frequency, int event,
solenberg8842c3e2016-03-11 03:06:41 -080052 int duration_ms) override;
solenberg94218532016-06-16 10:53:22 -070053 void SetMuted(bool muted) override;
solenbergc7a8b082015-10-16 14:35:07 -070054 webrtc::AudioSendStream::Stats GetStats() const override;
55
pbos1ba8d392016-05-01 20:18:34 -070056 void SignalNetworkState(NetworkState state);
57 bool DeliverRtcp(const uint8_t* packet, size_t length);
mflodman86cc6ff2016-07-26 04:44:06 -070058
59 // Implements BitrateAllocatorObserver.
60 uint32_t OnBitrateUpdated(uint32_t bitrate_bps,
61 uint8_t fraction_loss,
minyue78b4d562016-11-30 04:47:39 -080062 int64_t rtt,
63 int64_t probing_interval_ms) override;
mflodman86cc6ff2016-07-26 04:44:06 -070064
solenberg85a04962015-10-27 03:35:21 -070065 const webrtc::AudioSendStream::Config& config() const;
michaelt79e05882016-11-08 02:50:09 -080066 void SetTransportOverhead(int transport_overhead_per_packet);
solenbergc7a8b082015-10-16 14:35:07 -070067
68 private:
solenberg3a941542015-11-16 07:34:50 -080069 VoiceEngine* voice_engine() const;
70
minyue7a973442016-10-20 03:27:12 -070071 bool SetupSendCodec();
72
solenberg85a04962015-10-27 03:35:21 -070073 rtc::ThreadChecker thread_checker_;
perkj26091b12016-09-01 01:17:40 -070074 rtc::TaskQueue* worker_queue_;
solenbergc7a8b082015-10-16 14:35:07 -070075 const webrtc::AudioSendStream::Config config_;
solenberg566ef242015-11-06 15:34:49 -080076 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
kwibergfffa42b2016-02-23 10:46:32 -080077 std::unique_ptr<voe::ChannelProxy> channel_proxy_;
solenberg85a04962015-10-27 03:35:21 -070078
mflodman86cc6ff2016-07-26 04:44:06 -070079 BitrateAllocator* const bitrate_allocator_;
nisse559af382017-03-21 06:41:12 -070080 SendSideCongestionController* const send_side_cc_;
stefan7de8d642017-02-07 07:14:08 -080081 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
mflodman86cc6ff2016-07-26 04:44:06 -070082
solenberg85a04962015-10-27 03:35:21 -070083 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSendStream);
solenbergc7a8b082015-10-16 14:35:07 -070084};
85} // namespace internal
86} // namespace webrtc
87
88#endif // WEBRTC_AUDIO_AUDIO_SEND_STREAM_H_