def self.make_sdp(session_hash, ip, port, codecs, type)
sdp = make_no_media_sdp(session_hash, ip)
h = {}
ma = []
if codecs.include?('G711U')
h[:m] = sprintf("audio %s RTP/AVP 0", port.to_s.chomp)
ma << 'rtpmap:0 PCMU/8000'
end
if codecs.include?('G711A')
if h[:m]
h[:m] << " 8"
else
h[:m] = sprintf("audio %s RTP/AVP 8", port.to_s.chomp)
end
ma << 'rtpmap:8 PCMA/8000'
end
if codecs.include?('DTMF')
if h[:m]
h[:m] << " 101"
else
h[:m] = sprintf("audio %s RTP/AVP 101", port.to_s.chomp)
end
ma << 'rtpmap:101 telephone-event/8000'
end
sdp.add_media_lines(h)
sdp.add_media_attribute_at(0, type.downcase) if type
ma.each do |a|
sdp.add_media_attribute_at(0, a)
end
sdp
end