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

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2012 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/voe_network_impl.h"
      12             : 
      13             : #include "webrtc/base/checks.h"
      14             : #include "webrtc/base/format_macros.h"
      15             : #include "webrtc/base/logging.h"
      16             : #include "webrtc/system_wrappers/include/trace.h"
      17             : #include "webrtc/voice_engine/channel.h"
      18             : #include "webrtc/voice_engine/include/voe_errors.h"
      19             : #include "webrtc/voice_engine/voice_engine_impl.h"
      20             : 
      21             : namespace webrtc {
      22             : 
      23           0 : VoENetwork* VoENetwork::GetInterface(VoiceEngine* voiceEngine) {
      24           0 :   if (!voiceEngine) {
      25           0 :     return nullptr;
      26             :   }
      27           0 :   VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
      28           0 :   s->AddRef();
      29           0 :   return s;
      30             : }
      31             : 
      32           0 : VoENetworkImpl::VoENetworkImpl(voe::SharedData* shared) : _shared(shared) {
      33           0 : }
      34             : 
      35             : VoENetworkImpl::~VoENetworkImpl() = default;
      36             : 
      37           0 : int VoENetworkImpl::RegisterExternalTransport(int channel,
      38             :                                               Transport& transport) {
      39           0 :   RTC_DCHECK(_shared->statistics().Initialized());
      40           0 :   voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
      41           0 :   voe::Channel* channelPtr = ch.channel();
      42           0 :   if (!channelPtr) {
      43           0 :     LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
      44           0 :     return -1;
      45             :   }
      46           0 :   return channelPtr->RegisterExternalTransport(&transport);
      47             : }
      48             : 
      49           0 : int VoENetworkImpl::DeRegisterExternalTransport(int channel) {
      50           0 :   RTC_CHECK(_shared->statistics().Initialized());
      51           0 :   voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
      52           0 :   voe::Channel* channelPtr = ch.channel();
      53           0 :   if (!channelPtr) {
      54           0 :     LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
      55           0 :     return -1;
      56             :   }
      57           0 :   return channelPtr->DeRegisterExternalTransport();
      58             : }
      59             : 
      60           0 : int VoENetworkImpl::ReceivedRTPPacket(int channel,
      61             :                                       const void* data,
      62             :                                       size_t length) {
      63           0 :   return ReceivedRTPPacket(channel, data, length, webrtc::PacketTime());
      64             : }
      65             : 
      66           0 : int VoENetworkImpl::ReceivedRTPPacket(int channel,
      67             :                                       const void* data,
      68             :                                       size_t length,
      69             :                                       const PacketTime& packet_time) {
      70           0 :   RTC_CHECK(_shared->statistics().Initialized());
      71           0 :   RTC_CHECK(data);
      72             :   // L16 at 32 kHz, stereo, 10 ms frames (+12 byte RTP header) -> 1292 bytes
      73           0 :   if ((length < 12) || (length > 1292)) {
      74           0 :     LOG_F(LS_ERROR) << "Invalid packet length: " << length;
      75           0 :     return -1;
      76             :   }
      77           0 :   voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
      78           0 :   voe::Channel* channelPtr = ch.channel();
      79           0 :   if (!channelPtr) {
      80           0 :     LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
      81           0 :     return -1;
      82             :   }
      83           0 :   if (!channelPtr->ExternalTransport()) {
      84           0 :     LOG_F(LS_ERROR) << "No external transport for channel: " << channel;
      85           0 :     return -1;
      86             :   }
      87             :   return channelPtr->ReceivedRTPPacket(static_cast<const uint8_t*>(data),
      88           0 :                                        length, packet_time);
      89             : }
      90             : 
      91           0 : int VoENetworkImpl::ReceivedRTCPPacket(int channel,
      92             :                                        const void* data,
      93             :                                        size_t length) {
      94           0 :   RTC_CHECK(_shared->statistics().Initialized());
      95           0 :   RTC_CHECK(data);
      96           0 :   if (length < 4) {
      97           0 :     LOG_F(LS_ERROR) << "Invalid packet length: " << length;
      98           0 :     return -1;
      99             :   }
     100           0 :   voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
     101           0 :   voe::Channel* channelPtr = ch.channel();
     102           0 :   if (!channelPtr) {
     103           0 :     LOG_F(LS_ERROR) << "Failed to locate channel: " << channel;
     104           0 :     return -1;
     105             :   }
     106           0 :   if (!channelPtr->ExternalTransport()) {
     107           0 :     LOG_F(LS_ERROR) << "No external transport for channel: " << channel;
     108           0 :     return -1;
     109             :   }
     110             :   return channelPtr->ReceivedRTCPPacket(static_cast<const uint8_t*>(data),
     111           0 :                                         length);
     112             : }
     113             : 
     114             : }  // namespace webrtc

Generated by: LCOV version 1.13