Search in sources :

Example 1 with HardwareService

use of cx.ring.services.HardwareService in project ring-client-android by savoirfairelinux.

the class CallPresenter method update.

@Override
public void update(Observable observable, ServiceEvent event) {
    if (event == null) {
        return;
    }
    if (observable instanceof CallService) {
        switch(event.getEventType()) {
            case CALL_STATE_CHANGED:
                SipCall call = event.getEventInput(ServiceEvent.EventInput.CALL, SipCall.class);
                int state = call.getCallState();
                Log.d(TAG, "CALL_STATE_CHANGED: " + call.getCallId() + " " + state);
                parseCall(call, state);
                confUpdate();
                break;
        }
    } else if (observable instanceof AccountService) {
        switch(event.getEventType()) {
            case REGISTERED_NAME_FOUND:
                if (mSipCall != null && mSipCall.getContact() != null) {
                    getView().updateContactBubble(mSipCall.getContact());
                }
                break;
        }
    } else if (observable instanceof HardwareService) {
        switch(event.getEventType()) {
            case VIDEO_EVENT:
                boolean videoStart = event.getEventInput(ServiceEvent.EventInput.VIDEO_START, Boolean.class, false);
                String callId = event.getEventInput(ServiceEvent.EventInput.VIDEO_CALL, String.class);
                Log.d(TAG, "VIDEO_EVENT: " + videoStart + " " + callId);
                previewHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
                previewWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
                if (videoStart) {
                    getView().displayVideoSurface(true);
                } else if (mSipCall != null && callId != null && mSipCall.getCallId().equals(callId)) {
                    boolean videoStarted = event.getEventInput(ServiceEvent.EventInput.VIDEO_STARTED, Boolean.class, false);
                    getView().displayVideoSurface(videoStarted);
                    if (videoStarted) {
                        videoWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
                        videoHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
                    }
                }
                getView().resetVideoSize(videoWidth, videoHeight, previewWidth, previewHeight);
                break;
        }
    }
}
Also used : HardwareService(cx.ring.services.HardwareService) SipCall(cx.ring.model.SipCall) AccountService(cx.ring.services.AccountService) CallService(cx.ring.services.CallService)

Aggregations

SipCall (cx.ring.model.SipCall)1 AccountService (cx.ring.services.AccountService)1 CallService (cx.ring.services.CallService)1 HardwareService (cx.ring.services.HardwareService)1