java使用jain api上的编解码器信息自动创建sdp消息
我想使用jain sip应用程序在java中执行相互搜索。注册过程中没有问题,但由于搜索过程中的编解码器不兼容,我只需拨打和接听电话,但通话不是声音传输。 SDP中有一个特定的编解码器信息,对应于我发送到服务器的入侵请求。我应该根据这些信息进行编码。 此外,一些编解码器的有效负载类型值是动态确定的。如何提取这些动态值并创建其他属性。取决于我应该做什么pcma或电话活动
我想用PC8做视频,用VP8做视频。 默认情况下,我创建pcma,但还有另一个名为telephony event的编解码器。我该怎么做才对呢
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;
}
此时我需要输入正确的有效负载类型值和编码值,但我无法以健康的方式创建正确的媒体fmtp值或其他所需参数。是否可以从一个位置提取音频格式值,并访问编码和pt值?这些值是如何确定的。我怎样才能召开双方的会议
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
共 (0) 个答案