|
|
@@ -70,7 +70,7 @@ public class VoIP implements SipListenerExt |
|
|
|
{ |
|
|
|
//wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren |
|
|
|
String abc = InetAddress.getLocalHost().getHostAddress(); |
|
|
|
|
|
|
|
/* |
|
|
|
this.myIPAddress = InetAddress.getLocalHost().getHostAddress(); |
|
|
|
|
|
|
|
this.sipFactory = SipFactory.getInstance(); |
|
|
@@ -78,7 +78,7 @@ public class VoIP implements SipListenerExt |
|
|
|
this.properties = new Properties(); |
|
|
|
this.properties.setProperty("javax.sip.STACK_NAME", "stack"); |
|
|
|
this.sipStack = this.sipFactory.createSipStack(this.properties); |
|
|
|
this.messageFactory = this.sipFactory.createMessageFactory(); |
|
|
|
this.messageFactory = this.sipFactory.createMessageFactory(); |
|
|
|
this.headerFactory = this.sipFactory.createHeaderFactory(); |
|
|
|
this.addressFactory = this.sipFactory.createAddressFactory(); |
|
|
|
this.listeningPoint = this.sipStack.createListeningPoint(this.myIPAddress, this.myPort, this.protocolTyp); |
|
|
@@ -86,6 +86,7 @@ public class VoIP implements SipListenerExt |
|
|
|
this.sipProvider.addSipListener(this); |
|
|
|
this.contactAddress = this.addressFactory.createAddress("sip:129@" + this.myIPAddress + ":" + this.myPort); //+ ":" + this.myPort |
|
|
|
this.contactHeader = this.headerFactory.createContactHeader(contactAddress); |
|
|
|
*/ |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
@@ -103,8 +104,12 @@ public class VoIP implements SipListenerExt |
|
|
|
|
|
|
|
public void sendRegister(String serverIP, int serverPort) throws ParseException, InvalidArgumentException, SipException |
|
|
|
{ |
|
|
|
System.out.println("Test"); |
|
|
|
System.out.println(serverIP); |
|
|
|
lg.info("Vorbereiten des Registrierungs Headers"); |
|
|
|
Address addressto = this.addressFactory.createAddress("sip:192.168.100.11"); //evtl. mit Port: sip:192.168.100.11:5060 |
|
|
|
//Address addressto = this.addressFactory.createAddress("sip:"+serverIP); //evtl. mit Port: sip:192.168.100.11:5060 |
|
|
|
Address addressto = this.addressFactory.createAddress("sip:192.168.100.11"); |
|
|
|
System.out.println("Warum" + addressto); |
|
|
|
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag |
|
|
|
URI requestURI = addressto.getURI(); |
|
|
|
CallIdHeader callId = this.sipProvider.getNewCallId(); |
|
|
@@ -121,12 +126,11 @@ public class VoIP implements SipListenerExt |
|
|
|
request.addHeader(allow); |
|
|
|
request.addHeader(expire); |
|
|
|
this.sipProvider.sendRequest(request); |
|
|
|
view.getTxtArea().append("Erfolgreiche Registierung\n"); |
|
|
|
lg.info("Erfolgreiches Senden der Registrierung"); |
|
|
|
} |
|
|
|
public void sendInvitation(String sipaddresse, int serverPort)throws ParseException, InvalidArgumentException, SipException, SdpException |
|
|
|
{ |
|
|
|
Address addressto = this.addressFactory.createAddress(sipaddresse); //evtl. mit Port: sip:192.168.100.11:5060 |
|
|
|
Address addressto = this.addressFactory.createAddress("sip:"+sipaddresse); //evtl. mit Port: sip:192.168.100.11:5060 |
|
|
|
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag |
|
|
|
URI requestURI = addressto.getURI(); |
|
|
|
CallIdHeader callId = this.sipProvider.getNewCallId(); |
|
|
@@ -138,7 +142,7 @@ public class VoIP implements SipListenerExt |
|
|
|
MaxForwardsHeader maxForwards = this.headerFactory.createMaxForwardsHeader(70); |
|
|
|
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); |
|
|
|
ExpiresHeader expire = this.headerFactory.createExpiresHeader(3600); //int value |
|
|
|
Request request = this.messageFactory.createRequest(requestURI, "REGISTER", callId, cSeq, from, to, via, maxForwards); |
|
|
|
Request request = this.messageFactory.createRequest(requestURI, "INVITE", callId, cSeq, from, to, via, maxForwards); |
|
|
|
request.addHeader(contactHeader); |
|
|
|
request.addHeader(allow); |
|
|
|
request.addHeader(expire); |
|
|
@@ -193,7 +197,7 @@ public class VoIP implements SipListenerExt |
|
|
|
//Aktive Kommunikation |
|
|
|
else if ((Request.INVITE).equals(requestEvent.getRequest().getMethod())) // Invite von anderem Benutzer |
|
|
|
{ |
|
|
|
view.getTxtArea().append("Werde von xxx angerufen"); |
|
|
|
view.getTxtArea().append("Werde von xxx angerufen\n"); |
|
|
|
lg.info("Hab Invitation bekommen"); |
|
|
|
try |
|
|
|
{ |
|
|
@@ -213,6 +217,7 @@ public class VoIP implements SipListenerExt |
|
|
|
responsetry.addHeader(supp); |
|
|
|
responsetry.addHeader(allow); |
|
|
|
this.sipProvider.sendResponse(responsetry); |
|
|
|
view.getTxtArea().append("Trying geschickt"); |
|
|
|
lg.info("Trying ist raus"); |
|
|
|
|
|
|
|
//Ringing Message to Server (Responste Ringing) |
|
|
@@ -233,9 +238,8 @@ public class VoIP implements SipListenerExt |
|
|
|
AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold");// für was gebraucht |
|
|
|
responsering.addHeader(allowevent); |
|
|
|
this.sipProvider.sendResponse(responsering); |
|
|
|
System.out.println("Response ist raus"); |
|
|
|
view.getTxtArea().append("Ringing geschickt"); |
|
|
|
|
|
|
|
System.out.println("Erstelle 200 Ok + SDP Header(contentHeader)"); |
|
|
|
//Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP) |
|
|
|
//Sdp Header erstellen nächster Schritt |
|
|
|
System.out.println(requestEvent.getDialog()); |
|
|
@@ -319,6 +323,7 @@ public class VoIP implements SipListenerExt |
|
|
|
request.addHeader(expire); |
|
|
|
request.addHeader(auth); |
|
|
|
this.sipProvider.sendRequest(request); |
|
|
|
view.getTxtArea().append("Erfolgreich registriert"); |
|
|
|
} |
|
|
|
catch (ParseException | SipException | InvalidArgumentException ex) |
|
|
|
{ |