浏览代码

Some progress

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 年之前
父节点
当前提交
4671575418

+ 2 - 0
app/build.gradle

@@ -68,6 +68,8 @@ dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
     implementation "com.android.support:design:${supportLibraryVersion}"
+    implementation "com.android.support:percent:${supportLibraryVersion}"
+
     implementation 'com.android.support:multidex:1.0.2'
 
     implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

+ 17 - 12
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -34,8 +34,7 @@ import android.util.TypedValue;
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
-import android.widget.GridLayout;
-import android.widget.RelativeLayout;
+import android.widget.LinearLayout;
 
 import com.bluelinelabs.logansquare.LoganSquare;
 import com.nextcloud.talk.R;
@@ -106,8 +105,8 @@ public class CallActivity extends AppCompatActivity {
     @BindView(R.id.pip_video_view)
     SurfaceViewRenderer pipVideoView;
 
-    @BindView(R.id.videos_grid_view)
-    GridLayout videosGrid;
+    @BindView(R.id.remote_renderers_layout)
+    LinearLayout remoteRenderersLayout;
 
     @Inject
     NcApi ncApi;
@@ -449,9 +448,14 @@ public class CallActivity extends AppCompatActivity {
                         case "offer":
                         case "answer":
                             magicPeerConnectionWrapper.setNick(ncSignalingMessage.getPayload().getNick());
-                            magicPeerConnectionWrapper.getPeerConnection().setRemoteDescription(magicPeerConnectionWrapper
-                                    .getMagicSdpObserver(), new SessionDescription(SessionDescription.Type.fromCanonicalForm(type),
-                                    ncSignalingMessage.getPayload().getSdp()));
+                            if (!magicPeerConnectionWrapper.getPeerConnection().signalingState().equals
+                                    (PeerConnection.SignalingState.STABLE) &&
+                                    magicPeerConnectionWrapper.getPeerConnection().getRemoteDescription() == null ||
+                                    magicPeerConnectionWrapper.getPeerConnection().getLocalDescription() == null) {
+                                magicPeerConnectionWrapper.getPeerConnection().setRemoteDescription(magicPeerConnectionWrapper
+                                        .getMagicSdpObserver(), new SessionDescription(SessionDescription.Type.fromCanonicalForm(type),
+                                        ncSignalingMessage.getPayload().getSdp()));
+                            }
                             break;
                         case "candidate":
                             NCIceCandidate ncIceCandidate = ncSignalingMessage.getPayload().getIceCandidate();
@@ -617,11 +621,11 @@ public class CallActivity extends AppCompatActivity {
                     public void run() {
                         if (stream.videoTracks.size() == 1) {
                             try {
-                                RelativeLayout relativeLayout = (RelativeLayout)
-                                        getLayoutInflater().inflate(R.layout.surface_renderer, videosGrid,
+                                LinearLayout linearLayout = (LinearLayout)
+                                        getLayoutInflater().inflate(R.layout.surface_renderer, remoteRenderersLayout,
                                                 false);
-                                relativeLayout.setTag(session);
-                                SurfaceViewRenderer surfaceViewRenderer = relativeLayout.findViewById(R.id
+                                linearLayout.setTag(session);
+                                SurfaceViewRenderer surfaceViewRenderer = linearLayout.findViewById(R.id
                                         .surface_view);
                                 surfaceViewRenderer.setMirror(false);
                                 surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null);
@@ -631,7 +635,8 @@ public class CallActivity extends AppCompatActivity {
                                 VideoRenderer remoteRenderer = new VideoRenderer(surfaceViewRenderer);
                                 videoRendererHashMap.put(session, remoteRenderer);
                                 videoTrack.addRenderer(remoteRenderer);
-                                videosGrid.addView(relativeLayout);
+                                remoteRenderersLayout.addView(linearLayout);
+                                linearLayout.invalidate();
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }

+ 6 - 7
app/src/main/res/layout/activity_call.xml

@@ -24,16 +24,15 @@
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:fitsSystemWindows="true"
+                android:id="@+id/relative_layout"
                 tools:context=".activities.CallActivity">
 
-    <GridLayout
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:id="@+id/videos_grid_view"
-        android:columnCount="4"
-        android:rowCount="2">
-
-    </GridLayout>
+        android:layout_height="match_parent"
+        android:id="@+id/remote_renderers_layout"
+        android:orientation="vertical">
+    </LinearLayout>
 
     <org.webrtc.SurfaceViewRenderer
         android:id="@+id/pip_video_view"

+ 5 - 6
app/src/main/res/layout/surface_renderer.xml

@@ -19,12 +19,11 @@
   ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
   -->
 
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                 android:id="@+id/relative_layout"
-                                android:layout_width="0dp"
-                                android:layout_height="0dp"
-                                android:layout_columnWeight="1"
-                                android:layout_rowWeight="1"
+                                android:layout_width="match_parent"
+                                android:layout_height="match_parent"
+                                android:layout_weight="1"
                                 android:orientation="vertical">
 
     <org.webrtc.SurfaceViewRenderer
@@ -32,4 +31,4 @@
         android:layout_height="match_parent"
         android:id="@+id/surface_view"/>
 
-</RelativeLayout>
+</LinearLayout>