Restructuring

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-11-15 18:14:06 +01:00
parent eb9d7ec0d7
commit 3b447ee7d5
4 changed files with 47 additions and 51 deletions

View File

@ -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,22 +656,22 @@ 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()), ncApi.sendSignalingMessages(credentials, ApiHelper.getUrlForSignaling(userEntity.getBaseUrl()),
ncMessageWrappers) awesomeJson)
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.subscribe(new Observer<Integer>() { .subscribe(new Observer<GenericOverall>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
} }
@Override @Override
public void onNext(Integer integer) { public void onNext(GenericOverall genericOverall) {
} }
@ -685,6 +685,12 @@ public class CallActivity extends AppCompatActivity {
} }
}); });
} catch (IOException exception) {
Log.d(TAG, exception.getLocalizedMessage());
}
} }

View File

@ -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

View File

@ -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) {

View File

@ -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,7 +97,6 @@ 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);
@ -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));