blob: 711f2abd03b0723c913dcdf1329cafd559d49c66 [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
Stefan Holmerb86d4e42015-12-07 10:26:18 +010060void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
61 RTC_DCHECK(thread_checker_.CalledOnValidThread());
62 channel()->EnableSendTransportSequenceNumber(id);
63}
64
solenberg358057b2015-11-27 10:46:42 -080065void 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
Stefan Holmerb86d4e42015-12-07 10:26:18 +010077void ChannelProxy::SetCongestionControlObjects(
78 RtpPacketSender* rtp_packet_sender,
79 TransportFeedbackObserver* transport_feedback_observer,
80 PacketRouter* packet_router) {
81 RTC_DCHECK(thread_checker_.CalledOnValidThread());
82 channel()->SetCongestionControlObjects(
83 rtp_packet_sender, transport_feedback_observer, packet_router);
84}
85
solenberg358057b2015-11-27 10:46:42 -080086CallStatistics ChannelProxy::GetRTCPStatistics() const {
87 RTC_DCHECK(thread_checker_.CalledOnValidThread());
88 CallStatistics stats = {0};
89 int error = channel()->GetRTPStatistics(stats);
90 RTC_DCHECK_EQ(0, error);
91 return stats;
92}
93
94std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
95 RTC_DCHECK(thread_checker_.CalledOnValidThread());
96 std::vector<webrtc::ReportBlock> blocks;
97 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
98 RTC_DCHECK_EQ(0, error);
99 return blocks;
100}
101
102NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
103 RTC_DCHECK(thread_checker_.CalledOnValidThread());
104 NetworkStatistics stats = {0};
105 int error = channel()->GetNetworkStatistics(stats);
106 RTC_DCHECK_EQ(0, error);
107 return stats;
108}
109
110AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
111 RTC_DCHECK(thread_checker_.CalledOnValidThread());
112 AudioDecodingCallStats stats;
113 channel()->GetDecodingCallStatistics(&stats);
114 return stats;
115}
116
117int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
118 RTC_DCHECK(thread_checker_.CalledOnValidThread());
119 uint32_t level = 0;
120 int error = channel()->GetSpeechOutputLevelFullRange(level);
121 RTC_DCHECK_EQ(0, error);
122 return static_cast<int32_t>(level);
123}
124
125uint32_t ChannelProxy::GetDelayEstimate() const {
126 RTC_DCHECK(thread_checker_.CalledOnValidThread());
127 return channel()->GetDelayEstimate();
128}
129
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100130bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
131 RTC_DCHECK(thread_checker_.CalledOnValidThread());
132 return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
133}
134
135bool ChannelProxy::SendTelephoneEventOutband(uint8_t event,
136 uint32_t duration_ms) {
137 RTC_DCHECK(thread_checker_.CalledOnValidThread());
138 return
139 channel()->SendTelephoneEventOutband(event, duration_ms, 10, false) == 0;
140}
141
deadbeefe591f932016-01-12 16:44:59 -0800142void ChannelProxy::SetSink(const rtc::scoped_refptr<AudioSinkInterface>& sink) {
Tommif888bb52015-12-12 01:37:01 +0100143 RTC_DCHECK(thread_checker_.CalledOnValidThread());
deadbeefe591f932016-01-12 16:44:59 -0800144 channel()->SetSink(sink);
Tommif888bb52015-12-12 01:37:01 +0100145}
146
solenberg358057b2015-11-27 10:46:42 -0800147Channel* ChannelProxy::channel() const {
148 RTC_DCHECK(channel_owner_.channel());
149 return channel_owner_.channel();
150}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100151
solenberg13725082015-11-25 08:16:52 -0800152} // namespace voe
153} // namespace webrtc