blob: bb619cf2b5496266224f7d96e62ca1552a846d6e [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;
solenberg3a941542015-11-16 07:34:50 -080026
solenberg13725082015-11-25 08:16:52 -080027namespace voe {
28class ChannelProxy;
29} // namespace voe
solenbergc7a8b082015-10-16 14:35:07 -070030
solenberg13725082015-11-25 08:16:52 -080031namespace internal {
mflodman86cc6ff2016-07-26 04:44:06 -070032class AudioSendStream final : public webrtc::AudioSendStream,
33 public webrtc::BitrateAllocatorObserver {
solenbergc7a8b082015-10-16 14:35:07 -070034 public:
solenberg85a04962015-10-27 03:35:21 -070035 AudioSendStream(const webrtc::AudioSendStream::Config& config,
Stefan Holmerb86d4e42015-12-07 10:26:18 +010036 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
perkj26091b12016-09-01 01:17:40 -070037 rtc::TaskQueue* worker_queue,
mflodman86cc6ff2016-07-26 04:44:06 -070038 CongestionController* congestion_controller,
tereliuse035e2d2016-09-21 06:51:47 -070039 BitrateAllocator* bitrate_allocator,
sprang982bf892016-10-13 06:23:11 -070040 RtcEventLog* event_log);
solenbergc7a8b082015-10-16 14:35:07 -070041 ~AudioSendStream() override;
42
pbos1ba8d392016-05-01 20:18:34 -070043 // webrtc::AudioSendStream implementation.
solenbergc7a8b082015-10-16 14:35:07 -070044 void Start() override;
45 void Stop() override;
solenberg8842c3e2016-03-11 03:06:41 -080046 bool SendTelephoneEvent(int payload_type, int event,
47 int duration_ms) override;
solenberg94218532016-06-16 10:53:22 -070048 void SetMuted(bool muted) override;
solenbergc7a8b082015-10-16 14:35:07 -070049 webrtc::AudioSendStream::Stats GetStats() const override;
50
pbos1ba8d392016-05-01 20:18:34 -070051 void SignalNetworkState(NetworkState state);
52 bool DeliverRtcp(const uint8_t* packet, size_t length);
mflodman86cc6ff2016-07-26 04:44:06 -070053
54 // Implements BitrateAllocatorObserver.
55 uint32_t OnBitrateUpdated(uint32_t bitrate_bps,
56 uint8_t fraction_loss,
57 int64_t rtt) override;
58
solenberg85a04962015-10-27 03:35:21 -070059 const webrtc::AudioSendStream::Config& config() const;
michaelt79e05882016-11-08 02:50:09 -080060 void SetTransportOverhead(int transport_overhead_per_packet);
solenbergc7a8b082015-10-16 14:35:07 -070061
62 private:
solenberg3a941542015-11-16 07:34:50 -080063 VoiceEngine* voice_engine() const;
64
minyue7a973442016-10-20 03:27:12 -070065 bool SetupSendCodec();
66
solenberg85a04962015-10-27 03:35:21 -070067 rtc::ThreadChecker thread_checker_;
perkj26091b12016-09-01 01:17:40 -070068 rtc::TaskQueue* worker_queue_;
solenbergc7a8b082015-10-16 14:35:07 -070069 const webrtc::AudioSendStream::Config config_;
solenberg566ef242015-11-06 15:34:49 -080070 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
kwibergfffa42b2016-02-23 10:46:32 -080071 std::unique_ptr<voe::ChannelProxy> channel_proxy_;
solenberg85a04962015-10-27 03:35:21 -070072
mflodman86cc6ff2016-07-26 04:44:06 -070073 BitrateAllocator* const bitrate_allocator_;
74
solenberg85a04962015-10-27 03:35:21 -070075 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSendStream);
solenbergc7a8b082015-10-16 14:35:07 -070076};
77} // namespace internal
78} // namespace webrtc
79
80#endif // WEBRTC_AUDIO_AUDIO_SEND_STREAM_H_