mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 03:23:07 +00:00
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:
parent
54e365a304
commit
ac1380bd4c
@ -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) {
|
||||||
|
@ -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,17 +108,13 @@ 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));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user