コード例 #1
0
/*
 * sipsdp_free()
 *
 * Frees the SIP SDP structure, the contained common SDP structure,
 * and each stream structure in the linked stream list.
 *
 * sip_sdp is set to NULL after being freed.
 */
void
sipsdp_free (cc_sdp_t **sip_sdp)
{
    const char *fname = "sipsdp_free: ";
    sdp_result_e sdp_ret;

    if (!*sip_sdp) {
        return;
    }

    if ((*sip_sdp)->src_sdp) {
        sdp_ret = sdp_free_description((*sip_sdp)->src_sdp);
        if (sdp_ret != SDP_SUCCESS) {
            CCSIP_DEBUG_ERROR(SIP_F_PREFIX"%d while freeing src_sdp\n",
                          fname, sdp_ret);
        }
    }
    if ((*sip_sdp)->dest_sdp) {
        sdp_ret = sdp_free_description((*sip_sdp)->dest_sdp);
        if (sdp_ret != SDP_SUCCESS) {
            CCSIP_DEBUG_ERROR(SIP_F_PREFIX"%d while freeing dest_sdp\n",
                          fname, sdp_ret);
        }
    }

    SDP_FREE(*sip_sdp);
}
コード例 #2
0
UniquePtr<Sdp>
SipccSdpParser::Parse(const std::string &sdpText)
{
  ClearParseErrors();

  sdp_conf_options_t *sipcc_config = sdp_init_config();
  if (!sipcc_config) {
    return UniquePtr<Sdp>();
  }

  sdp_nettype_supported(sipcc_config, SDP_NT_INTERNET, true);
  sdp_addrtype_supported(sipcc_config, SDP_AT_IP4, true);
  sdp_addrtype_supported(sipcc_config, SDP_AT_IP6, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPAVP, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPAVPF, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPSAVP, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_RTPSAVPF, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_UDPTLSRTPSAVP, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_UDPTLSRTPSAVPF, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_TCPTLSRTPSAVP, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_TCPTLSRTPSAVPF, true);
  sdp_transport_supported(sipcc_config, SDP_TRANSPORT_DTLSSCTP, true);
  sdp_require_session_name(sipcc_config, false);

  sdp_config_set_error_handler(sipcc_config, &sipcc_sdp_parser_error_handler,
                               this);

  // Takes ownership of |sipcc_config| iff it succeeds
  sdp_t *sdp = sdp_init_description(sipcc_config);
  if (!sdp) {
    sdp_free_config(sipcc_config);
    return UniquePtr<Sdp>();
  }

  const char *rawString = sdpText.c_str();
  sdp_result_e sdpres = sdp_parse(sdp, rawString, sdpText.length());
  if (sdpres != SDP_SUCCESS) {
    sdp_free_description(sdp);
    return UniquePtr<Sdp>();
  }

  UniquePtr<SipccSdp> sipccSdp(new SipccSdp);

  bool success = sipccSdp->Load(sdp, *this);
  sdp_free_description(sdp);
  if (!success) {
    return UniquePtr<Sdp>();
  }

  return UniquePtr<Sdp>(Move(sipccSdp));
}
コード例 #3
0
/*
 * sipsdp_src_dest_free()
 *
 * Frees the SRC and/or DEST SDP.  It will also free the sdp_info
 * structure if both SRC and DEST SDP are freed.
 *
 * Input:
 *   flags   - bitmask indicating if src and/or dest sdp should be
 *             freed
 *
 * Returns:
 *   sdp_info is set to NULL if freed.
 */
void
sipsdp_src_dest_free (uint16_t flags, cc_sdp_t **sdp_info)
{
    const char *fname = "sipsdp_src_dest_free: ";
    sdp_result_e sdp_ret;

    if ((sdp_info == NULL) || (*sdp_info == NULL)) {
        return;
    }

    /* Free the SRC and/or DEST SDP */
    if (flags & CCSIP_SRC_SDP_BIT) {
        if ((*sdp_info)->src_sdp) {
            sdp_ret = sdp_free_description((*sdp_info)->src_sdp);
            if (sdp_ret != SDP_SUCCESS) {
                CCSIP_DEBUG_ERROR(SIP_F_PREFIX"%d while freeing src_sdp\n",
                              fname, sdp_ret);
            }
            (*sdp_info)->src_sdp = NULL;
        }
    }

    if (flags & CCSIP_DEST_SDP_BIT) {
        if ((*sdp_info)->dest_sdp) {
            sdp_ret = sdp_free_description((*sdp_info)->dest_sdp);
            if (sdp_ret != SDP_SUCCESS) {
                CCSIP_DEBUG_ERROR(SIP_F_PREFIX"%d while freeing dest_sdp\n",
                              fname, sdp_ret);
            }
            (*sdp_info)->dest_sdp = NULL;
        }

    }

    /*
     * If both src and dest sdp are NULL, there is no need to keep the
     * sdp_info structure around.  Free it.
     */
    if (((*sdp_info)->src_sdp == NULL) && ((*sdp_info)->dest_sdp == NULL)) {
        sipsdp_free(sdp_info);
        *sdp_info = NULL;
    }
}
コード例 #4
0
 void ResetSdp() {
   if (!sdp_ptr_) {
     sdp_free_description(sdp_ptr_);
   }
   sdp_ptr_ = sdp_init_description("BogusPeerConnectionId", config_p_);
 }