blob: 15a21512fb819aebcc07e0e0c81e9bc98302576a [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
15#include "webrtc/audio/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
Stefan Holmerb86d4e42015-12-07 10:26:18 +010082void ChannelProxy::SetCongestionControlObjects(
83 RtpPacketSender* rtp_packet_sender,
84 TransportFeedbackObserver* transport_feedback_observer,
85 PacketRouter* packet_router) {
86 RTC_DCHECK(thread_checker_.CalledOnValidThread());
87 channel()->SetCongestionControlObjects(
88 rtp_packet_sender, transport_feedback_observer, packet_router);
89}
90
solenberg358057b2015-11-27 10:46:42 -080091CallStatistics ChannelProxy::GetRTCPStatistics() const {
92 RTC_DCHECK(thread_checker_.CalledOnValidThread());
93 CallStatistics stats = {0};
94 int error = channel()->GetRTPStatistics(stats);
95 RTC_DCHECK_EQ(0, error);
96 return stats;
97}
98
99std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
100 RTC_DCHECK(thread_checker_.CalledOnValidThread());
101 std::vector<webrtc::ReportBlock> blocks;
102 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
103 RTC_DCHECK_EQ(0, error);
104 return blocks;
105}
106
107NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
108 RTC_DCHECK(thread_checker_.CalledOnValidThread());
109 NetworkStatistics stats = {0};
110 int error = channel()->GetNetworkStatistics(stats);
111 RTC_DCHECK_EQ(0, error);
112 return stats;
113}
114
115AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
116 RTC_DCHECK(thread_checker_.CalledOnValidThread());
117 AudioDecodingCallStats stats;
118 channel()->GetDecodingCallStatistics(&stats);
119 return stats;
120}
121
122int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
123 RTC_DCHECK(thread_checker_.CalledOnValidThread());
124 uint32_t level = 0;
125 int error = channel()->GetSpeechOutputLevelFullRange(level);
126 RTC_DCHECK_EQ(0, error);
127 return static_cast<int32_t>(level);
128}
129
130uint32_t ChannelProxy::GetDelayEstimate() const {
131 RTC_DCHECK(thread_checker_.CalledOnValidThread());
132 return channel()->GetDelayEstimate();
133}
134
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100135bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
136 RTC_DCHECK(thread_checker_.CalledOnValidThread());
137 return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
138}
139
140bool ChannelProxy::SendTelephoneEventOutband(uint8_t event,
141 uint32_t duration_ms) {
142 RTC_DCHECK(thread_checker_.CalledOnValidThread());
143 return
144 channel()->SendTelephoneEventOutband(event, duration_ms, 10, false) == 0;
145}
146
deadbeef2d110be2016-01-13 12:00:26 -0800147void ChannelProxy::SetSink(rtc::scoped_ptr<AudioSinkInterface> sink) {
Tommif888bb52015-12-12 01:37:01 +0100148 RTC_DCHECK(thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800149 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100150}
151
solenberg358057b2015-11-27 10:46:42 -0800152Channel* ChannelProxy::channel() const {
153 RTC_DCHECK(channel_owner_.channel());
154 return channel_owner_.channel();
155}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100156
solenberg13725082015-11-25 08:16:52 -0800157} // namespace voe
158} // namespace webrtc