• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
13 #include <utility>
14 
15 #include "webrtc/audio/audio_sink.h"
16 #include "webrtc/base/checks.h"
17 #include "webrtc/voice_engine/channel.h"
18 
19 namespace webrtc {
20 namespace voe {
ChannelProxy()21 ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
22 
ChannelProxy(const ChannelOwner & channel_owner)23 ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
24     channel_owner_(channel_owner) {
25   RTC_CHECK(channel_owner_.channel());
26 }
27 
~ChannelProxy()28 ChannelProxy::~ChannelProxy() {}
29 
SetRTCPStatus(bool enable)30 void ChannelProxy::SetRTCPStatus(bool enable) {
31   channel()->SetRTCPStatus(enable);
32 }
33 
SetLocalSSRC(uint32_t ssrc)34 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
35   RTC_DCHECK(thread_checker_.CalledOnValidThread());
36   int error = channel()->SetLocalSSRC(ssrc);
37   RTC_DCHECK_EQ(0, error);
38 }
39 
SetRTCP_CNAME(const std::string & c_name)40 void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
41   RTC_DCHECK(thread_checker_.CalledOnValidThread());
42   // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
43   std::string c_name_limited = c_name.substr(0, 255);
44   int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
45   RTC_DCHECK_EQ(0, error);
46 }
47 
SetSendAbsoluteSenderTimeStatus(bool enable,int id)48 void 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 
SetSendAudioLevelIndicationStatus(bool enable,int id)54 void 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 
EnableSendTransportSequenceNumber(int id)60 void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
61   RTC_DCHECK(thread_checker_.CalledOnValidThread());
62   channel()->EnableSendTransportSequenceNumber(id);
63 }
64 
SetReceiveAbsoluteSenderTimeStatus(bool enable,int id)65 void 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 
SetReceiveAudioLevelIndicationStatus(bool enable,int id)71 void 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 
SetCongestionControlObjects(RtpPacketSender * rtp_packet_sender,TransportFeedbackObserver * transport_feedback_observer,PacketRouter * packet_router)77 void 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 
GetRTCPStatistics() const86 CallStatistics 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 
GetRemoteRTCPReportBlocks() const94 std::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 
GetNetworkStatistics() const102 NetworkStatistics 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 
GetDecodingCallStatistics() const110 AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
111   RTC_DCHECK(thread_checker_.CalledOnValidThread());
112   AudioDecodingCallStats stats;
113   channel()->GetDecodingCallStatistics(&stats);
114   return stats;
115 }
116 
GetSpeechOutputLevelFullRange() const117 int32_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 
GetDelayEstimate() const125 uint32_t ChannelProxy::GetDelayEstimate() const {
126   RTC_DCHECK(thread_checker_.CalledOnValidThread());
127   return channel()->GetDelayEstimate();
128 }
129 
SetSendTelephoneEventPayloadType(int payload_type)130 bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
131   RTC_DCHECK(thread_checker_.CalledOnValidThread());
132   return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
133 }
134 
SendTelephoneEventOutband(uint8_t event,uint32_t duration_ms)135 bool 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 
SetSink(rtc::scoped_ptr<AudioSinkInterface> sink)142 void ChannelProxy::SetSink(rtc::scoped_ptr<AudioSinkInterface> sink) {
143   RTC_DCHECK(thread_checker_.CalledOnValidThread());
144   channel()->SetSink(std::move(sink));
145 }
146 
channel() const147 Channel* ChannelProxy::channel() const {
148   RTC_DCHECK(channel_owner_.channel());
149   return channel_owner_.channel();
150 }
151 
152 }  // namespace voe
153 }  // namespace webrtc
154