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)); }
/* * sip_sdp_create() * * Allocate a standard SDP with SIP config and set debug options * based on ccsip debug settings */ void * sipsdp_create (void) { const char *fname = "sipsdp_create :"; void *sdp; // char debug_str[80]; sdp = sdp_init_description(ccsip_sdp_config); if (!sdp) { CCSIP_DEBUG_ERROR(SIP_F_PREFIX"SDP allocation failure\n", fname); return (NULL); } /* * Map "ccsip debug events (or info)" to SDP warnings * "ccsip debug errors to SDP errors */ CCSIP_INFO_DEBUG { sdp_debug(sdp, SDP_DEBUG_WARNINGS, TRUE); } CCSIP_ERR_DEBUG { sdp_debug(sdp, SDP_DEBUG_ERRORS, TRUE); } #ifdef DEBUG_SDP_LIB /* * Enabling this is redundant to the existing message printing * available for the entire SIP text messages, so it is not * enabled here. It is useful for debugging the SDP parser, * however. */ CCSIP_MESSAGES_DEBUG { sdp_debug(sdp, SDP_DEBUG_TRACE, TRUE); } #endif return (sdp); }
void ResetSdp() { if (!sdp_ptr_) { sdp_free_description(sdp_ptr_); } sdp_ptr_ = sdp_init_description("BogusPeerConnectionId", config_p_); }