Search in sources :

Example 1 with CallMember

use of im.actor.core.viewmodel.CallMember in project actor-platform by actorapp.

the class JsBindingModule method getCall.

public JsBindedValue<JsCall> getCall(String id) {
    if (!calls.containsKey(id)) {
        final CallVM callModel = messenger.getCall(Long.parseLong(id));
        final JsBindedValue<JsCall> jsCall = new JsBindedValue<>(JsCall.create(messenger, callModel));
        callModel.getState().subscribe(new ValueChangedListener<CallState>() {

            @Override
            public void onChanged(CallState val, Value<CallState> valueModel) {
                jsCall.changeValue(JsCall.create(messenger, callModel));
            }
        });
        callModel.getMembers().subscribe(new ValueChangedListener<ArrayList<CallMember>>() {

            @Override
            public void onChanged(ArrayList<CallMember> val, Value<ArrayList<CallMember>> valueModel) {
                jsCall.changeValue(JsCall.create(messenger, callModel));
            }
        });
        callModel.getOwnVideoTracks().subscribe(new ValueChangedListener<ArrayListMediaTrack>() {

            @Override
            public void onChanged(ArrayListMediaTrack val, Value<ArrayListMediaTrack> valueModel) {
                jsCall.changeValue(JsCall.create(messenger, callModel));
            }
        });
        callModel.getTheirVideoTracks().subscribe(new ValueChangedListener<ArrayListMediaTrack>() {

            @Override
            public void onChanged(ArrayListMediaTrack val, Value<ArrayListMediaTrack> valueModel) {
                jsCall.changeValue(JsCall.create(messenger, callModel));
            }
        });
        calls.put(id, jsCall);
    }
    return calls.get(id);
}
Also used : ArrayList(java.util.ArrayList) CallVM(im.actor.core.viewmodel.CallVM) ArrayListMediaTrack(im.actor.core.viewmodel.generics.ArrayListMediaTrack) CallMember(im.actor.core.viewmodel.CallMember) JsCall(im.actor.core.js.entity.JsCall) CallState(im.actor.core.viewmodel.CallState)

Example 2 with CallMember

use of im.actor.core.viewmodel.CallMember in project actor-platform by actorapp.

the class JsCall method create.

public static JsCall create(JsMessenger messenger, CallVM model) {
    JsArray<JsPeerInfo> members = JsArray.createArray().cast();
    for (CallMember member : model.getMembers().get()) {
        members.push(messenger.buildPeerInfo(Peer.user(member.getUid())));
    }
    String state;
    switch(model.getState().get()) {
        case RINGING:
            state = "calling";
            break;
        case CONNECTING:
            state = "connecting";
            break;
        case IN_PROGRESS:
            state = "in_progress";
            break;
        default:
        case ENDED:
            state = "ended";
            break;
    }
    JsArray<JsMediaStreamTrack> tracks = JsArray.createArray().cast();
    for (WebRTCMediaTrack track : model.getTheirVideoTracks().get()) {
        tracks.push(((MediaTrack) track).getTrack());
    }
    ArrayList<WebRTCMediaTrack> ownTrack = model.getOwnVideoTracks().get();
    return create(JsPeer.create(model.getPeer()), model.isOutgoing(), members, state, !model.getIsAudioEnabled().get(), ownTrack.size() == 0 ? null : ((MediaTrack) ownTrack.get(0)).getTrack(), tracks);
}
Also used : WebRTCMediaTrack(im.actor.runtime.webrtc.WebRTCMediaTrack) MediaTrack(im.actor.runtime.js.webrtc.MediaTrack) CallMember(im.actor.core.viewmodel.CallMember) JsMediaStreamTrack(im.actor.runtime.js.webrtc.js.JsMediaStreamTrack) WebRTCMediaTrack(im.actor.runtime.webrtc.WebRTCMediaTrack)

Aggregations

CallMember (im.actor.core.viewmodel.CallMember)2 JsCall (im.actor.core.js.entity.JsCall)1 CallState (im.actor.core.viewmodel.CallState)1 CallVM (im.actor.core.viewmodel.CallVM)1 ArrayListMediaTrack (im.actor.core.viewmodel.generics.ArrayListMediaTrack)1 MediaTrack (im.actor.runtime.js.webrtc.MediaTrack)1 JsMediaStreamTrack (im.actor.runtime.js.webrtc.js.JsMediaStreamTrack)1 WebRTCMediaTrack (im.actor.runtime.webrtc.WebRTCMediaTrack)1 ArrayList (java.util.ArrayList)1