blob: d16167f9bb15bfff51e0be616531fd938a1c930c [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
48void ChannelProxy::SetSendAbsoluteSenderTimeStatus(bool enable, int id) {
49 RTC_DCHECK(thread_checker_.CalledOnValidThread());
50 int error = channel()->SetSendAbsoluteSenderTimeStatus(enable, id);
51 RTC_DCHECK_EQ(0, error);
52}
53
54void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
55 RTC_DCHECK(thread_checker_.CalledOnValidThread());
56 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
57 RTC_DCHECK_EQ(0, error);
58}
59
60void ChannelProxy::SetReceiveAbsoluteSenderTimeStatus(bool enable, int id) {
61 RTC_DCHECK(thread_checker_.CalledOnValidThread());
62 int error = channel()->SetReceiveAbsoluteSenderTimeStatus(enable, id);
63 RTC_DCHECK_EQ(0, error);
64}
65
66void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
67 RTC_DCHECK(thread_checker_.CalledOnValidThread());
68 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
69 RTC_DCHECK_EQ(0, error);
70}
71
stefan3313ec92016-01-21 06:32:43 -080072void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
73 RTC_DCHECK(thread_checker_.CalledOnValidThread());
74 channel()->EnableSendTransportSequenceNumber(id);
75}
76
77void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
78 RTC_DCHECK(thread_checker_.CalledOnValidThread());
79 channel()->EnableReceiveTransportSequenceNumber(id);
80}
81
stefanbba9dec2016-02-01 04:39:55 -080082void ChannelProxy::RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010083 RtpPacketSender* rtp_packet_sender,
84 TransportFeedbackObserver* transport_feedback_observer,
85 PacketRouter* packet_router) {
86 RTC_DCHECK(thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080087 channel()->RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010088 rtp_packet_sender, transport_feedback_observer, packet_router);
89}
90
stefanbba9dec2016-02-01 04:39:55 -080091void ChannelProxy::RegisterReceiverCongestionControlObjects(
92 PacketRouter* packet_router) {
93 RTC_DCHECK(thread_checker_.CalledOnValidThread());
94 channel()->RegisterReceiverCongestionControlObjects(packet_router);
95}
96
97void ChannelProxy::ResetCongestionControlObjects() {
98 RTC_DCHECK(thread_checker_.CalledOnValidThread());
99 channel()->ResetCongestionControlObjects();
100}
101
solenberg358057b2015-11-27 10:46:42 -0800102CallStatistics ChannelProxy::GetRTCPStatistics() const {
103 RTC_DCHECK(thread_checker_.CalledOnValidThread());
104 CallStatistics stats = {0};
105 int error = channel()->GetRTPStatistics(stats);
106 RTC_DCHECK_EQ(0, error);
107 return stats;
108}
109
110std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
111 RTC_DCHECK(thread_checker_.CalledOnValidThread());
112 std::vector<webrtc::ReportBlock> blocks;
113 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
114 RTC_DCHECK_EQ(0, error);
115 return blocks;
116}
117
118NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
119 RTC_DCHECK(thread_checker_.CalledOnValidThread());
120 NetworkStatistics stats = {0};
121 int error = channel()->GetNetworkStatistics(stats);
122 RTC_DCHECK_EQ(0, error);
123 return stats;
124}
125
126AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
127 RTC_DCHECK(thread_checker_.CalledOnValidThread());
128 AudioDecodingCallStats stats;
129 channel()->GetDecodingCallStatistics(&stats);
130 return stats;
131}
132
133int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
134 RTC_DCHECK(thread_checker_.CalledOnValidThread());
135 uint32_t level = 0;
136 int error = channel()->GetSpeechOutputLevelFullRange(level);
137 RTC_DCHECK_EQ(0, error);
138 return static_cast<int32_t>(level);
139}
140
141uint32_t ChannelProxy::GetDelayEstimate() const {
142 RTC_DCHECK(thread_checker_.CalledOnValidThread());
143 return channel()->GetDelayEstimate();
144}
145
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100146bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
147 RTC_DCHECK(thread_checker_.CalledOnValidThread());
148 return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
149}
150
solenberg8842c3e2016-03-11 03:06:41 -0800151bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100152 RTC_DCHECK(thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800153 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100154}
155
kwibergb7f89d62016-02-17 10:04:18 -0800156void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
Tommif888bb52015-12-12 01:37:01 +0100157 RTC_DCHECK(thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800158 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100159}
160
mflodman3d7db262016-04-29 00:57:13 -0700161void ChannelProxy::RegisterExternalTransport(Transport* transport) {
162 RTC_DCHECK(thread_checker_.CalledOnValidThread());
163 int error = channel()->RegisterExternalTransport(transport);
164 RTC_DCHECK_EQ(0, error);
165}
166
167void ChannelProxy::DeRegisterExternalTransport() {
168 RTC_DCHECK(thread_checker_.CalledOnValidThread());
169 channel()->DeRegisterExternalTransport();
170}
171
172bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet,
173 size_t length,
174 const PacketTime& packet_time) {
175 // May be called on either worker thread or network thread.
176 return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0;
177}
178
179bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
180 // May be called on either worker thread or network thread.
181 return channel()->ReceivedRTCPPacket(packet, length) == 0;
182}
183
ossu29b1a8d2016-06-13 07:34:51 -0700184const rtc::scoped_refptr<AudioDecoderFactory>&
185ChannelProxy::GetAudioDecoderFactory() const {
186 return channel()->GetAudioDecoderFactory();
187}
188
solenberg358057b2015-11-27 10:46:42 -0800189Channel* ChannelProxy::channel() const {
190 RTC_DCHECK(channel_owner_.channel());
191 return channel_owner_.channel();
192}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100193
solenberg13725082015-11-25 08:16:52 -0800194} // namespace voe
195} // namespace webrtc