Search in sources :

Example 6 with WebRTCMediaTrack

use of im.actor.runtime.webrtc.WebRTCMediaTrack in project actor-platform by actorapp.

the class PeerNodeActor method startIfNeeded.

private void startIfNeeded() {
    if (isEnabled && isConnected && !isStarted) {
        isStarted = true;
        state = PeerState.ACTIVE;
        callback.onPeerStateChanged(deviceId, state);
        if (theirStream != null) {
            for (WebRTCMediaTrack track : theirStream.getAudioTracks()) {
                track.setEnabled(isAudioEnabled);
                if (isAudioEnabled) {
                    callback.onTrackAdded(deviceId, track);
                }
            }
            for (WebRTCMediaTrack track : theirStream.getVideoTracks()) {
                track.setEnabled(isVideoEnabled);
                if (isVideoEnabled) {
                    callback.onTrackAdded(deviceId, track);
                }
            }
        }
    }
}
Also used : WebRTCMediaTrack(im.actor.runtime.webrtc.WebRTCMediaTrack)

Example 7 with WebRTCMediaTrack

use of im.actor.runtime.webrtc.WebRTCMediaTrack in project actor-platform by actorapp.

the class PeerNodeActor method onStreamAdded.

@Override
public void onStreamAdded(WebRTCMediaStream stream) {
    WebRTCMediaStream oldStream = theirStream;
    theirStream = stream;
    //
    if (isStarted) {
        for (WebRTCMediaTrack track : stream.getAudioTracks()) {
            track.setEnabled(isAudioEnabled);
            if (isAudioEnabled) {
                callback.onTrackAdded(deviceId, track);
            }
        }
        for (WebRTCMediaTrack track : stream.getVideoTracks()) {
            track.setEnabled(isVideoEnabled);
            if (isVideoEnabled) {
                callback.onTrackAdded(deviceId, track);
            }
        }
        if (oldStream != null) {
            for (WebRTCMediaTrack track : oldStream.getVideoTracks()) {
                callback.onTrackRemoved(deviceId, track);
            }
            for (WebRTCMediaTrack track : oldStream.getAudioTracks()) {
                callback.onTrackRemoved(deviceId, track);
            }
        }
    }
    if (!isConnected) {
        isConnected = true;
        if (!isEnabled) {
            state = PeerState.CONNECTED;
            callback.onPeerStateChanged(deviceId, state);
        } else {
        // This case is handled in startIfNeeded();
        }
    }
    startIfNeeded();
}
Also used : WebRTCMediaTrack(im.actor.runtime.webrtc.WebRTCMediaTrack) WebRTCMediaStream(im.actor.runtime.webrtc.WebRTCMediaStream)

Aggregations

WebRTCMediaTrack (im.actor.runtime.webrtc.WebRTCMediaTrack)7 WebRTCMediaStream (im.actor.runtime.webrtc.WebRTCMediaStream)2 Property (com.google.j2objc.annotations.Property)1 ApiICEServer (im.actor.core.api.ApiICEServer)1 ModuleActor (im.actor.core.modules.ModuleActor)1 ModuleContext (im.actor.core.modules.ModuleContext)1 CallMember (im.actor.core.viewmodel.CallMember)1 Log (im.actor.runtime.Log)1 WebRTC (im.actor.runtime.WebRTC)1 ActorCreator (im.actor.runtime.actors.ActorCreator)1 AskMessage (im.actor.runtime.actors.ask.AskMessage)1 Void (im.actor.runtime.actors.messages.Void)1 ManagedList (im.actor.runtime.collections.ManagedList)1 CountedReference (im.actor.runtime.function.CountedReference)1 MediaTrack (im.actor.runtime.js.webrtc.MediaTrack)1 JsMediaStreamTrack (im.actor.runtime.js.webrtc.js.JsMediaStreamTrack)1 Promise (im.actor.runtime.promise.Promise)1 WebRTCIceServer (im.actor.runtime.webrtc.WebRTCIceServer)1 WebRTCPeerConnection (im.actor.runtime.webrtc.WebRTCPeerConnection)1 WebRTCPeerConnectionCallback (im.actor.runtime.webrtc.WebRTCPeerConnectionCallback)1