mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-14 08:15:04 +01:00
Restructuring
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
eb9d7ec0d7
commit
3b447ee7d5
@ -301,7 +301,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(GenericOverall genericOverall) {
|
public void onNext(GenericOverall genericOverall) {
|
||||||
callSession = callOverall.getOcs().getData().getSessionId();
|
callSession = callOverall.getOcs().getData().getSessionId();
|
||||||
localPeer = alwaysGetPeerConnectionWrapperForSessionId(callSession, true).
|
localPeer = alwaysGetPeerConnectionWrapperForSessionId(callSession, true).
|
||||||
getPeerConnection();
|
getPeerConnection();
|
||||||
|
|
||||||
//creating local mediastream
|
//creating local mediastream
|
||||||
@ -437,7 +437,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
case "candidate":
|
case "candidate":
|
||||||
NCIceCandidate ncIceCandidate = ncSignalingMessage.getPayload().getIceCandidate();
|
NCIceCandidate ncIceCandidate = ncSignalingMessage.getPayload().getIceCandidate();
|
||||||
IceCandidate iceCandidate = new IceCandidate(ncIceCandidate.getSdpMid(),
|
IceCandidate iceCandidate = new IceCandidate(ncIceCandidate.getSdpMid(),
|
||||||
ncIceCandidate.getSdpMLineIndex(), ncIceCandidate.getCandidate());
|
ncIceCandidate.getSdpMLineIndex(), ncIceCandidate.getCandidate());
|
||||||
peerConnectionWrapper.addCandidate(iceCandidate);
|
peerConnectionWrapper.addCandidate(iceCandidate);
|
||||||
break;
|
break;
|
||||||
case "endOfCandidates":
|
case "endOfCandidates":
|
||||||
@ -485,7 +485,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
for (String sessionId : newSessions) {
|
for (String sessionId : newSessions) {
|
||||||
if (getPeerConnectionWrapperForSessionId(sessionId) == null) {
|
if (getPeerConnectionWrapperForSessionId(sessionId) == null) {
|
||||||
if (sessionId.compareTo(callSession) < 0 ) {
|
if (sessionId.compareTo(callSession) < 0) {
|
||||||
PeerConnectionWrapper connectionWrapper = alwaysGetPeerConnectionWrapperForSessionId(sessionId,
|
PeerConnectionWrapper connectionWrapper = alwaysGetPeerConnectionWrapperForSessionId(sessionId,
|
||||||
false);
|
false);
|
||||||
connectionWrapper.getPeerConnection().createAnswer(connectionWrapper.getMagicSdpObserver(), sdpConstraints);
|
connectionWrapper.getPeerConnection().createAnswer(connectionWrapper.getMagicSdpObserver(), sdpConstraints);
|
||||||
@ -632,7 +632,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||||
public void onMessageEvent(SessionDescriptionSendEvent sessionDescriptionSend) throws IOException {
|
public void onMessageEvent(SessionDescriptionSendEvent sessionDescriptionSend) {
|
||||||
Log.d("MARIO_123", "SENDING " + sessionDescriptionSend.getType());
|
Log.d("MARIO_123", "SENDING " + sessionDescriptionSend.getType());
|
||||||
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
||||||
NCMessageWrapper ncMessageWrapper = new NCMessageWrapper();
|
NCMessageWrapper ncMessageWrapper = new NCMessageWrapper();
|
||||||
@ -656,35 +656,41 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
ncSignalingMessage.setPayload(ncMessagePayload);
|
ncSignalingMessage.setPayload(ncMessagePayload);
|
||||||
ncMessageWrapper.setSignalingMessage(ncSignalingMessage);
|
ncMessageWrapper.setSignalingMessage(ncSignalingMessage);
|
||||||
|
|
||||||
List<NCMessageWrapper> ncMessageWrappers = new ArrayList<>();
|
List<String> awesomeJson = new ArrayList<>();
|
||||||
ncMessageWrappers.add(ncMessageWrapper);
|
try {
|
||||||
|
awesomeJson.add(LoganSquare.serialize(ncMessageWrapper));
|
||||||
|
|
||||||
Log.d("MARIO_123", LoganSquare.serialize(ncMessageWrappers));
|
Log.d("MARIO_JSON", LoganSquare.serialize(ncMessageWrapper));
|
||||||
|
ncApi.sendSignalingMessages(credentials, ApiHelper.getUrlForSignaling(userEntity.getBaseUrl()),
|
||||||
|
awesomeJson)
|
||||||
|
.subscribeOn(Schedulers.newThread())
|
||||||
|
.subscribe(new Observer<GenericOverall>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
ncApi.sendSignalingMessages(credentials, ApiHelper.getUrlForSignaling(userEntity.getBaseUrl()),
|
}
|
||||||
ncMessageWrappers)
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
|
||||||
.subscribe(new Observer<Integer>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onNext(GenericOverall genericOverall) {
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onNext(Integer integer) {
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (IOException exception) {
|
||||||
|
Log.d(TAG, exception.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import com.nextcloud.talk.api.models.json.push.PushRegistrationOverall;
|
|||||||
import com.nextcloud.talk.api.models.json.rooms.RoomOverall;
|
import com.nextcloud.talk.api.models.json.rooms.RoomOverall;
|
||||||
import com.nextcloud.talk.api.models.json.rooms.RoomsOverall;
|
import com.nextcloud.talk.api.models.json.rooms.RoomsOverall;
|
||||||
import com.nextcloud.talk.api.models.json.sharees.ShareesOverall;
|
import com.nextcloud.talk.api.models.json.sharees.ShareesOverall;
|
||||||
import com.nextcloud.talk.api.models.json.signaling.NCMessageWrapper;
|
|
||||||
import com.nextcloud.talk.api.models.json.signaling.SignalingOverall;
|
import com.nextcloud.talk.api.models.json.signaling.SignalingOverall;
|
||||||
import com.nextcloud.talk.api.models.json.userprofile.UserProfileOverall;
|
import com.nextcloud.talk.api.models.json.userprofile.UserProfileOverall;
|
||||||
|
|
||||||
@ -168,8 +167,8 @@ public interface NcApi {
|
|||||||
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
|
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
Observable<Integer> sendSignalingMessages(@Header("Authorization") String authorization, @Url String url,
|
Observable<GenericOverall> sendSignalingMessages(@Header("Authorization") String authorization, @Url String url,
|
||||||
@Body List<NCMessageWrapper> ncMessageWrapper);
|
@Body List<String> message);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
|
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
|
||||||
|
@ -30,10 +30,12 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SessionDescriptionSendEvent {
|
public class SessionDescriptionSendEvent {
|
||||||
@Nullable private final SessionDescription sessionDescription;
|
@Nullable
|
||||||
|
private final SessionDescription sessionDescription;
|
||||||
private final String peerId;
|
private final String peerId;
|
||||||
private final String type;
|
private final String type;
|
||||||
@Nullable private final NCIceCandidate ncIceCandidate;
|
@Nullable
|
||||||
|
private final NCIceCandidate ncIceCandidate;
|
||||||
|
|
||||||
public SessionDescriptionSendEvent(@Nullable SessionDescription sessionDescription, String peerId, String type,
|
public SessionDescriptionSendEvent(@Nullable SessionDescription sessionDescription, String peerId, String type,
|
||||||
@Nullable NCIceCandidate ncIceCandidate) {
|
@Nullable NCIceCandidate ncIceCandidate) {
|
||||||
|
@ -46,6 +46,9 @@ public class PeerConnectionWrapper {
|
|||||||
List<IceCandidate> iceCandidates = new ArrayList<>();
|
List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||||
List<PeerConnection.IceServer> iceServers;
|
List<PeerConnection.IceServer> iceServers;
|
||||||
List<IceCandidate> candidatesToSend = new ArrayList<>();
|
List<IceCandidate> candidatesToSend = new ArrayList<>();
|
||||||
|
List<SessionDescription> sessionDescriptionsQueue = new ArrayList<>();
|
||||||
|
List<NCIceCandidate> localCandidates = new ArrayList<>();
|
||||||
|
List<SessionDescriptionSendEvent> sessionDescriptionSendEvents = new ArrayList<>();
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
private String callToken;
|
private String callToken;
|
||||||
private String nick;
|
private String nick;
|
||||||
@ -55,10 +58,7 @@ public class PeerConnectionWrapper {
|
|||||||
private MagicSdpObserver magicSdpObserver;
|
private MagicSdpObserver magicSdpObserver;
|
||||||
private MagicPeerConnectionObserver magicPeerConnectionObserver;
|
private MagicPeerConnectionObserver magicPeerConnectionObserver;
|
||||||
private boolean isInitiator;
|
private boolean isInitiator;
|
||||||
List<SessionDescription> sessionDescriptionsQueue = new ArrayList<>();
|
|
||||||
|
|
||||||
List<NCIceCandidate> localCandidates = new ArrayList<>();
|
|
||||||
List<SessionDescriptionSendEvent> sessionDescriptionSendEvents = new ArrayList<>();
|
|
||||||
public PeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
public PeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
||||||
List<PeerConnection.IceServer> iceServerList,
|
List<PeerConnection.IceServer> iceServerList,
|
||||||
MediaConstraints mediaConstraints,
|
MediaConstraints mediaConstraints,
|
||||||
@ -97,12 +97,11 @@ public class PeerConnectionWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIceCandidate(IceCandidate iceCandidate) {
|
public void onIceCandidate(IceCandidate iceCandidate) {
|
||||||
Log.d("MARIO_GENERT", "BLA");
|
NCIceCandidate ncIceCandidate = new NCIceCandidate();
|
||||||
NCIceCandidate ncIceCandidate = new NCIceCandidate();
|
ncIceCandidate.setSdpMid(iceCandidate.sdpMid);
|
||||||
ncIceCandidate.setSdpMid(iceCandidate.sdpMid);
|
ncIceCandidate.setSdpMLineIndex(iceCandidate.sdpMLineIndex);
|
||||||
ncIceCandidate.setSdpMLineIndex(iceCandidate.sdpMLineIndex);
|
ncIceCandidate.setCandidate(iceCandidate.sdp);
|
||||||
ncIceCandidate.setCandidate(iceCandidate.sdp);
|
localCandidates.add(ncIceCandidate);
|
||||||
localCandidates.add(ncIceCandidate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -150,23 +149,15 @@ public class PeerConnectionWrapper {
|
|||||||
// For anwering peer connection we set remote SDP and then
|
// For anwering peer connection we set remote SDP and then
|
||||||
// create answer and set local SDP.
|
// create answer and set local SDP.
|
||||||
if (peerConnection.getLocalDescription() != null) {
|
if (peerConnection.getLocalDescription() != null) {
|
||||||
// We've just set our local SDP so time to send it, drain
|
|
||||||
// remote and send local ICE candidates.
|
|
||||||
Log.d("MARIO", "SENDING ANSWER FROM OBSERVER");
|
|
||||||
EventBus.getDefault().post(new SessionDescriptionSendEvent(peerConnection.getLocalDescription
|
EventBus.getDefault().post(new SessionDescriptionSendEvent(peerConnection.getLocalDescription
|
||||||
(),
|
(),
|
||||||
sessionId,
|
sessionId,
|
||||||
"answer", null));
|
"answer", null));
|
||||||
|
// We've just set our local SDP so time to send it, drain
|
||||||
|
// remote and send local ICE candidates.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
peerConnection.createAnswer(new MagicSdpObserver() {
|
peerConnection.createAnswer(magicSdpObserver, mediaConstraints);
|
||||||
@Override
|
|
||||||
public void onCreateSuccess(SessionDescription sessionDescription) {
|
|
||||||
super.onCreateSuccess(sessionDescription);
|
|
||||||
peerConnection.setLocalDescription(magicSdpObserver, sessionDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, mediaConstraints);
|
|
||||||
|
|
||||||
// We've just set remote SDP - do nothing for now -
|
// We've just set remote SDP - do nothing for now -
|
||||||
// answer will be created soon.
|
// answer will be created soon.
|
||||||
@ -183,9 +174,7 @@ public class PeerConnectionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void sendLocalCandidates() {
|
private void sendLocalCandidates() {
|
||||||
Log.d("MARIO", "SENDING LOCAL");
|
|
||||||
for (NCIceCandidate ncIceCandidate : localCandidates) {
|
for (NCIceCandidate ncIceCandidate : localCandidates) {
|
||||||
EventBus.getDefault().post(new SessionDescriptionSendEvent(null, sessionId,
|
EventBus.getDefault().post(new SessionDescriptionSendEvent(null, sessionId,
|
||||||
"candidate", ncIceCandidate));
|
"candidate", ncIceCandidate));
|
||||||
|
Loading…
Reference in New Issue
Block a user