I would like to perform mutual search in java using jain sip application. There is no problem in the register process, but because of codec incompatibility in the search process, I just call and answer the phone, but the call is not sound transmission. . There is a certain codec information in the SDP that corresponds to the invate request that I send to my server. I should take this information and do codecs according to it. Also, payload type values of some codecs are dynamically determined. How to pull these dynamic values and create other attributes. Depending on what I should do a pcma or telephone-event.
I want to use PC8 for video and VP8 for video. I create pcma by default, but there is another codec called telephony event. How am I supposed to do this correctly?
try {
Address toAddress = addressFactory.createAddress(GUI.getDestination());
ToHeader toHeader = headerFactory.createToHeader(toAddress, null);
Address fromAddress = addressFactory.createAddress(GUI.getName() + "<sip:" + GUI.getAOR() + ">");
FromHeader fromHeader = headerFactory.createFromHeader(fromAddress, String.valueOf(tag));
ViaHeader viaHeader = headerFactory.createViaHeader(sIP, iSipPort, "udp", null);
ArrayList viaHeaders = new ArrayList();
viaHeaders.add(viaHeader);
MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(20);
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(LCseqDegeri, Request.INVITE);
CallIdHeader callIdHeader = sipProvider.getNewCallId();
// proxy adresi
Address proxyAddress = addressFactory.createAddress(GUI.getDestination());
URI requestUri = proxyAddress.getURI();
Request request = messageFactory.createRequest(requestUri, Request.INVITE,
callIdHeader, cSeqHeader, fromHeader, toHeader,
viaHeaders, maxForwardsHeader);
request.addHeader(contactHeader);
RouteHeader routeHeader = headerFactory.createRouteHeader(proxyAddress);
request.addHeader(routeHeader);
// senderInfo_UAC: UAC sesli sohbet için bilgi içerir
SdpInfo senderInfo_UAC = new SdpInfo();
senderInfo_UAC.setIpSender(sIP);
senderInfo_UAC.setVoicePort(GUI.getVoicePort());
String direction = "sendrecv";
senderInfo_UAC.setDirection("sendrecv");
ContentTypeHeader myContentTypeHeader = headerFactory.createContentTypeHeader("application", "sdp");
// SDP mesajını oluştur ve bilgileri sdpOffer'in senderInfo değişkenine kaydet
byte[] content = sdpOffer.createSdp(senderInfo_UAC);
// SDP mesajını INVITE mesaj gövdesine kaydet
request.setContent(content, myContentTypeHeader);
clientTransaction = sipProvider.getNewClientTransaction(request);
clientTransaction.sendRequest();
GUI.Display(" sendRequest SdpInfo Send ringbacktone.wav : " + request.toString());
// UAC zil sesini çal
ringClient.playRing("file:ringbacktone.wav");
} catch (ParseException | InvalidArgumentException | SipException ex) {
System.out.println(ex.getMessage());
}
public byte[] createSdp(SdpInfo senderInfo) {
try {
this.senderInfo = senderInfo;
Version version = sdpFactory.createVersion(0);
long ss = sdpFactory.getNtpTime(new Date());
Origin origin = sdpFactory.createOrigin("-", ss, ss, "IN", "IP4", senderInfo.getIpSender());
SessionName sessionName = sdpFactory.createSessionName("-");
Connection con = sdpFactory.createConnection("IN", "IP4", senderInfo.getIpSender());
Time time = sdpFactory.createTime();
Vector timeVector = new Vector();
timeVector.add(time);
**Vector mediaDescriptionVector = new Vector();
int[] audioformat = new int[2];
//audioformat[0] = senderInfo.getMediaPayloadType();
audioformat[0] = 8;
audioformat[1] = 101;
MediaDescription audioMediaDescription = sdpFactory.createMediaDescription("audio", senderInfo.getVoicePort(), 1, "RTP/AVP", audioformat);
mediaDescriptionVector.add(audioMediaDescription);
String[] encoding = new String[2];
encoding[0] = "PCMA";
encoding[1] = "telephone-event";
// Attribute audioAttributeDescription = sdpFactory.createAttribute("rtpmap", "PCMA/8000");
// mediaDescriptionVector.add(audioAttributeDescription);
for (int i = 0; i < audioformat.length; i++) {
Attribute rtpmap = sdpFactory.createAttribute(
SdpConstants.RTPMAP,
audioformat[i] + " " + encoding[i] + "/"
+ senderInfo.getMediaRate());
mediaDescriptionVector.add(rtpmap); }
Attribute fmtp = sdpFactory.createAttribute("fmtp", audioformat[1] + " 0-16");//0-16 1-10 abcdef
mediaDescriptionVector.add(fmtp);
Attribute direction = sdpFactory.createAttribute(senderInfo.getDirection(), null);
mediaDescriptionVector.add(direction);
Attribute ptime = sdpFactory.createAttribute("ptime", "20");
mediaDescriptionVector.add(ptime);**
// SDP mesajı oluştur
SessionDescription sdpMessage = sdpFactory.createSessionDescription();
sdpMessage.setVersion(version);
sdpMessage.setOrigin(origin);
sdpMessage.setSessionName(sessionName);
sdpMessage.setConnection(con);
sdpMessage.setTimeDescriptions(timeVector);
sdpMessage.setMediaDescriptions(mediaDescriptionVector); return sdpMessage.toString().getBytes();
} catch (IllegalArgumentException | SdpException ex) {
System.out.println(ex.getMessage());
}
return null;
}
I need to enter the correct payload type value and encoding value at this point, but I could not create the correct media fmtp values or other required parameters in a healthy way. Is it possible to extract audio format values from a location and access both the encoding and pt values? How these values are determined. How can I conduct a mutual meeting
Sip Mesajları
sendRegister : REGISTER sip:801@kdogutas.com SIP/2.0
Call-ID: 49d0e36414c1d1abaa33a256b318b171@192.168.2.86
CSeq: 1 REGISTER
From: "Zeynep Eğilmez" <sip:801@kdogutas.com:5060>;tag=724913436
To: "801" <sip:801@kdogutas.com>
Via: SIP/2.0/UDP 192.168.2.86:5060;rport;branch=z9hG4bK-373730-3cf966a6a3c0177a572d2a23fe506287
Max-Forwards: 70
Contact: <sip:801@192.168.2.86:5060;udp>
Expires: 60
Content-Length: 0
Received processResponse: SIP/2.0 401 Unauthorized
Call-ID: 49d0e36414c1d1abaa33a256b318b171@192.168.2.86
CSeq: 1 REGISTER
From: "Zeynep Eğilmez" <sip:801@kdogutas.com:5060>;tag=724913436
To: "801" <sip:801@kdogutas.com>;tag=b059b3424eb911ed130009d1469e6b45.a968
Via: SIP/2.0/UDP 192.168.2.86:5060;received=78.188.3.82;rport=1030;branch=z9hG4bK-373730-3cf966a6a3c0177a572d2a23fe506287
WWW-Authenticate: Digest realm="kdogutas.com",nonce="5b6c4dd100013d145714177985de24ad385d4f548e9c207c"
Server: NORMSWITCH V3.14 KDOGUTAS
Content-Length: 0
Received processResponse: SIP/2.0 200 OK
Call-ID: 49d0e36414c1d1abaa33a256b318b171@192.168.2.86
CSeq: 2 REGISTER
From: "Zeynep Eğilmez" <sip:801@kdogutas.com:5060>;tag=724913436
To: "801" <sip:801@kdogutas.com>;tag=b059b3424eb911ed130009d1469e6b45.1432
Via: SIP/2.0/UDP 192.168.2.86:5060;received=78.188.3.82;rport=1030;branch=z9hG4bK-373730-f7b309520389533925035dfe3bc703cb
Contact: <sip:801@78.188.3.82:1030;udp>;expires=60
Server: NORMSWITCH V3.14 KDOGUTAS
Content-Length: 0
sendRequest SdpInfo Send ringbacktone.wav : INVITE sip:802@kdogutas.com SIP/2.0
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 2 INVITE
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>
Via: SIP/2.0/UDP 192.168.2.86:5060;branch=z9hG4bK-373730-1b367e5c8080590ed71e86bd3de92fb6
Max-Forwards: 20
Contact: <sip:801@192.168.2.86:5060;udp>
Route: <sip:802@kdogutas.com>
Content-Type: application/sdp
Content-Length: 235
v=0
o=- 3742813239 3742813239 IN IP4 192.168.2.86
s=-
c=IN IP4 192.168.2.86
t=0 0
m=video 0 RTP/AVP 0
m=audio 40000 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=ptime:20
Received processResponse: SIP/2.0 407 Proxy Authentication Required
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 2 INVITE
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>;tag=b059b3424eb911ed130009d1469e6b45.90d1
Via: SIP/2.0/UDP 192.168.2.86:5060;received=78.188.3.82;rport=1030;branch=z9hG4bK-373730-1b367e5c8080590ed71e86bd3de92fb6
Proxy-Authenticate: Digest realm="kdogutas.com",nonce="5b6c4dd400013d17d5ce3e2f006d64f76f721c482d32c154"
Server: NORMSWITCH V3.14 KDOGUTAS
Content-Length: 0
Received processResponse: SIP/2.0 100 Giving a try
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 3 INVITE
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>
Via: SIP/2.0/UDP 192.168.2.86:5060;received=78.188.3.82;rport=1030;branch=z9hG4bK-373730-133c6c506e767d97418dba14fc5725b8
Server: NORMSWITCH V3.14 KDOGUTAS
Content-Length: 0
Received processResponse: SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 192.168.2.86:5060;rport=1030;received=78.188.3.82;branch=z9hG4bK-373730-133c6c506e767d97418dba14fc5725b8
Record-Route: <sip:185.124.84.100;lr;ftag=724913436;did=423.b4fe0cf3>
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>;tag=FZv3gvvt39BXg
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 3 INVITE
Contact: <sip:802@192.168.10.110:5060;transport=udp>
User-Agent: NORM MEDIA SERVER V3.14 © KDOGUTAS
Accept: application/sdp
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REGISTER,REFER,NOTIFY
Supported: timer,path,replaces
Allow-Events: talk,hold,conference,refer
Content-Type: application/sdp
Remote-Party-ID: "#RR001#RA0002#SNA#802" <sip:#RR001#RA0002#SNA#802@kdogutas.com>;party=calling;privacy=off;screen=no
Content-Length: 268
v=0
o=NORMMEDIASERVER 1533797619 1533797620 IN IP4 185.124.84.110
s=NORMMEDIASERVER
c=IN IP4 185.124.84.110
t=0 0
m=audio 26824 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 0 RTP/AVP 19
Received processResponse: SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.2.86:5060;rport=1030;received=78.188.3.82;branch=z9hG4bK-373730-133c6c506e767d97418dba14fc5725b8
Record-Route: <sip:185.124.84.100;lr;ftag=724913436;did=423.b4fe0cf3>
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>;tag=FZv3gvvt39BXg
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 3 INVITE
Contact: <sip:802@192.168.10.110:5060;transport=udp>
User-Agent: NORM MEDIA SERVER V3.14 © KDOGUTAS
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REGISTER,REFER,NOTIFY
Supported: timer,path,replaces
Allow-Events: talk,hold,conference,refer
Content-Type: application/sdp
Remote-Party-ID: "Outbound Call" <sip:802@kdogutas.com>;party=calling;privacy=off;screen=no
Content-Length: 246
v=0
o=NORMMEDIASERVER 1533797619 1533797621 IN IP4 185.124.84.110
s=NORMMEDIASERVER
c=IN IP4 185.124.84.110
t=0 0
m=audio 26824 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
INVITE 200 processResponse Send : ACK sip:802@192.168.10.110:5060;transport=udp SIP/2.0
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 3 ACK
Via: SIP/2.0/UDP 192.168.2.86:5060;branch=z9hG4bK-373730-57d38f452333c14c7e1cc8b65dafde0a
From: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
To: <sip:802@kdogutas.com>;tag=FZv3gvvt39BXg
Max-Forwards: 70
Route: <sip:185.124.84.100;lr;ftag=724913436;did=423.b4fe0cf3>
Contact: <sip:801@192.168.2.86:5060;udp>
Content-Length: 0
Received processRequest: BYE sip:801@78.188.3.82:1030;udp SIP/2.0
Via: SIP/2.0/UDP 185.124.84.100:5060;branch=z9hG4bKf00c.420d8c85.0,SIP/2.0/UDP 192.168.10.110;received=192.168.10.110;rport=5060;branch=z9hG4bK281K63Z85g3vN
Max-Forwards: 70
From: <sip:802@kdogutas.com>;tag=FZv3gvvt39BXg
To: "Kadriye Doğutaş" <sip:801@kdogutas.com>;tag=724913436
Call-ID: 39768268317c68212845c5ac32316c33@192.168.2.86
CSeq: 126576169 BYE
User-Agent: NORM MEDIA SERVER V3.14 © KDOGUTAS
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REGISTER,REFER,NOTIFY
Supported: timer,path,replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0