Skip to content

Commit

Permalink
adding WebRTC user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
angel-ayala committed Aug 13, 2024
1 parent 08657de commit f490767
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public class DJIStreamer {
private final Hashtable<String, WebRTCClient> ongoingConnections = new Hashtable<>();
private final Model aircraftModel;

public DJIStreamer(Context context, Model aircraftModel){
public DJIStreamer(Context context, Model aircraftModel, String stunServer){
this.aircraftModel = aircraftModel;
this.context = context;
setupSocketEvent();
setupSocketEvent(stunServer);
}

private WebRTCClient getClient(String socketID){
Expand All @@ -35,9 +35,9 @@ private void removeClient(String socketID){
ongoingConnections.remove(socketID);
}

private WebRTCClient addNewClient(String socketID){
private WebRTCClient addNewClient(String socketID, String stunServer){
VideoCapturer videoCapturer = new DJIVideoCapturer(aircraftModel);
WebRTCClient client = new WebRTCClient(socketID, context, videoCapturer, new WebRTCMediaOptions());
WebRTCClient client = new WebRTCClient(socketID, context, videoCapturer, new WebRTCMediaOptions(), stunServer);
client.setConnectionChangedListener(new WebRTCClient.PeerConnectionChangedListener() {
@Override
public void onDisconnected() {
Expand All @@ -49,7 +49,7 @@ public void onDisconnected() {
return client;
}

private void setupSocketEvent(){
private void setupSocketEvent(String stunServer){
Socket.getInstance().with(context).setOnEventResponseListener("webrtc_msg", (event, data) -> {
try {
JSONObject jsonData = new JSONObject(data);
Expand All @@ -59,7 +59,7 @@ private void setupSocketEvent(){

if (client == null){
// A new client wants to establish a P2P
client = addNewClient(peerSocketID);
client = addNewClient(peerSocketID, stunServer);
}

// Then just pass the message to the client
Expand Down

0 comments on commit f490767

Please sign in to comment.