throws IOException {
SessionDescription sessionDescription = new SessionDescription();
sessionDescription.setUsername("user1");
sessionDescription.setId(random.nextInt(Integer.MAX_VALUE));
sessionDescription.setVersion(random.nextInt(Integer.MAX_VALUE));
Config config = userAgent.getConfig();
InetAddress inetAddress = config.getPublicInetAddress();
if (inetAddress == null) {
inetAddress = config.getLocalInetAddress();
}
sessionDescription.setIpAddress(inetAddress);
sessionDescription.setName("-");
sessionDescription.setAttributes(new Hashtable<String, String>());
List<Codec> codecs;
if (offer == null) {
codecs = supportedCodecs;
} else {
codecs = new ArrayList<Codec>();
for (MediaDescription mediaDescription:
offer.getMediaDescriptions()) {
if (RFC4566.MEDIA_AUDIO.equals(mediaDescription.getType())) {
for (Codec codec: mediaDescription.getCodecs()) {
if (supportedCodecs.contains(codec)) {
codecs.add(codec);
}
}
}
}
}
MediaDescription mediaDescription = new MediaDescription();
Hashtable<String, String> attributes = new Hashtable<String, String>();
attributes.put(RFC4566.ATTR_SENDRECV, "");
mediaDescription.setAttributes(attributes);
mediaDescription.setType(RFC4566.MEDIA_AUDIO);
mediaDescription.setPort(config.getRtpPort());
mediaDescription.setCodecs(codecs);
List<MediaDescription> mediaDescriptions =
new ArrayList<MediaDescription>();
mediaDescriptions.add(mediaDescription);
sessionDescription.setMediaDescriptions(mediaDescriptions);