WebRTC-PeerConnection约束已弃用

时间:2019-07-17 15:56:26

标签: android webrtc rtcpeerconnection

我正在将Android的视频聊天应用程序构建为家庭项目。 Android Studio抱怨以下代码行:

sdpConstraints = new MediaConstraints();
        sdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveAudio", "true"));
        sdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveVideo", "true"));



        //creating localPeer
        localPeer = peerConnectionFactory.createPeerConnection(iceServers, sdpConstraints, new CustomPeerConnectionObserver("localPeerCreation") {
            @Override
            public void onIceCandidate(IceCandidate iceCandidate) {
                super.onIceCandidate(iceCandidate);

                /*
                * We also have the onIceCandidateReceived() method whose work is to set the Ice candidates
                * received from one peer to another peer.
                * */
                onIceCandidateReceived(localPeer, iceCandidate);
            }
        }); 

它表明createPeerConnection()已过时。我有 createPeerConnection

因此,经过一些搜索之后,我在https://chromium.googlesource.com/external/webrtc/+/master/sdk/android/api/org/webrtc/PeerConnectionFactory.java处找到了该功能的实现。 作为评论,它说已弃用了签名中具有约束的createPeerConnection()方法,我应该使用其他createPeerConnection()版本中的一种,而方法签名中没有约束。

所以,我应该删除sdpConstraints参数,一切正常吗?我在哪里使用约束?

0 个答案:

没有答案