blob: 23a748501438178c1bfce5c1b9330be3a56f7314 [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
kjellandera69d9732016-08-31 07:33:05 -070016#include "webrtc/api/call/audio_send_stream.h"
17#include "webrtc/api/call/audio_state.h"
kwiberg4485ffb2016-04-26 08:14:39 -070018#include "webrtc/base/constructormagic.h"
solenberg85a04962015-10-27 03:35:21 -070019#include "webrtc/base/thread_checker.h"
mflodman86cc6ff2016-07-26 04:44:06 -070020#include "webrtc/call/bitrate_allocator.h"
solenbergc7a8b082015-10-16 14:35:07 -070021
22namespace webrtc {
Stefan Holmerb86d4e42015-12-07 10:26:18 +010023class CongestionController;
solenberg3a941542015-11-16 07:34:50 -080024class VoiceEngine;
tereliuse035e2d2016-09-21 06:51:47 -070025class RtcEventLog;
michaelt9332b7d2016-11-30 07:51:13 -080026class RtcpRttStats;
nisse0245da02016-11-30 03:35:20 -080027class PacketRouter;
solenberg3a941542015-11-16 07:34:50 -080028
solenberg13725082015-11-25 08:16:52 -080029namespace voe {
30class ChannelProxy;
31} // namespace voe
solenbergc7a8b082015-10-16 14:35:07 -070032
solenberg13725082015-11-25 08:16:52 -080033namespace internal {
mflodman86cc6ff2016-07-26 04:44:06 -070034class AudioSendStream final : public webrtc::AudioSendStream,
35 public webrtc::BitrateAllocatorObserver {
solenbergc7a8b082015-10-16 14:35:07 -070036 public:
solenberg85a04962015-10-27 03:35:21 -070037 AudioSendStream(const webrtc::AudioSendStream::Config& config,
Stefan Holmerb86d4e42015-12-07 10:26:18 +010038 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
perkj26091b12016-09-01 01:17:40 -070039 rtc::TaskQueue* worker_queue,
nisse0245da02016-11-30 03:35:20 -080040 PacketRouter* packet_router,
mflodman86cc6ff2016-07-26 04:44:06 -070041 CongestionController* congestion_controller,
tereliuse035e2d2016-09-21 06:51:47 -070042 BitrateAllocator* bitrate_allocator,
michaelt9332b7d2016-11-30 07:51:13 -080043 RtcEventLog* event_log,
44 RtcpRttStats* rtcp_rtt_stats);
solenbergc7a8b082015-10-16 14:35:07 -070045 ~AudioSendStream() override;
46
pbos1ba8d392016-05-01 20:18:34 -070047 // webrtc::AudioSendStream implementation.
solenbergc7a8b082015-10-16 14:35:07 -070048 void Start() override;
49 void Stop() override;
solenbergffbbcac2016-11-17 05:25:37 -080050 bool SendTelephoneEvent(int payload_type, int payload_frequency, int event,
solenberg8842c3e2016-03-11 03:06:41 -080051 int duration_ms) override;
solenberg94218532016-06-16 10:53:22 -070052 void SetMuted(bool muted) override;
solenbergc7a8b082015-10-16 14:35:07 -070053 webrtc::AudioSendStream::Stats GetStats() const override;
54
pbos1ba8d392016-05-01 20:18:34 -070055 void SignalNetworkState(NetworkState state);
56 bool DeliverRtcp(const uint8_t* packet, size_t length);
mflodman86cc6ff2016-07-26 04:44:06 -070057
58 // Implements BitrateAllocatorObserver.
59 uint32_t OnBitrateUpdated(uint32_t bitrate_bps,
60 uint8_t fraction_loss,
minyue78b4d562016-11-30 04:47:39 -080061 int64_t rtt,
62 int64_t probing_interval_ms) override;
mflodman86cc6ff2016-07-26 04:44:06 -070063
solenberg85a04962015-10-27 03:35:21 -070064 const webrtc::AudioSendStream::Config& config() const;
michaelt79e05882016-11-08 02:50:09 -080065 void SetTransportOverhead(int transport_overhead_per_packet);
solenbergc7a8b082015-10-16 14:35:07 -070066
67 private:
solenberg3a941542015-11-16 07:34:50 -080068 VoiceEngine* voice_engine() const;
69
minyue7a973442016-10-20 03:27:12 -070070 bool SetupSendCodec();
71
solenberg85a04962015-10-27 03:35:21 -070072 rtc::ThreadChecker thread_checker_;
perkj26091b12016-09-01 01:17:40 -070073 rtc::TaskQueue* worker_queue_;
solenbergc7a8b082015-10-16 14:35:07 -070074 const webrtc::AudioSendStream::Config config_;
solenberg566ef242015-11-06 15:34:49 -080075 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
kwibergfffa42b2016-02-23 10:46:32 -080076 std::unique_ptr<voe::ChannelProxy> channel_proxy_;
solenberg85a04962015-10-27 03:35:21 -070077
mflodman86cc6ff2016-07-26 04:44:06 -070078 BitrateAllocator* const bitrate_allocator_;
79
solenberg85a04962015-10-27 03:35:21 -070080 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSendStream);
solenbergc7a8b082015-10-16 14:35:07 -070081};
82} // namespace internal
83} // namespace webrtc
84
85#endif // WEBRTC_AUDIO_AUDIO_SEND_STREAM_H_