/* * sip_sdp_init * * This function initializes SDP parser with SIP-specific parameters. * This includes supported media, network types, address types, * transports and codecs. * * The function must be called once. * * Returns TRUE - successful * FALSE - failed */ boolean sip_sdp_init (void) { ccsip_sdp_config = sdp_init_config(); if (!ccsip_sdp_config) { CCSIP_ERR_MSG("sdp_init_config() failure"); return FALSE; } sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_AUDIO, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_VIDEO, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_APPLICATION, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_DATA, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_CONTROL, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_RADIUS, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_TACACS, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_DIAMETER, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_L2TP, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_LOGIN, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_NAS_NONE, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_IMAGE, TRUE); sdp_media_supported(ccsip_sdp_config, SDP_MEDIA_TEXT, TRUE); sdp_nettype_supported(ccsip_sdp_config, SDP_NT_INTERNET, TRUE); sdp_addrtype_supported(ccsip_sdp_config, SDP_AT_IP4, TRUE); sdp_addrtype_supported(ccsip_sdp_config, SDP_AT_IP6, TRUE); sdp_transport_supported(ccsip_sdp_config, SDP_TRANSPORT_RTPAVP, TRUE); sdp_transport_supported(ccsip_sdp_config, SDP_TRANSPORT_UDPTL, TRUE); sdp_require_session_name(ccsip_sdp_config, FALSE); return (TRUE); }
SdpTest() : sdp_ptr_(nullptr) { sdp_media_e supported_media[] = { SDP_MEDIA_AUDIO, SDP_MEDIA_VIDEO, SDP_MEDIA_APPLICATION, SDP_MEDIA_DATA, SDP_MEDIA_CONTROL, SDP_MEDIA_NAS_RADIUS, SDP_MEDIA_NAS_TACACS, SDP_MEDIA_NAS_DIAMETER, SDP_MEDIA_NAS_L2TP, SDP_MEDIA_NAS_LOGIN, SDP_MEDIA_NAS_NONE, SDP_MEDIA_IMAGE, }; config_p_ = sdp_init_config(); unsigned int i; for (i = 0; i < sizeof(supported_media) / sizeof(sdp_media_e); i++) { sdp_media_supported(config_p_, supported_media[i], true); } sdp_nettype_supported(config_p_, SDP_NT_INTERNET, true); sdp_addrtype_supported(config_p_, SDP_AT_IP4, true); sdp_addrtype_supported(config_p_, SDP_AT_IP6, true); sdp_transport_supported(config_p_, SDP_TRANSPORT_RTPSAVPF, true); sdp_transport_supported(config_p_, SDP_TRANSPORT_UDPTL, true); sdp_require_session_name(config_p_, false); }
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)); }