use of im.actor.runtime.android.webrtc.AndroidVideoTrack in project actor-platform by actorapp.
the class CallFragment method onResume.
@Override
public void onResume() {
super.onResume();
enableWakeLock();
//
// Bind State
//
bind(call.getState(), (val, valueModel) -> {
if (currentState != val) {
currentState = val;
switch(val) {
case RINGING:
if (call.isOutgoing()) {
statusTV.setText(R.string.call_outgoing);
} else {
statusTV.setText(R.string.call_incoming);
toggleSpeaker(speaker, speakerTV, true);
initIncoming();
}
break;
case CONNECTING:
statusTV.setText(R.string.call_connecting);
break;
case IN_PROGRESS:
toggleSpeaker(speaker, speakerTV, false);
onConnected();
startTimer();
break;
case ENDED:
statusTV.setText(R.string.call_ended);
onCallEnd();
break;
}
}
});
//
// Is Muted
//
bind(call.getIsAudioEnabled(), (val, valueModel) -> {
if (getActivity() != null) {
if (!val) {
muteCallTv.setTextColor(getResources().getColor(R.color.picker_grey));
muteCall.setTint(getResources().getColor(R.color.picker_grey));
} else {
muteCallTv.setTextColor(Color.WHITE);
muteCall.setTint(Color.WHITE);
}
}
});
//
if (peer.getPeerType() == PeerType.PRIVATE) {
//
// Video Button
//
bind(call.getIsVideoEnabled(), (val, valueModel) -> {
if (val) {
videoTv.setTextColor(Color.WHITE);
videoIcon.setTint(Color.WHITE);
} else {
videoTv.setTextColor(getResources().getColor(R.color.picker_grey));
videoIcon.setTint(getResources().getColor(R.color.picker_grey));
}
});
//
// Bind Own Stream
//
ACTIVITY_BINDER.bind(call.getOwnVideoTracks(), (videoTracks, valueModel) -> {
boolean isNeedUnbind = true;
if (videoTracks.size() > 0) {
if (!isLocalViewConfigured) {
localVideoView.init(eglContext.getEglBaseContext(), null);
isLocalViewConfigured = true;
}
VideoTrack videoTrack = ((AndroidVideoTrack) videoTracks.get(0)).getVideoTrack();
if (videoTrack != localTrack) {
if (localTrack != null) {
localTrack.removeRenderer(localRender);
localRender.dispose();
}
localTrack = videoTrack;
localRender = new VideoRenderer(localVideoView);
localTrack.addRenderer(localRender);
localVideoView.setVisibility(View.VISIBLE);
}
isNeedUnbind = false;
}
if (isNeedUnbind) {
if (localTrack != null) {
localTrack.removeRenderer(localRender);
localTrack = null;
localRender.dispose();
localRender = null;
}
if (isLocalViewConfigured) {
localVideoView.release();
isLocalViewConfigured = false;
}
localVideoView.setVisibility(View.INVISIBLE);
}
});
//
// Bind Their Stream
//
ACTIVITY_BINDER.bind(call.getTheirVideoTracks(), (videoTracks, valueModel) -> {
boolean isNeedUnbind = true;
if (videoTracks.size() > 0) {
if (!isRemoteViewConfigured) {
remoteVideoView.init(eglContext.getEglBaseContext(), null);
isRemoteViewConfigured = true;
}
VideoTrack videoTrack = ((AndroidVideoTrack) videoTracks.get(0)).getVideoTrack();
if (videoTrack != remoteTrack) {
if (remoteTrack != null) {
remoteTrack.removeRenderer(remoteRender);
remoteRender.dispose();
}
remoteTrack = videoTrack;
remoteRender = new VideoRenderer(remoteVideoView);
remoteTrack.addRenderer(remoteRender);
remoteVideoView.setVisibility(View.VISIBLE);
avatarView.setVisibility(View.INVISIBLE);
nameTV.setVisibility(View.INVISIBLE);
}
isNeedUnbind = false;
}
if (isNeedUnbind) {
if (remoteTrack != null) {
remoteTrack.removeRenderer(remoteRender);
remoteTrack = null;
remoteRender.dispose();
remoteRender = null;
}
if (isRemoteViewConfigured) {
remoteVideoView.release();
isRemoteViewConfigured = false;
}
remoteVideoView.setVisibility(View.INVISIBLE);
avatarView.setVisibility(View.VISIBLE);
nameTV.setVisibility(View.VISIBLE);
}
});
} else {
videoTv.setTextColor(getResources().getColor(R.color.picker_grey));
videoIcon.setTint(getResources().getColor(R.color.picker_grey));
}
//
// Hide "in progress" notification
//
manager.cancel(NOTIFICATION_ID);
}
Aggregations