-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
core/src/main/java/com/rtm516/mcxboxbroadcast/core/webrtc/CustomDatagramTransport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.rtm516.mcxboxbroadcast.core.webrtc; | ||
|
||
import org.bouncycastle.tls.DatagramTransport; | ||
import org.ice4j.ice.Component; | ||
import org.ice4j.ice.ComponentSocket; | ||
|
||
import java.io.IOException; | ||
import java.net.DatagramPacket; | ||
|
||
public class CustomDatagramTransport implements DatagramTransport { | ||
private final ComponentSocket socket; | ||
private final Component component; | ||
private final int receiveLimit = 1500; // Typically, a standard MTU size | ||
private final int sendLimit = 1500; // Typically, a standard MTU size | ||
|
||
public CustomDatagramTransport(Component component) { | ||
this.socket = component.getComponentSocket(); | ||
this.component = component; | ||
} | ||
|
||
@Override | ||
public int getReceiveLimit() { | ||
return receiveLimit; | ||
} | ||
|
||
@Override | ||
public int getSendLimit() { | ||
return sendLimit; | ||
} | ||
|
||
@Override | ||
public int receive(byte[] buf, int off, int len, int waitMillis) throws IOException { | ||
DatagramPacket packet = new DatagramPacket(buf, off, len); | ||
socket.receive(packet); | ||
return packet.getLength(); | ||
} | ||
|
||
@Override | ||
public void send(byte[] buf, int off, int len) throws IOException { | ||
DatagramPacket packet = new DatagramPacket(buf, off, len, component.getDefaultCandidate().getTransportAddress()); | ||
socket.send(packet); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
socket.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters