mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 04:55:29 +03:00
Improve data channel handling
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
a621401520
commit
b98bb93e44
3 changed files with 19 additions and 16 deletions
|
@ -298,7 +298,6 @@ public class CallActivity extends AppCompatActivity {
|
|||
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("internalSctpDataChannels", "true"));
|
||||
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
|
||||
|
||||
|
||||
ncApi.joinRoom(credentials, ApiHelper.getUrlForJoinRoom(userEntity.getBaseUrl(), roomToken))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -547,7 +546,7 @@ public class CallActivity extends AppCompatActivity {
|
|||
return magicPeerConnectionWrapper;
|
||||
} else {
|
||||
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
||||
iceServers, sdpConstraints, sessionId);
|
||||
iceServers, sdpConstraints, sessionId, callSession);
|
||||
magicPeerConnectionWrapper.getPeerConnection().addStream(localMediaStream);
|
||||
magicPeerConnectionWrapperList.add(magicPeerConnectionWrapper);
|
||||
return magicPeerConnectionWrapper;
|
||||
|
|
|
@ -36,7 +36,6 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.support.v7.widget.SearchView;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -237,7 +236,6 @@ public class CallsListController extends BaseController implements SearchView.On
|
|||
|
||||
callItems = new ArrayList<>();
|
||||
|
||||
Log.d("MARIO", userEntity.getUsername());
|
||||
roomsQueryDisposable = ncApi.getRooms(ApiHelper.getCredentials(userEntity.getUsername(),
|
||||
userEntity.getToken()), ApiHelper.getUrlForGetRooms(userEntity.getBaseUrl()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
|
|
|
@ -48,9 +48,10 @@ public class MagicPeerConnectionWrapper {
|
|||
private static String TAG = "MagicPeerConnectionWrapper";
|
||||
private static PeerConnection peerConnection;
|
||||
List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||
List<PeerConnection.IceServer> iceServers;
|
||||
List<NCIceCandidate> localCandidates = new ArrayList<>();
|
||||
private List<PeerConnection.IceServer> iceServers;
|
||||
private List<NCIceCandidate> localCandidates = new ArrayList<>();
|
||||
private String sessionId;
|
||||
private String localSession;
|
||||
private String nick;
|
||||
private MediaConstraints mediaConstraints;
|
||||
private DataChannel magicDataChannel;
|
||||
|
@ -62,19 +63,22 @@ public class MagicPeerConnectionWrapper {
|
|||
public MagicPeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
||||
List<PeerConnection.IceServer> iceServerList,
|
||||
MediaConstraints mediaConstraints,
|
||||
String sessionId) {
|
||||
String sessionId, String localSession) {
|
||||
|
||||
this.iceServers = iceServerList;
|
||||
|
||||
peerConnection = peerConnectionFactory.createPeerConnection(iceServerList, mediaConstraints,
|
||||
new MagicPeerConnectionObserver());
|
||||
|
||||
DataChannel.Init init = new DataChannel.Init();
|
||||
init.negotiated = false;
|
||||
magicDataChannel = peerConnection.createDataChannel("status", init);
|
||||
magicDataChannel.registerObserver(new MagicDataChannelObserver());
|
||||
if (sessionId.compareTo(localSession) < 0) {
|
||||
DataChannel.Init init = new DataChannel.Init();
|
||||
init.negotiated = false;
|
||||
magicDataChannel = peerConnection.createDataChannel("status", init);
|
||||
magicDataChannel.registerObserver(new MagicDataChannelObserver());
|
||||
}
|
||||
|
||||
this.sessionId = sessionId;
|
||||
this.localSession = localSession;
|
||||
this.mediaConstraints = mediaConstraints;
|
||||
|
||||
magicSdpObserver = new MagicSdpObserver();
|
||||
|
@ -119,7 +123,7 @@ public class MagicPeerConnectionWrapper {
|
|||
buffer = ByteBuffer.wrap(LoganSquare.serialize(dataChannelMessage).getBytes());
|
||||
magicDataChannel.send(new DataChannel.Buffer(buffer, false));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, "Failed to send channel data");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +166,6 @@ public class MagicPeerConnectionWrapper {
|
|||
sendChannelData(new DataChannelMessage("videoOn"));
|
||||
sendChannelData(new DataChannelMessage("audioOn"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -187,12 +190,11 @@ public class MagicPeerConnectionWrapper {
|
|||
|
||||
@Override
|
||||
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
||||
|
||||
Log.d("MARIO", signalingState.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +243,11 @@ public class MagicPeerConnectionWrapper {
|
|||
|
||||
@Override
|
||||
public void onDataChannel(DataChannel dataChannel) {
|
||||
|
||||
Log.d("MARIO", "DATA");
|
||||
if (dataChannel.label().equals("status")) {
|
||||
magicDataChannel = dataChannel;
|
||||
magicDataChannel.registerObserver(new MagicDataChannelObserver());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue