Add nick magic

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-12-07 16:05:26 +01:00
parent 8756c006c8
commit 638f57e81c
3 changed files with 46 additions and 22 deletions

View file

@ -36,6 +36,8 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bluelinelabs.logansquare.LoganSquare; import com.bluelinelabs.logansquare.LoganSquare;
import com.nextcloud.talk.R; import com.nextcloud.talk.R;
@ -128,7 +130,6 @@ public class CallActivity extends AppCompatActivity {
AudioTrack localAudioTrack; AudioTrack localAudioTrack;
VideoCapturer videoCapturer; VideoCapturer videoCapturer;
VideoRenderer localRenderer; VideoRenderer localRenderer;
HashMap<String, VideoRenderer> videoRendererHashMap = new HashMap<>();
EglBase rootEglBase; EglBase rootEglBase;
boolean leavingCall = false; boolean leavingCall = false;
BooleanSupplier booleanSupplier = () -> leavingCall; BooleanSupplier booleanSupplier = () -> leavingCall;
@ -565,8 +566,13 @@ public class CallActivity extends AppCompatActivity {
videoCapturer.dispose(); videoCapturer.dispose();
} }
localMediaStream.removeTrack(localMediaStream.videoTracks.get(0)); if (localMediaStream.videoTracks.size() > 0) {
localMediaStream.removeTrack(localMediaStream.audioTracks.get(0)); localMediaStream.removeTrack(localMediaStream.videoTracks.get(0));
}
if (localMediaStream.audioTracks.size() > 0) {
localMediaStream.removeTrack(localMediaStream.audioTracks.get(0));
}
localMediaStream = null; localMediaStream = null;
pipVideoView.release(); pipVideoView.release();
@ -622,6 +628,14 @@ public class CallActivity extends AppCompatActivity {
}); });
} }
private void gotNick(String sessionId, String nick) {
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
if (relativeLayout != null) {
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
textView.setText(nick);
}
}
private void gotRemoteStream(MediaStream stream, String session) { private void gotRemoteStream(MediaStream stream, String session) {
//we have remote video stream. add to the renderer. //we have remote video stream. add to the renderer.
removeMediaStream(session); removeMediaStream(session);
@ -634,11 +648,11 @@ public class CallActivity extends AppCompatActivity {
public void run() { public void run() {
if (stream.videoTracks.size() == 1) { if (stream.videoTracks.size() == 1) {
try { try {
LinearLayout linearLayout = (LinearLayout) RelativeLayout relativeLayout = (RelativeLayout)
getLayoutInflater().inflate(R.layout.surface_renderer, remoteRenderersLayout, getLayoutInflater().inflate(R.layout.surface_renderer, remoteRenderersLayout,
false); false);
linearLayout.setTag(session); relativeLayout.setTag(session);
SurfaceViewRenderer surfaceViewRenderer = linearLayout.findViewById(R.id SurfaceViewRenderer surfaceViewRenderer = relativeLayout.findViewById(R.id
.surface_view); .surface_view);
surfaceViewRenderer.setMirror(false); surfaceViewRenderer.setMirror(false);
surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null); surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null);
@ -646,10 +660,10 @@ public class CallActivity extends AppCompatActivity {
surfaceViewRenderer.setEnableHardwareScaler(true); surfaceViewRenderer.setEnableHardwareScaler(true);
surfaceViewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT); surfaceViewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
VideoRenderer remoteRenderer = new VideoRenderer(surfaceViewRenderer); VideoRenderer remoteRenderer = new VideoRenderer(surfaceViewRenderer);
videoRendererHashMap.put(session, remoteRenderer);
videoTrack.addRenderer(remoteRenderer); videoTrack.addRenderer(remoteRenderer);
remoteRenderersLayout.addView(linearLayout); remoteRenderersLayout.addView(relativeLayout);
linearLayout.invalidate(); relativeLayout.invalidate();
gotNick(session, getPeerConnectionWrapperForSessionId(session).getNick());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -52,7 +52,7 @@ public class MagicPeerConnectionWrapper {
private List<PeerConnection.IceServer> iceServers; private List<PeerConnection.IceServer> iceServers;
private String sessionId; private String sessionId;
private String localSession; private String localSession;
private String nick; private String nick = "";
private MediaConstraints mediaConstraints; private MediaConstraints mediaConstraints;
private DataChannel magicDataChannel; private DataChannel magicDataChannel;
private MagicSdpObserver magicSdpObserver; private MagicSdpObserver magicSdpObserver;

View file

@ -19,16 +19,26 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>. ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative_layout" android:id="@+id/relative_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<org.webrtc.SurfaceViewRenderer <org.webrtc.SurfaceViewRenderer
android:layout_width="match_parent" android:id="@+id/surface_view"
android:layout_height="match_parent" android:layout_width="match_parent"
android:id="@+id/surface_view"/> android:layout_height="match_parent"/>
</LinearLayout> <TextView
android:id="@+id/peer_nick_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_margin="8dp"
android:textColor="@color/nc_white_color_complete"
android:visibility="visible"/>
</RelativeLayout>