Search in sources :

Example 1 with WakeLock

use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.

the class CallManagerActor method doCall.

//
// Outgoing call
//
private void doCall(final Peer peer, final CommandCallback<Long> callback, boolean isVideoEnabled) {
    Log.d(TAG, "doCall (" + peer + ")");
    //
    if (currentCall != null) {
        terminalCall(currentCall);
        currentCall = null;
    }
    //
    // Spawning new Actor for call
    //
    final WakeLock wakeLock = Runtime.makeWakeLock();
    system().actorOf("actor/master/" + RandomUtils.nextRid(), () -> {
        return new CallActor(peer, callback, wakeLock, isVideoEnabled, context());
    });
}
Also used : WakeLock(im.actor.runtime.power.WakeLock) AbsCallActor(im.actor.core.modules.calls.peers.AbsCallActor)

Example 2 with WakeLock

use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.

the class SenderActor method performSendContent.

// Sending content
private void performSendContent(final Peer peer, final long rid, AbsContent content) {
    WakeLock wakeLock = im.actor.runtime.Runtime.makeWakeLock();
    ApiMessage message;
    if (content instanceof TextContent) {
        message = new ApiTextMessage(((TextContent) content).getText(), ((TextContent) content).getMentions(), ((TextContent) content).getTextMessageEx());
    } else if (content instanceof DocumentContent) {
        DocumentContent documentContent = (DocumentContent) content;
        FileRemoteSource source = (FileRemoteSource) documentContent.getSource();
        ApiDocumentEx documentEx = null;
        if (content instanceof PhotoContent) {
            PhotoContent photoContent = (PhotoContent) content;
            documentEx = new ApiDocumentExPhoto(photoContent.getW(), photoContent.getH());
        } else if (content instanceof VideoContent) {
            VideoContent videoContent = (VideoContent) content;
            documentEx = new ApiDocumentExVideo(videoContent.getW(), videoContent.getH(), videoContent.getDuration());
        } else if (content instanceof AnimationContent) {
            AnimationContent animationContent = (AnimationContent) content;
            documentEx = new ApiDocumentExAnimation(animationContent.getW(), animationContent.getH());
        } else if (content instanceof VoiceContent) {
            VoiceContent voiceContent = (VoiceContent) content;
            documentEx = new ApiDocumentExVoice(voiceContent.getDuration());
        }
        ApiFastThumb fastThumb = null;
        if (documentContent.getFastThumb() != null) {
            fastThumb = new ApiFastThumb(documentContent.getFastThumb().getW(), documentContent.getFastThumb().getH(), documentContent.getFastThumb().getImage());
        }
        message = new ApiDocumentMessage(source.getFileReference().getFileId(), source.getFileReference().getAccessHash(), source.getFileReference().getFileSize(), source.getFileReference().getFileName(), documentContent.getMimeType(), fastThumb, documentEx);
    } else if (content instanceof LocationContent) {
        message = new ApiJsonMessage(((LocationContent) content).getRawJson());
    } else if (content instanceof ContactContent) {
        message = new ApiJsonMessage(((ContactContent) content).getRawJson());
    } else if (content instanceof JsonContent) {
        message = new ApiJsonMessage(((JsonContent) content).getRawJson());
    } else if (content instanceof StickerContent) {
        message = ((ContentRemoteContainer) content.getContentContainer()).getMessage();
    } else {
        return;
    }
    performSendApiContent(peer, rid, message, wakeLock);
}
Also used : ApiFastThumb(im.actor.core.api.ApiFastThumb) ApiDocumentEx(im.actor.core.api.ApiDocumentEx) ApiDocumentExVoice(im.actor.core.api.ApiDocumentExVoice) StickerContent(im.actor.core.entity.content.StickerContent) LocationContent(im.actor.core.entity.content.LocationContent) WakeLock(im.actor.runtime.power.WakeLock) VideoContent(im.actor.core.entity.content.VideoContent) ApiTextMessage(im.actor.core.api.ApiTextMessage) JsonContent(im.actor.core.entity.content.JsonContent) AnimationContent(im.actor.core.entity.content.AnimationContent) ContactContent(im.actor.core.entity.content.ContactContent) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) FileRemoteSource(im.actor.core.entity.content.FileRemoteSource) VoiceContent(im.actor.core.entity.content.VoiceContent) DocumentContent(im.actor.core.entity.content.DocumentContent) ApiMessage(im.actor.core.api.ApiMessage) ApiDocumentExPhoto(im.actor.core.api.ApiDocumentExPhoto) ApiDocumentExAnimation(im.actor.core.api.ApiDocumentExAnimation) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) ContentRemoteContainer(im.actor.core.entity.content.internal.ContentRemoteContainer) ApiDocumentExVideo(im.actor.core.api.ApiDocumentExVideo) TextContent(im.actor.core.entity.content.TextContent) PhotoContent(im.actor.core.entity.content.PhotoContent)

Example 3 with WakeLock

use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.

the class CallManagerActor method onIncomingCall.

//
// Incoming call
//
private void onIncomingCall(final long callId, final int attempt, WakeLock wakeLock) {
    Log.d(TAG, "onIncomingCall (" + callId + ")");
    //
    if (handledCalls.contains(callId)) {
        if (handledCallAttempts.get(callId) >= attempt) {
            if (wakeLock != null) {
                wakeLock.releaseLock();
            }
            return;
        }
    }
    //
    if (runningCalls.containsKey(callId)) {
        if (wakeLock != null) {
            wakeLock.releaseLock();
        }
        return;
    }
    //
    // Marking handled calls as handled
    //
    handledCalls.add(callId);
    handledCallAttempts.put(callId, attempt);
    //
    if (wakeLock == null) {
        wakeLock = Runtime.makeWakeLock();
    }
    //
    // Spawning new Actor for call
    //
    final WakeLock finalWakeLock = wakeLock;
    system().actorOf("actor/call" + RandomUtils.nextRid(), () -> {
        return new CallActor(callId, finalWakeLock, context());
    });
}
Also used : WakeLock(im.actor.runtime.power.WakeLock) AbsCallActor(im.actor.core.modules.calls.peers.AbsCallActor)

Aggregations

WakeLock (im.actor.runtime.power.WakeLock)3 AbsCallActor (im.actor.core.modules.calls.peers.AbsCallActor)2 ApiDocumentEx (im.actor.core.api.ApiDocumentEx)1 ApiDocumentExAnimation (im.actor.core.api.ApiDocumentExAnimation)1 ApiDocumentExPhoto (im.actor.core.api.ApiDocumentExPhoto)1 ApiDocumentExVideo (im.actor.core.api.ApiDocumentExVideo)1 ApiDocumentExVoice (im.actor.core.api.ApiDocumentExVoice)1 ApiDocumentMessage (im.actor.core.api.ApiDocumentMessage)1 ApiFastThumb (im.actor.core.api.ApiFastThumb)1 ApiJsonMessage (im.actor.core.api.ApiJsonMessage)1 ApiMessage (im.actor.core.api.ApiMessage)1 ApiTextMessage (im.actor.core.api.ApiTextMessage)1 AnimationContent (im.actor.core.entity.content.AnimationContent)1 ContactContent (im.actor.core.entity.content.ContactContent)1 DocumentContent (im.actor.core.entity.content.DocumentContent)1 FileRemoteSource (im.actor.core.entity.content.FileRemoteSource)1 JsonContent (im.actor.core.entity.content.JsonContent)1 LocationContent (im.actor.core.entity.content.LocationContent)1 PhotoContent (im.actor.core.entity.content.PhotoContent)1 StickerContent (im.actor.core.entity.content.StickerContent)1