Fix force-close if the stream is aborted before RTP is connected. Fix address already in use exception on RTCP socket.

This commit is contained in:
Cameron Gutman 2013-11-10 05:49:00 -05:00
parent 54e365a304
commit ac1380bd4c
2 changed files with 11 additions and 8 deletions

View File

@ -53,7 +53,9 @@ public class NvAudioStream {
} }
// Close the socket to interrupt the receive thread // Close the socket to interrupt the receive thread
rtp.close(); if (rtp != null) {
rtp.close();
}
// Wait for threads to terminate // Wait for threads to terminate
for (Thread t : threads) { for (Thread t : threads) {

View File

@ -36,7 +36,7 @@ public class NvVideoStream {
private LinkedBlockingQueue<AvRtpPacket> packets = new LinkedBlockingQueue<AvRtpPacket>(); private LinkedBlockingQueue<AvRtpPacket> packets = new LinkedBlockingQueue<AvRtpPacket>();
private RTPSession session; private RTPSession session;
private DatagramSocket rtp; private DatagramSocket rtp, rtcp;
private LinkedList<Thread> threads = new LinkedList<Thread>(); private LinkedList<Thread> threads = new LinkedList<Thread>();
@ -58,7 +58,12 @@ public class NvVideoStream {
} }
// Close the socket to interrupt the receive thread // Close the socket to interrupt the receive thread
rtp.close(); if (rtp != null) {
rtp.close();
}
if (rtcp != null) {
rtcp.close();
}
// Wait for threads to terminate // Wait for threads to terminate
for (Thread t : threads) { for (Thread t : threads) {
@ -103,16 +108,12 @@ public class NvVideoStream {
public void setupRtpSession(String host) throws SocketException public void setupRtpSession(String host) throws SocketException
{ {
DatagramSocket rtcp;
rtp = new DatagramSocket(RTP_PORT); rtp = new DatagramSocket(RTP_PORT);
rtcp = new DatagramSocket(RTCP_PORT);
rtp.setReceiveBufferSize(2097152); rtp.setReceiveBufferSize(2097152);
System.out.println("RECV BUF: "+rtp.getReceiveBufferSize()); System.out.println("RECV BUF: "+rtp.getReceiveBufferSize());
System.out.println("SEND BUF: "+rtp.getSendBufferSize()); System.out.println("SEND BUF: "+rtp.getSendBufferSize());
rtcp = new DatagramSocket(RTCP_PORT);
session = new RTPSession(rtp, rtcp); session = new RTPSession(rtp, rtcp);
session.addParticipant(new Participant(host, RTP_PORT, RTCP_PORT)); session.addParticipant(new Participant(host, RTP_PORT, RTCP_PORT));