Skip to content

Commit

Permalink
- send and receive udp packets only from the specified address
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Dec 3, 2010
1 parent d027a50 commit a01541e
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import org.red5.server.api.IScope;
import org.red5.server.api.stream.IBroadcastStream;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Vector;

public class CallAgent extends CallListenerAdapter implements CallStreamObserver {
Expand Down Expand Up @@ -174,22 +176,26 @@ private void createVoiceStreams() {
int localAudioPort = SessionDescriptorUtil.getLocalAudioPort(localSdp);

SipConnectInfo connInfo = new SipConnectInfo(localSocket, remoteMediaAddress, remoteAudioPort);

log.debug("[localAudioPort=" + localAudioPort + ",remoteAudioPort=" + remoteAudioPort + "]");
try {
localSocket.connect(InetAddress.getByName(remoteMediaAddress), remoteAudioPort);
log.debug("[localAudioPort=" + localAudioPort + ",remoteAudioPort=" + remoteAudioPort + "]");

if (userProfile.audio && localAudioPort != 0 && remoteAudioPort != 0) {
if ((callStream == null) && (sipCodec != null)) {
try {
callStream = callStreamFactory.createCallStream(sipCodec, connInfo);
callStream.addCallStreamObserver(this);
callStream.start();
notifyListenersOnCallConnected(callStream.getTalkStreamName(), callStream.getListenStreamName());
} catch (Exception e) {
log.error("Failed to create Call Stream.");
System.out.println(StackTraceUtil.getStackTrace(e));
}
}
}
if (userProfile.audio && localAudioPort != 0 && remoteAudioPort != 0) {
if ((callStream == null) && (sipCodec != null)) {
try {
callStream = callStreamFactory.createCallStream(sipCodec, connInfo);
callStream.addCallStreamObserver(this);
callStream.start();
notifyListenersOnCallConnected(callStream.getTalkStreamName(), callStream.getListenStreamName());
} catch (Exception e) {
log.error("Failed to create Call Stream.");
System.out.println(StackTraceUtil.getStackTrace(e));
}
}
}
} catch (UnknownHostException e1) {
log.error(StackTraceUtil.getStackTrace(e1));
}
}


Expand Down

0 comments on commit a01541e

Please sign in to comment.