blob: e148649aa3ab2c9731f6fc602a37061a5f67e26a [file] [log] [blame]
solenberg13725082015-11-25 08:16:52 -08001/*
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#include "webrtc/voice_engine/channel_proxy.h"
12
Tommif888bb52015-12-12 01:37:01 +010013#include <utility>
14
kjellander@webrtc.org7ffeab52016-02-26 22:46:09 +010015#include "webrtc/audio_sink.h"
solenberg13725082015-11-25 08:16:52 -080016#include "webrtc/base/checks.h"
17#include "webrtc/voice_engine/channel.h"
18
19namespace webrtc {
20namespace voe {
21ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
22
23ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
24 channel_owner_(channel_owner) {
25 RTC_CHECK(channel_owner_.channel());
26}
27
Tommif888bb52015-12-12 01:37:01 +010028ChannelProxy::~ChannelProxy() {}
29
solenberg13725082015-11-25 08:16:52 -080030void ChannelProxy::SetRTCPStatus(bool enable) {
solenberg358057b2015-11-27 10:46:42 -080031 channel()->SetRTCPStatus(enable);
solenberg13725082015-11-25 08:16:52 -080032}
33
34void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
solenberg358057b2015-11-27 10:46:42 -080035 RTC_DCHECK(thread_checker_.CalledOnValidThread());
36 int error = channel()->SetLocalSSRC(ssrc);
solenberg13725082015-11-25 08:16:52 -080037 RTC_DCHECK_EQ(0, error);
38}
39
40void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
solenberg358057b2015-11-27 10:46:42 -080041 RTC_DCHECK(thread_checker_.CalledOnValidThread());
solenberg13725082015-11-25 08:16:52 -080042 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
43 std::string c_name_limited = c_name.substr(0, 255);
solenberg358057b2015-11-27 10:46:42 -080044 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
solenberg13725082015-11-25 08:16:52 -080045 RTC_DCHECK_EQ(0, error);
46}
solenberg358057b2015-11-27 10:46:42 -080047
solenberg971cab02016-06-14 10:02:41 -070048void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
49 RTC_DCHECK(thread_checker_.CalledOnValidThread());
50 channel()->SetNACKStatus(enable, max_packets);
51}
52
solenberg358057b2015-11-27 10:46:42 -080053void ChannelProxy::SetSendAbsoluteSenderTimeStatus(bool enable, int id) {
54 RTC_DCHECK(thread_checker_.CalledOnValidThread());
55 int error = channel()->SetSendAbsoluteSenderTimeStatus(enable, id);
56 RTC_DCHECK_EQ(0, error);
57}
58
59void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
62 RTC_DCHECK_EQ(0, error);
63}
64
65void ChannelProxy::SetReceiveAbsoluteSenderTimeStatus(bool enable, int id) {
66 RTC_DCHECK(thread_checker_.CalledOnValidThread());
67 int error = channel()->SetReceiveAbsoluteSenderTimeStatus(enable, id);
68 RTC_DCHECK_EQ(0, error);
69}
70
71void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
72 RTC_DCHECK(thread_checker_.CalledOnValidThread());
73 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
74 RTC_DCHECK_EQ(0, error);
75}
76
stefan3313ec92016-01-21 06:32:43 -080077void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
78 RTC_DCHECK(thread_checker_.CalledOnValidThread());
79 channel()->EnableSendTransportSequenceNumber(id);
80}
81
82void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
83 RTC_DCHECK(thread_checker_.CalledOnValidThread());
84 channel()->EnableReceiveTransportSequenceNumber(id);
85}
86
stefanbba9dec2016-02-01 04:39:55 -080087void ChannelProxy::RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010088 RtpPacketSender* rtp_packet_sender,
89 TransportFeedbackObserver* transport_feedback_observer,
90 PacketRouter* packet_router) {
91 RTC_DCHECK(thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080092 channel()->RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010093 rtp_packet_sender, transport_feedback_observer, packet_router);
94}
95
stefanbba9dec2016-02-01 04:39:55 -080096void ChannelProxy::RegisterReceiverCongestionControlObjects(
97 PacketRouter* packet_router) {
98 RTC_DCHECK(thread_checker_.CalledOnValidThread());
99 channel()->RegisterReceiverCongestionControlObjects(packet_router);
100}
101
102void ChannelProxy::ResetCongestionControlObjects() {
103 RTC_DCHECK(thread_checker_.CalledOnValidThread());
104 channel()->ResetCongestionControlObjects();
105}
106
solenberg358057b2015-11-27 10:46:42 -0800107CallStatistics ChannelProxy::GetRTCPStatistics() const {
108 RTC_DCHECK(thread_checker_.CalledOnValidThread());
109 CallStatistics stats = {0};
110 int error = channel()->GetRTPStatistics(stats);
111 RTC_DCHECK_EQ(0, error);
112 return stats;
113}
114
115std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
116 RTC_DCHECK(thread_checker_.CalledOnValidThread());
117 std::vector<webrtc::ReportBlock> blocks;
118 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
119 RTC_DCHECK_EQ(0, error);
120 return blocks;
121}
122
123NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
124 RTC_DCHECK(thread_checker_.CalledOnValidThread());
125 NetworkStatistics stats = {0};
126 int error = channel()->GetNetworkStatistics(stats);
127 RTC_DCHECK_EQ(0, error);
128 return stats;
129}
130
131AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
132 RTC_DCHECK(thread_checker_.CalledOnValidThread());
133 AudioDecodingCallStats stats;
134 channel()->GetDecodingCallStatistics(&stats);
135 return stats;
136}
137
138int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
139 RTC_DCHECK(thread_checker_.CalledOnValidThread());
140 uint32_t level = 0;
141 int error = channel()->GetSpeechOutputLevelFullRange(level);
142 RTC_DCHECK_EQ(0, error);
143 return static_cast<int32_t>(level);
144}
145
146uint32_t ChannelProxy::GetDelayEstimate() const {
147 RTC_DCHECK(thread_checker_.CalledOnValidThread());
148 return channel()->GetDelayEstimate();
149}
150
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100151bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
152 RTC_DCHECK(thread_checker_.CalledOnValidThread());
153 return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
154}
155
solenberg8842c3e2016-03-11 03:06:41 -0800156bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100157 RTC_DCHECK(thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800158 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100159}
160
kwibergb7f89d62016-02-17 10:04:18 -0800161void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
Tommif888bb52015-12-12 01:37:01 +0100162 RTC_DCHECK(thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800163 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100164}
165
mflodman3d7db262016-04-29 00:57:13 -0700166void ChannelProxy::RegisterExternalTransport(Transport* transport) {
167 RTC_DCHECK(thread_checker_.CalledOnValidThread());
168 int error = channel()->RegisterExternalTransport(transport);
169 RTC_DCHECK_EQ(0, error);
170}
171
172void ChannelProxy::DeRegisterExternalTransport() {
173 RTC_DCHECK(thread_checker_.CalledOnValidThread());
174 channel()->DeRegisterExternalTransport();
175}
176
177bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet,
178 size_t length,
179 const PacketTime& packet_time) {
180 // May be called on either worker thread or network thread.
181 return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0;
182}
183
184bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
185 // May be called on either worker thread or network thread.
186 return channel()->ReceivedRTCPPacket(packet, length) == 0;
187}
188
ossu29b1a8d2016-06-13 07:34:51 -0700189const rtc::scoped_refptr<AudioDecoderFactory>&
190ChannelProxy::GetAudioDecoderFactory() const {
191 return channel()->GetAudioDecoderFactory();
192}
193
solenberg358057b2015-11-27 10:46:42 -0800194Channel* ChannelProxy::channel() const {
195 RTC_DCHECK(channel_owner_.channel());
196 return channel_owner_.channel();
197}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100198
solenberg13725082015-11-25 08:16:52 -0800199} // namespace voe
200} // namespace webrtc