LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/voice_engine - channel_proxy.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 171 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 44 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/api/call/audio_sink.h"
      16             : #include "webrtc/base/checks.h"
      17             : #include "webrtc/voice_engine/channel.h"
      18             : 
      19             : namespace webrtc {
      20             : namespace voe {
      21           0 : ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
      22             : 
      23           0 : ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
      24           0 :     channel_owner_(channel_owner) {
      25           0 :   RTC_CHECK(channel_owner_.channel());
      26           0 : }
      27             : 
      28           0 : ChannelProxy::~ChannelProxy() {}
      29             : 
      30           0 : void ChannelProxy::SetRTCPStatus(bool enable) {
      31           0 :   channel()->SetRTCPStatus(enable);
      32           0 : }
      33             : 
      34           0 : void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
      35           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      36           0 :   int error = channel()->SetLocalSSRC(ssrc);
      37           0 :   RTC_DCHECK_EQ(0, error);
      38           0 : }
      39             : 
      40           0 : void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
      41           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      42             :   // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
      43           0 :   std::string c_name_limited = c_name.substr(0, 255);
      44           0 :   int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
      45           0 :   RTC_DCHECK_EQ(0, error);
      46           0 : }
      47             : 
      48           0 : void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
      49           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      50           0 :   channel()->SetNACKStatus(enable, max_packets);
      51           0 : }
      52             : 
      53           0 : void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
      54           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      55           0 :   int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
      56           0 :   RTC_DCHECK_EQ(0, error);
      57           0 : }
      58             : 
      59           0 : void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
      60           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      61           0 :   int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
      62           0 :   RTC_DCHECK_EQ(0, error);
      63           0 : }
      64             : 
      65           0 : void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
      66           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      67           0 :   channel()->EnableSendTransportSequenceNumber(id);
      68           0 : }
      69             : 
      70           0 : void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
      71           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      72           0 :   channel()->EnableReceiveTransportSequenceNumber(id);
      73           0 : }
      74             : 
      75           0 : void ChannelProxy::RegisterSenderCongestionControlObjects(
      76             :     RtpPacketSender* rtp_packet_sender,
      77             :     TransportFeedbackObserver* transport_feedback_observer,
      78             :     PacketRouter* packet_router) {
      79           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      80           0 :   channel()->RegisterSenderCongestionControlObjects(
      81           0 :       rtp_packet_sender, transport_feedback_observer, packet_router);
      82           0 : }
      83             : 
      84           0 : void ChannelProxy::RegisterReceiverCongestionControlObjects(
      85             :     PacketRouter* packet_router) {
      86           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      87           0 :   channel()->RegisterReceiverCongestionControlObjects(packet_router);
      88           0 : }
      89             : 
      90           0 : void ChannelProxy::ResetCongestionControlObjects() {
      91           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      92           0 :   channel()->ResetCongestionControlObjects();
      93           0 : }
      94             : 
      95           0 : CallStatistics ChannelProxy::GetRTCPStatistics() const {
      96             :   // Since we (Mozilla) need to collect stats on STS, we can't
      97             :   // use the thread-checker (which will want to be called on MainThread)
      98             :   // without refactor of ExecuteStatsQuery_s().
      99             :   // However, GetRTPStatistics internally locks in the SSRC()
     100             :   // and statistician methods.
     101             : 
     102             :   // RTC_DCHECK(thread_checker_.CalledOnValidThread());
     103           0 :   CallStatistics stats = {0};
     104           0 :   int error = channel()->GetRTPStatistics(stats);
     105           0 :   RTC_DCHECK_EQ(0, error);
     106           0 :   return stats;
     107             : }
     108             : 
     109           0 : int ChannelProxy::GetRTPStatistics(unsigned int& averageJitterMs,
     110             :                                    unsigned int& maxJitterMs,
     111             :                                    unsigned int& discardedPackets,
     112             :                                    unsigned int& cumulativeLost) const {
     113             :   // Since we (Mozilla) need to collect stats on STS, we can't
     114             :   // use the thread-checker (which will want to be called on MainThread)
     115             :   // without refactor of ExecuteStatsQuery_s().
     116             :   // However, GetRTPStatistics internally locks in the SSRC()
     117             :   // and statistician methods.  PlayoutFrequency() should also be safe.
     118             :   // statistics_proxy_->GetStats() also locks
     119             : 
     120           0 :   return channel()->GetRTPStatistics(averageJitterMs,
     121             :                                      maxJitterMs,
     122             :                                      discardedPackets,
     123           0 :                                      cumulativeLost);
     124             : }
     125             : 
     126           0 : std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
     127           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     128           0 :   std::vector<webrtc::ReportBlock> blocks;
     129           0 :   int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
     130           0 :   RTC_DCHECK_EQ(0, error);
     131           0 :   return blocks;
     132             : }
     133             : 
     134           0 : NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
     135           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     136           0 :   NetworkStatistics stats = {0};
     137           0 :   int error = channel()->GetNetworkStatistics(stats);
     138           0 :   RTC_DCHECK_EQ(0, error);
     139           0 :   return stats;
     140             : }
     141             : 
     142           0 : AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
     143           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     144           0 :   AudioDecodingCallStats stats;
     145           0 :   channel()->GetDecodingCallStatistics(&stats);
     146           0 :   return stats;
     147             : }
     148             : 
     149           0 : int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
     150           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     151           0 :   uint32_t level = 0;
     152           0 :   int error = channel()->GetSpeechOutputLevelFullRange(level);
     153           0 :   RTC_DCHECK_EQ(0, error);
     154           0 :   return static_cast<int32_t>(level);
     155             : }
     156             : 
     157           0 : uint32_t ChannelProxy::GetDelayEstimate() const {
     158           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     159           0 :   return channel()->GetDelayEstimate();
     160             : }
     161             : 
     162           0 : bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
     163             :                                                     int payload_frequency) {
     164           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     165           0 :   return channel()->SetSendTelephoneEventPayloadType(payload_type,
     166           0 :                                                      payload_frequency) == 0;
     167             : }
     168             : 
     169           0 : bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
     170           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     171           0 :   return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
     172             : }
     173             : 
     174           0 : void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
     175             :   // May be called on different threads and needs to be handled by the channel.
     176           0 :   channel()->SetBitRate(bitrate_bps, probing_interval_ms);
     177           0 : }
     178             : 
     179           0 : void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
     180           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     181           0 :   channel()->SetSink(std::move(sink));
     182           0 : }
     183             : 
     184           0 : void ChannelProxy::SetInputMute(bool muted) {
     185           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     186           0 :   int error = channel()->SetInputMute(muted);
     187           0 :   RTC_DCHECK_EQ(0, error);
     188           0 : }
     189             : 
     190           0 : void ChannelProxy::RegisterExternalTransport(Transport* transport) {
     191           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     192           0 :   int error = channel()->RegisterExternalTransport(transport);
     193           0 :   RTC_DCHECK_EQ(0, error);
     194           0 : }
     195             : 
     196           0 : void ChannelProxy::DeRegisterExternalTransport() {
     197           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     198           0 :   channel()->DeRegisterExternalTransport();
     199           0 : }
     200             : 
     201           0 : bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet,
     202             :                                      size_t length,
     203             :                                      const PacketTime& packet_time) {
     204             :   // May be called on either worker thread or network thread.
     205           0 :   return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0;
     206             : }
     207             : 
     208           0 : bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
     209             :   // May be called on either worker thread or network thread.
     210           0 :   return channel()->ReceivedRTCPPacket(packet, length) == 0;
     211             : }
     212             : 
     213             : const rtc::scoped_refptr<AudioDecoderFactory>&
     214           0 :     ChannelProxy::GetAudioDecoderFactory() const {
     215           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     216           0 :   return channel()->GetAudioDecoderFactory();
     217             : }
     218             : 
     219           0 : void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
     220           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     221           0 :   int error = channel()->SetChannelOutputVolumeScaling(scaling);
     222           0 :   RTC_DCHECK_EQ(0, error);
     223           0 : }
     224             : 
     225           0 : void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
     226           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     227           0 :   channel()->SetRtcEventLog(event_log);
     228           0 : }
     229             : 
     230           0 : void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
     231           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     232           0 :   bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
     233           0 :   RTC_DCHECK(ret);
     234           0 : ;}
     235             : 
     236           0 : void ChannelProxy::DisableAudioNetworkAdaptor() {
     237           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     238           0 :   channel()->DisableAudioNetworkAdaptor();
     239           0 : }
     240             : 
     241           0 : void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
     242             :                                                int max_frame_length_ms) {
     243           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     244           0 :   channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
     245           0 :                                          max_frame_length_ms);
     246           0 : }
     247             : 
     248           0 : AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
     249             :     int sample_rate_hz,
     250             :     AudioFrame* audio_frame) {
     251           0 :   RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
     252           0 :   return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
     253             : }
     254             : 
     255           0 : int ChannelProxy::NeededFrequency() const {
     256           0 :   return static_cast<int>(channel()->NeededFrequency(-1));
     257             : }
     258             : 
     259           0 : void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
     260           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     261           0 :   channel()->SetTransportOverhead(transport_overhead_per_packet);
     262           0 : }
     263             : 
     264           0 : void ChannelProxy::AssociateSendChannel(
     265             :     const ChannelProxy& send_channel_proxy) {
     266           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     267           0 :   channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
     268           0 : }
     269             : 
     270           0 : void ChannelProxy::DisassociateSendChannel() {
     271           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     272           0 :   channel()->set_associate_send_channel(ChannelOwner(nullptr));
     273           0 : }
     274             : 
     275           0 : void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
     276           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
     277           0 :   channel()->SetRtcpRttStats(rtcp_rtt_stats);
     278           0 : }
     279             : 
     280           0 : Channel* ChannelProxy::channel() const {
     281           0 :   RTC_DCHECK(channel_owner_.channel());
     282           0 :   return channel_owner_.channel();
     283             : }
     284             : 
     285             : }  // namespace voe
     286             : }  // namespace webrtc

Generated by: LCOV version 1.13