Module: sems Branch: master Commit: 5e7493048909e142a64d7a6bcc35326bacaa7c06 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=5e7493048909e142a64d7a6bcc35326bacaa7c06
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Wed Nov 3 15:09:50 2010 +0100 AmSdp::print function (part of 177a7a8fba) --- core/AmSdp.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ core/AmSdp.h | 6 ++++++ 2 files changed, 54 insertions(+), 0 deletions(-) diff --git a/core/AmSdp.cpp b/core/AmSdp.cpp index c2e27e4..ddfd365 100644 --- a/core/AmSdp.cpp +++ b/core/AmSdp.cpp @@ -158,6 +158,54 @@ int AmSdp::parse() return ret; } +void AmSdp::print(string& body) const +{ + string out_buf = + "v="+int2str(version)+"\r\n" + "o="+origin.user+" "+int2str(origin.sessId)+" "+int2str(origin.sessV)+" IN IP4 "+conn.address+"\r\n" + "s="+sessionName+"\r\n" + "c=IN IP4 "+conn.address+"\r\n" + "t=0 0\r\n"; + + for(std::vector<SdpMedia>::const_iterator media_it = media.begin(); + media_it != media.end(); media_it++) { + + out_buf += "m=" + media_t_2_str(media_it->type) + " " + int2str(media_it->port) + " " + transport_p_2_str(media_it->transport); + + string options; + for(std::vector<SdpPayload>::const_iterator pl_it = media_it->payloads.begin(); + pl_it != media_it->payloads.end(); pl_it++) { + + out_buf += " " + int2str(pl_it->payload_type); + + // "a=rtpmap:" line + options += "a=rtpmap:" + int2str(pl_it->payload_type) + " " + + pl_it->encoding_name + "/" + int2str(pl_it->clock_rate); + + if(pl_it->encoding_param > 0){ + options += "/" + int2str(pl_it->encoding_param); + } + + options += "\r\n"; + + // "a=fmtp:" line + if(pl_it->sdp_format_parameters.size()){ + options += "a=fmtp:" + int2str(pl_it->payload_type) + " " + + pl_it->sdp_format_parameters + "\r\n"; + } + + } + + out_buf += "\r\n" + options; + + if(remote_active /* dir == SdpMedia::DirActive */) + out_buf += "a=direction:passive\r\n"; + } + + body = out_buf; + //mime_type = "application/sdp"; +} + int AmSdp::genResponse(const string& localip, int localport, string& out_buf, bool single_codec) { string l_ip = "IP4 " + localip; diff --git a/core/AmSdp.h b/core/AmSdp.h index 60412ea..79967ab 100644 --- a/core/AmSdp.h +++ b/core/AmSdp.h @@ -174,6 +174,12 @@ public: */ int parse(); + /** + * Prints the current SDP structure + * into a proper SDP message. + */ + void print(string& body) const; + /** * Generate an SDP answer to the offer parsed previously. * @return !=0 if error encountered. _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
