LCOV - code coverage report
Current view: top level - media/webrtc/signaling/src/sdp - SipccSdpParser.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 1 42 2.4 %
Date: 2017-07-14 16:53:18 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "signaling/src/sdp/SipccSdpParser.h"
       8             : #include "signaling/src/sdp/SipccSdp.h"
       9             : 
      10             : #include <utility>
      11             : extern "C" {
      12             : #include "signaling/src/sdp/sipcc/sdp.h"
      13             : }
      14             : 
      15             : namespace mozilla
      16             : {
      17             : 
      18             : extern "C" {
      19             : 
      20             : void
      21           0 : sipcc_sdp_parser_error_handler(void *context, uint32_t line,
      22             :                                const char *message)
      23             : {
      24           0 :   SdpErrorHolder *errorHolder = static_cast<SdpErrorHolder *>(context);
      25           0 :   std::string err(message);
      26           0 :   errorHolder->AddParseError(line, err);
      27           0 : }
      28             : 
      29             : } // extern "C"
      30             : 
      31             : UniquePtr<Sdp>
      32           0 : SipccSdpParser::Parse(const std::string &sdpText)
      33             : {
      34           0 :   ClearParseErrors();
      35             : 
      36           0 :   sdp_conf_options_t *sipcc_config = sdp_init_config();
      37           0 :   if (!sipcc_config) {
      38           0 :     return UniquePtr<Sdp>();
      39             :   }
      40             : 
      41           0 :   sdp_nettype_supported(sipcc_config, SDP_NT_INTERNET, true);
      42           0 :   sdp_addrtype_supported(sipcc_config, SDP_AT_IP4, true);
      43           0 :   sdp_addrtype_supported(sipcc_config, SDP_AT_IP6, true);
      44           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPAVP, true);
      45           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPAVPF, true);
      46           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPSAVP, true);
      47           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPSAVPF, true);
      48           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_UDPTLSRTPSAVP, true);
      49           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_UDPTLSRTPSAVPF, true);
      50           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_TCPTLSRTPSAVP, true);
      51           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_TCPTLSRTPSAVPF, true);
      52           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_DTLSSCTP, true);
      53           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_UDPDTLSSCTP, true);
      54           0 :   sdp_transport_supported(sipcc_config, SDP_TRANSPORT_TCPDTLSSCTP, true);
      55           0 :   sdp_require_session_name(sipcc_config, false);
      56             : 
      57             :   sdp_config_set_error_handler(sipcc_config, &sipcc_sdp_parser_error_handler,
      58           0 :                                this);
      59             : 
      60             :   // Takes ownership of |sipcc_config| iff it succeeds
      61           0 :   sdp_t *sdp = sdp_init_description(sipcc_config);
      62           0 :   if (!sdp) {
      63           0 :     sdp_free_config(sipcc_config);
      64           0 :     return UniquePtr<Sdp>();
      65             :   }
      66             : 
      67           0 :   const char *rawString = sdpText.c_str();
      68           0 :   sdp_result_e sdpres = sdp_parse(sdp, rawString, sdpText.length());
      69           0 :   if (sdpres != SDP_SUCCESS) {
      70           0 :     sdp_free_description(sdp);
      71           0 :     return UniquePtr<Sdp>();
      72             :   }
      73             : 
      74           0 :   UniquePtr<SipccSdp> sipccSdp(new SipccSdp);
      75             : 
      76           0 :   bool success = sipccSdp->Load(sdp, *this);
      77           0 :   sdp_free_description(sdp);
      78           0 :   if (!success) {
      79           0 :     return UniquePtr<Sdp>();
      80             :   }
      81             : 
      82           0 :   return UniquePtr<Sdp>(Move(sipccSdp));
      83             : }
      84             : 
      85           9 : } // namespace mozilla

Generated by: LCOV version 1.13