This commit is contained in:
parent
baa3adf8e3
commit
23a96b64eb
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/nbproject/private/
|
||||||
|
/build/
|
||||||
|
/dist/
|
@ -1079,6 +1079,15 @@ is divided into following sections:
|
|||||||
<propertyfile file="${built-jar.properties}">
|
<propertyfile file="${built-jar.properties}">
|
||||||
<entry key="${basedir}" value=""/>
|
<entry key="${basedir}" value=""/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
|
<antcall target="-maybe-call-dep">
|
||||||
|
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||||
|
<param location="${project.rtplib}" name="call.subproject"/>
|
||||||
|
<param location="${project.rtplib}/build.xml" name="call.script"/>
|
||||||
|
<param name="call.target" value="jar"/>
|
||||||
|
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||||
|
<param name="transfer.not.archive.disabled" value="true"/>
|
||||||
|
<param name="transfer.do.jlink" value="false"/>
|
||||||
|
</antcall>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||||
<target depends="init" name="-check-automatic-build">
|
<target depends="init" name="-check-automatic-build">
|
||||||
@ -1735,6 +1744,15 @@ is divided into following sections:
|
|||||||
<propertyfile file="${built-clean.properties}">
|
<propertyfile file="${built-clean.properties}">
|
||||||
<entry key="${basedir}" value=""/>
|
<entry key="${basedir}" value=""/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
|
<antcall target="-maybe-call-dep">
|
||||||
|
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||||
|
<param location="${project.rtplib}" name="call.subproject"/>
|
||||||
|
<param location="${project.rtplib}/build.xml" name="call.script"/>
|
||||||
|
<param name="call.target" value="clean"/>
|
||||||
|
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||||
|
<param name="transfer.not.archive.disabled" value="true"/>
|
||||||
|
<param name="transfer.do.jlink" value="false"/>
|
||||||
|
</antcall>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init" name="-do-clean">
|
<target depends="init" name="-do-clean">
|
||||||
<delete dir="${build.dir}"/>
|
<delete dir="${build.dir}"/>
|
||||||
|
@ -3,6 +3,6 @@ build.xml.script.CRC32=53e451ff
|
|||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.90.1.48
|
build.xml.stylesheet.CRC32=f85dc8f2@1.90.1.48
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
nbproject/build-impl.xml.data.CRC32=f69c57db
|
nbproject/build-impl.xml.data.CRC32=9558f99f
|
||||||
nbproject/build-impl.xml.script.CRC32=2b6978ab
|
nbproject/build-impl.xml.script.CRC32=4415df3d
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.90.1.48
|
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.92.0.48
|
||||||
|
@ -1,21 +1,31 @@
|
|||||||
#Tue Jun 11 17:15:12 CEST 2019
|
#Tue Jun 11 17:15:12 CEST 2019
|
||||||
excludes=
|
excludes=
|
||||||
|
file.reference.jain-sip-api-1.2.1.4.jar-1=C:\\Users\\Tim\\Desktop\\VoIP PA\\VoIPProjekt\\VoIPProjekt\\lib\\jain-sip-api-1.2.1.4.jar
|
||||||
|
file.reference.jain-sip-ri-1.2.327.jar-1=C:\\Users\\Tim\\Desktop\\VoIP PA\\VoIPProjekt\\VoIPProjekt\\lib\\jain-sip-ri-1.2.327.jar
|
||||||
|
file.reference.junit-4.12.jar-1=C:\\Users\\Tim\\Desktop\\VoIP PA\\VoIPProjekt\\VoIPProjekt\\lib\\junit-4.12.jar
|
||||||
|
file.reference.log4j-1.2.17.jar-1=C:\\Users\\Tim\\Desktop\\VoIP PA\\VoIPProjekt\\VoIPProjekt\\lib\\log4j-1.2.17.jar
|
||||||
javac.test.classpath=\
|
javac.test.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}:\
|
${build.classes.dir}:\
|
||||||
${libs.junit_4.classpath}:\
|
${libs.junit_4.classpath}:\
|
||||||
${libs.hamcrest.classpath}
|
${libs.hamcrest.classpath}
|
||||||
run.classpath=${javac.classpath}\:${build.classes.dir}
|
project.rtplib=../../rtplib
|
||||||
javac.processorpath=${javac.classpath}
|
reference.rtplib.jar=${project.rtplib}/dist/rtplib.jar
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
test.src.dir=test
|
test.src.dir=test
|
||||||
file.reference.junit-4.12.jar=lib\\junit-4.12.jar
|
file.reference.junit-4.12.jar=lib\\junit-4.12.jar
|
||||||
run.modulepath=${javac.modulepath}
|
run.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
file.reference.jain-sip-ri-1.2.327.jar=lib\\jain-sip-ri-1.2.327.jar
|
file.reference.jain-sip-ri-1.2.327.jar=lib\\jain-sip-ri-1.2.327.jar
|
||||||
build.sysclasspath=ignore
|
build.sysclasspath=ignore
|
||||||
debug.modulepath=${run.modulepath}
|
debug.modulepath=${run.modulepath}
|
||||||
javac.compilerargs=
|
javac.compilerargs=-g
|
||||||
javadoc.noindex=false
|
javadoc.noindex=false
|
||||||
javadoc.private=false
|
javadoc.private=false
|
||||||
file.reference.log4j-1.2.17.jar=lib\\log4j-1.2.17.jar
|
file.reference.log4j-1.2.17.jar=lib\\log4j-1.2.17.jar
|
||||||
@ -24,7 +34,7 @@ endorsed.classpath=
|
|||||||
main.class=phone.Start
|
main.class=phone.Start
|
||||||
junit.selected.version=4
|
junit.selected.version=4
|
||||||
source.encoding=UTF-8
|
source.encoding=UTF-8
|
||||||
javac.source=11
|
javac.source=1.8
|
||||||
includes=**
|
includes=**
|
||||||
javadoc.use=true
|
javadoc.use=true
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
@ -43,9 +53,16 @@ javac.processormodulepath=
|
|||||||
run.jvmargs=
|
run.jvmargs=
|
||||||
jlink.additionalmodules=
|
jlink.additionalmodules=
|
||||||
javadoc.encoding=${source.encoding}
|
javadoc.encoding=${source.encoding}
|
||||||
javac.classpath=${file.reference.jain-sip-api-1.2.1.4.jar}\:${file.reference.jain-sip-ri-1.2.327.jar}\:${file.reference.junit-4.12.jar}\:${file.reference.log4j-1.2.17.jar}
|
javac.classpath=\
|
||||||
|
${file.reference.jain-sip-api-1.2.1.4.jar}:\
|
||||||
|
${file.reference.jain-sip-ri-1.2.327.jar}:\
|
||||||
|
${file.reference.junit-4.12.jar}:\
|
||||||
|
${file.reference.log4j-1.2.17.jar}:\
|
||||||
|
${libs.RTPLibrary.classpath}:\
|
||||||
|
${reference.rtplib.jar}
|
||||||
mkdist.disabled=false
|
mkdist.disabled=false
|
||||||
run.test.modulepath=${javac.test.modulepath}
|
run.test.modulepath=\
|
||||||
|
${javac.test.modulepath}
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
dist.jlink.dir=${dist.dir}/jlink
|
dist.jlink.dir=${dist.dir}/jlink
|
||||||
dist.jar=${dist.dir}/Phone.jar
|
dist.jar=${dist.dir}/Phone.jar
|
||||||
@ -62,19 +79,26 @@ annotation.processing.source.output=${build.generated.sources.dir}/ap-source-out
|
|||||||
build.generated.dir=${build.dir}/generated
|
build.generated.dir=${build.dir}/generated
|
||||||
javadoc.version=false
|
javadoc.version=false
|
||||||
application.title=Phone
|
application.title=Phone
|
||||||
javac.test.modulepath=${javac.modulepath}
|
javac.test.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
debug.test.classpath=${run.test.classpath}
|
debug.test.classpath=${run.test.classpath}
|
||||||
javac.external.vm=true
|
javac.external.vm=true
|
||||||
javac.target=11
|
javac.target=1.8
|
||||||
platform.active=default_platform
|
platform.active=default_platform
|
||||||
manifest.file=manifest.mf
|
manifest.file=manifest.mf
|
||||||
javadoc.html5=false
|
javadoc.html5=false
|
||||||
javac.test.processorpath=${javac.test.classpath}
|
javac.test.processorpath=${javac.test.classpath}
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
run.test.classpath=${javac.test.classpath}\:${build.test.classes.dir}
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
dist.jlink.output=${dist.jlink.dir}/Phone
|
dist.jlink.output=${dist.jlink.dir}/Phone
|
||||||
annotation.processing.run.all.processors=true
|
annotation.processing.run.all.processors=true
|
||||||
javac.modulepath=
|
javac.modulepath=\
|
||||||
|
${file.reference.jain-sip-api-1.2.1.4.jar-1}:\
|
||||||
|
${file.reference.jain-sip-ri-1.2.327.jar-1}:\
|
||||||
|
${file.reference.junit-4.12.jar-1}:\
|
||||||
|
${file.reference.log4j-1.2.17.jar-1}
|
||||||
src.dir=src
|
src.dir=src
|
||||||
jlink.additionalparam=
|
jlink.additionalparam=
|
||||||
debug.classpath=${run.classpath}
|
debug.classpath=${run.classpath}
|
||||||
|
@ -11,5 +11,15 @@
|
|||||||
<root id="test.src.dir"/>
|
<root id="test.src.dir"/>
|
||||||
</test-roots>
|
</test-roots>
|
||||||
</data>
|
</data>
|
||||||
|
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||||
|
<reference>
|
||||||
|
<foreign-project>rtplib</foreign-project>
|
||||||
|
<artifact-type>jar</artifact-type>
|
||||||
|
<script>build.xml</script>
|
||||||
|
<target>jar</target>
|
||||||
|
<clean-target>clean</clean-target>
|
||||||
|
<id>jar</id>
|
||||||
|
</reference>
|
||||||
|
</references>
|
||||||
</configuration>
|
</configuration>
|
||||||
</project>
|
</project>
|
||||||
|
@ -3,56 +3,75 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controller.commands;
|
package controller.commands;
|
||||||
|
|
||||||
import controller.CommandInterface;
|
import controller.CommandInterface;
|
||||||
import gui.Hauptfenster;
|
import gui.Hauptfenster;
|
||||||
|
import static java.lang.Thread.sleep;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
|
import model.SoundSenderDemo;
|
||||||
|
//import jlibrtpDemos.SoundSenderDemo;
|
||||||
import logger.OhmLogger;
|
import logger.OhmLogger;
|
||||||
import model.SIPmodel;
|
import model.SIPmodel;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jan
|
* @author Jan Fehlende Ergänzungen(timer nach 10 sec für abbruchbedingung +
|
||||||
* Fehlende Ergänzungen(timer nach 10 sec für abbruchbedingung + bedingung falls angenommen wurde -> Boolean)
|
* bedingung falls angenommen wurde -> Boolean)
|
||||||
*/
|
*/
|
||||||
public class CommandInvite implements CommandInterface
|
public class CommandInvite implements CommandInterface {
|
||||||
{
|
|
||||||
private static final Logger lginvite = OhmLogger.getLogger();
|
|
||||||
private SIPmodel model;
|
|
||||||
private Hauptfenster view;
|
|
||||||
public CommandInvite(SIPmodel model, Hauptfenster view)
|
|
||||||
{
|
|
||||||
this.model = model;
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
view.getTxtArea().append("Einladung an " + view.getTxtcallIP().getText() + " gesendet\n");
|
|
||||||
model.sendInvitation(view.getTxtcallIP().getText(),view.getTxtServerIP().getText(), 5078);
|
|
||||||
}
|
|
||||||
catch (SipException ex)
|
|
||||||
{
|
|
||||||
view.getTxtArea().append("Einladung fehlgeschlagen\n");
|
|
||||||
lginvite.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void undo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private static final Logger lginvite = OhmLogger.getLogger();
|
||||||
public Boolean isundoable()
|
private SIPmodel model;
|
||||||
{
|
private Hauptfenster view;
|
||||||
return false;
|
|
||||||
}
|
public CommandInvite(SIPmodel model, Hauptfenster view) {
|
||||||
|
this.model = model;
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
view.getTxtArea().append("Einladung an " + view.getTxtcallIP().getText() + " gesendet\n");
|
||||||
|
model.sendInvitation(view.getTxtcallIP().getText(), view.getTxtServerIP().getText(), 5078);
|
||||||
|
} catch (SipException ex) {
|
||||||
|
view.getTxtArea().append("Einladung fehlgeschlagen\n");
|
||||||
|
lginvite.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
sleep(5000);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Starte RTP Session");
|
||||||
|
//String[] s = null;
|
||||||
|
SoundSenderDemo aDemo = null;
|
||||||
|
try {
|
||||||
|
aDemo = new SoundSenderDemo(true);
|
||||||
|
} catch (UnknownHostException | InterruptedException ex) {
|
||||||
|
Logger.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
aDemo.SendDemo(null);
|
||||||
|
} catch (UnknownHostException | InterruptedException ex) {
|
||||||
|
Logger.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
System.out.println("Beende RTP Session");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isundoable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class AudioRinging
|
|||||||
{
|
{
|
||||||
//Normalerweise so da Betriebssystemunabhängig aber ka wo der Fehler ist
|
//Normalerweise so da Betriebssystemunabhängig aber ka wo der Fehler ist
|
||||||
//String file = (File.separator+"phone"+File.separator+"SoundDateien"+ File.separator+"RingingPhone.wav");
|
//String file = (File.separator+"phone"+File.separator+"SoundDateien"+ File.separator+"RingingPhone.wav");
|
||||||
audioFile = new File(getClass().getResource("/SoundDateien/RingingPhone.wav").getFile());
|
audioFile = new File("C:\\Users\\Tim\\Desktop\\VoIP PA\\project\\VoIPProjekt\\src\\SoundDateien\\RingingPhone.wav");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
format = AudioSystem.getAudioInputStream(audioFile).getFormat();
|
format = AudioSystem.getAudioInputStream(audioFile).getFormat();
|
||||||
|
@ -55,7 +55,7 @@ public class SIPSessionDescription
|
|||||||
//Media Bod
|
//Media Bod
|
||||||
if (anfrage == true)
|
if (anfrage == true)
|
||||||
{
|
{
|
||||||
mediavec.add(sdpFactory.createMediaDescription("audio", 6022, 1, "RTP/AVP", codsRTP)); //(Übertragungstyp, Port, anzahl der Ports, Verbindungstyp,..)
|
mediavec.add(sdpFactory.createMediaDescription("audio", 5004, 1, "RTP/AVP", codsRTP)); //(Übertragungstyp, Port, anzahl der Ports, Verbindungstyp,..)
|
||||||
mediavec.add(sdpFactory.createAttribute("sendrecv", null));
|
mediavec.add(sdpFactory.createAttribute("sendrecv", null));
|
||||||
for (int i = 0; i < codsRTP.length; i++)
|
for (int i = 0; i < codsRTP.length; i++)
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ public class SIPSessionDescription
|
|||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
String[] tempArray = tempList.toArray(new String[tempList.size()]);
|
String[] tempArray = tempList.toArray(new String[tempList.size()]);
|
||||||
mediavec.add(sdpFactory.createMediaDescription("audio", 6022, 1, "RTP/AVP", tempArray)); //(Übertragungstyp, Port, anzahl der Ports, Verbindungstyp,..)
|
mediavec.add(sdpFactory.createMediaDescription("audio", 5004, 1, "RTP/AVP", tempArray)); //(Übertragungstyp, Port, anzahl der Ports, Verbindungstyp,..)
|
||||||
mediavec.add(sdpFactory.createAttribute("sendrecv", null));
|
mediavec.add(sdpFactory.createAttribute("sendrecv", null));
|
||||||
}
|
}
|
||||||
sessionDescription.setAttributes(mediavec);
|
sessionDescription.setAttributes(mediavec);
|
||||||
|
@ -58,7 +58,7 @@ public class SIPmodel implements SipListenerExt
|
|||||||
private int myPort = 5060;
|
private int myPort = 5060;
|
||||||
private String myName = "129";
|
private String myName = "129";
|
||||||
public String protocolTyp = "UDP";
|
public String protocolTyp = "UDP";
|
||||||
public String myIPAddress;
|
public String myIPAddress = "192.168.100.30";
|
||||||
public String proxyAddress;
|
public String proxyAddress;
|
||||||
public CallIdHeader callID;
|
public CallIdHeader callID;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class SIPmodel implements SipListenerExt
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren
|
//wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren
|
||||||
this.myIPAddress = InetAddress.getLocalHost().getHostAddress();
|
//this.myIPAddress = InetAddress.getLocalHost().getHostAddress();
|
||||||
this.sipFactory = SipFactory.getInstance();
|
this.sipFactory = SipFactory.getInstance();
|
||||||
this.sipFactory.setPathName("gov.nist");
|
this.sipFactory.setPathName("gov.nist");
|
||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
|
255
src/model/SoundSenderDemo.java
Normal file
255
src/model/SoundSenderDemo.java
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
/* This file is based on
|
||||||
|
* http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml
|
||||||
|
* Please see the site for license information.
|
||||||
|
*/
|
||||||
|
package model;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.DataLine;
|
||||||
|
import javax.sound.sampled.FloatControl;
|
||||||
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
|
import javax.sound.sampled.SourceDataLine;
|
||||||
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
|
import java.lang.String;
|
||||||
|
import static java.lang.Thread.sleep;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import jlibrtp.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Arne Kepp
|
||||||
|
*/
|
||||||
|
public class SoundSenderDemo implements RTPAppIntf {
|
||||||
|
|
||||||
|
public RTPSession rtpSession = null;
|
||||||
|
static int pktCount = 0;
|
||||||
|
static int dataCount = 0;
|
||||||
|
private String filename;
|
||||||
|
private final int EXTERNAL_BUFFER_SIZE = 1024;
|
||||||
|
SourceDataLine auline;
|
||||||
|
private Position curPosition;
|
||||||
|
boolean local;
|
||||||
|
|
||||||
|
enum Position {
|
||||||
|
LEFT, RIGHT, NORMAL
|
||||||
|
};
|
||||||
|
|
||||||
|
public SoundSenderDemo(boolean isLocal) throws UnknownHostException, InterruptedException {
|
||||||
|
DatagramSocket rtpSocket = null;
|
||||||
|
DatagramSocket rtcpSocket = null;
|
||||||
|
|
||||||
|
// for(int i=5000; i<=6000; i++)
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
// rtpSocket = new DatagramSocket(i);
|
||||||
|
// rtpSocket.close();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// System.out.println("RTPSession failed to obtain port"+i);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
InetAddress myIP = InetAddress.getByName("192.168.100.30");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// rtpSocket = new DatagramSocket(5004, myIP);
|
||||||
|
// rtcpSocket = new DatagramSocket(5005, myIP);
|
||||||
|
// } catch (SocketException e) {
|
||||||
|
// System.out.println("RTPSession failed to obtain port");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
rtpSocket = new DatagramSocket(null);
|
||||||
|
InetSocketAddress myInetSocketAddress = new InetSocketAddress(5004);
|
||||||
|
rtpSocket.bind(myInetSocketAddress);
|
||||||
|
sleep(2000);
|
||||||
|
} catch (SocketException e) {
|
||||||
|
System.out.println("RTPSession failed to obtain port");
|
||||||
|
rtpSocket.close();
|
||||||
|
rtcpSocket.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rtpSession = new RTPSession(rtpSocket, rtcpSocket);
|
||||||
|
rtpSession.RTPSessionRegister(this, null, null);
|
||||||
|
System.out.println("CNAME: " + rtpSession.CNAME());
|
||||||
|
this.local = isLocal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public void SendDemo(String[] args) throws UnknownHostException, InterruptedException {
|
||||||
|
args = new String[4];
|
||||||
|
args[1] = "192.168.100.249";
|
||||||
|
args[0] = "C:\\Users\\Tim\\Desktop\\VoIP PA\\project\\VoIPProjekt\\src\\SoundDateien\\RingingPhone.wav";
|
||||||
|
args[2] = "5004";
|
||||||
|
args[3] = "5005";
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
System.out.println("args[" + i + "]" + args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (args.length == 0) {
|
||||||
|
// args = new String[4];
|
||||||
|
// args[1] = "192.168.100.249";
|
||||||
|
// args[0] = "C:\\Users\\Tim\\Desktop\\VoIP PA\\project\\VoIPProjekt\\src\\SoundDateien\\RingingPhone.wav";
|
||||||
|
// args[2] = "5004";
|
||||||
|
// args[3] = "5005";
|
||||||
|
// }
|
||||||
|
SoundSenderDemo aDemo = new SoundSenderDemo(false);
|
||||||
|
Participant p = new Participant("192.168.100.249", Integer.parseInt(args[2]), Integer.parseInt(args[2]) + 1);
|
||||||
|
aDemo.rtpSession.addParticipant(p);
|
||||||
|
aDemo.filename = args[0];
|
||||||
|
aDemo.run();
|
||||||
|
System.out.println("pktCount: " + pktCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void receiveData(DataFrame dummy1, Participant dummy2) {
|
||||||
|
// We don't expect any data.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void userEvent(int type, Participant[] participant) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public int frameSize(int payloadType) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if (RTPSession.rtpDebugLevel > 1) {
|
||||||
|
System.out.println("-> Run()");
|
||||||
|
}
|
||||||
|
File soundFile = new File(filename);
|
||||||
|
if (!soundFile.exists()) {
|
||||||
|
System.err.println("Wave file not found: " + filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioInputStream audioInputStream = null;
|
||||||
|
try {
|
||||||
|
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
|
||||||
|
} catch (UnsupportedAudioFileException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//AudioFormat format = audioInputStream.getFormat();
|
||||||
|
AudioFormat.Encoding encoding = new AudioFormat.Encoding("PCM_SIGNED");
|
||||||
|
AudioFormat format = new AudioFormat(encoding, ((float) 8000.0), 16, 1, 2, ((float) 8000.0), false);
|
||||||
|
System.out.println(format.toString());
|
||||||
|
|
||||||
|
if (!this.local) {
|
||||||
|
// To time the output correctly, we also play at the input:
|
||||||
|
auline = null;
|
||||||
|
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
|
||||||
|
|
||||||
|
try {
|
||||||
|
auline = (SourceDataLine) AudioSystem.getLine(info);
|
||||||
|
auline.open(format);
|
||||||
|
} catch (LineUnavailableException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auline.isControlSupported(FloatControl.Type.PAN)) {
|
||||||
|
FloatControl pan = (FloatControl) auline
|
||||||
|
.getControl(FloatControl.Type.PAN);
|
||||||
|
if (this.curPosition == Position.RIGHT) {
|
||||||
|
pan.setValue(1.0f);
|
||||||
|
} else if (this.curPosition == Position.LEFT) {
|
||||||
|
pan.setValue(-1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auline.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
int nBytesRead = 0;
|
||||||
|
byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
while (nBytesRead != -1 && pktCount < 200) {
|
||||||
|
nBytesRead = audioInputStream.read(abData, 0, abData.length);
|
||||||
|
|
||||||
|
if (nBytesRead >= 0) {
|
||||||
|
rtpSession.sendData(abData);
|
||||||
|
//if(!this.local) {
|
||||||
|
auline.write(abData, 0, abData.length);
|
||||||
|
|
||||||
|
//dataCount += abData.length;
|
||||||
|
//if(pktCount % 10 == 0) {
|
||||||
|
// System.out.println("pktCount:" + pktCount + " dataCount:" + dataCount);
|
||||||
|
//
|
||||||
|
// long test = 0;
|
||||||
|
// for(int i=0; i<abData.length; i++) {
|
||||||
|
// test += abData[i];
|
||||||
|
// }
|
||||||
|
// System.out.println(Long.toString(test));
|
||||||
|
//}
|
||||||
|
pktCount++;
|
||||||
|
//if(pktCount == 100) {
|
||||||
|
// System.out.println("Time!!!!!!!!! " + Long.toString(System.currentTimeMillis()));
|
||||||
|
//}
|
||||||
|
//System.out.println("yep");
|
||||||
|
}
|
||||||
|
if (pktCount == 100) {
|
||||||
|
Enumeration<Participant> iter = this.rtpSession.getParticipants();
|
||||||
|
System.out.println("iter " + iter.hasMoreElements());
|
||||||
|
Participant p = null;
|
||||||
|
|
||||||
|
//while (iter.hasMoreElements()) {
|
||||||
|
p = iter.nextElement();
|
||||||
|
|
||||||
|
String name = "name";
|
||||||
|
byte[] nameBytes = name.getBytes();
|
||||||
|
String data = "abcd";
|
||||||
|
byte[] dataBytes = data.getBytes();
|
||||||
|
|
||||||
|
int ret = rtpSession.sendRTCPAppPacket(p.getSSRC(), 0, nameBytes, dataBytes);
|
||||||
|
System.out.println("!!!!!!!!!!!! ADDED APPLICATION SPECIFIC " + ret);
|
||||||
|
continue;
|
||||||
|
//}
|
||||||
|
// if (p == null) {
|
||||||
|
// System.out.println("No participant with SSRC available :(");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.out.println("Time: " + (System.currentTimeMillis() - start) / 1000 + " s");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rtpSession.endSession();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (RTPSession.rtpDebugLevel > 1) {
|
||||||
|
System.out.println("<- Run()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user