|
|
|
|
@ -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;
|
|
|
|
|
|