From cc465f03f86af6313238062777d3c981e02bdbf2 Mon Sep 17 00:00:00 2001 From: li <719947897@ qq.com> Date: Sat, 11 May 2024 17:41:52 +0800 Subject: [PATCH] test --- .../zlm/rtc/client/PeerConnectionClient.java | 2 +- .../java/com/zlm/rtc/play/ZLMRTCPlayerImpl.kt | 35 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/client/PeerConnectionClient.java b/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/client/PeerConnectionClient.java index 460d9499..7601e882 100644 --- a/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/client/PeerConnectionClient.java +++ b/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/client/PeerConnectionClient.java @@ -636,7 +636,7 @@ public class PeerConnectionClient { sdpMediaConstraints.mandatory.add( new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( - "OfferToReceiveVideo", Boolean.toString(isVideoCallEnabled()))); + "OfferToReceiveVideo", Boolean.toString(true)));//这里 } private void createPeerConnectionInternal(final BigInteger handleId) { diff --git a/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/play/ZLMRTCPlayerImpl.kt b/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/play/ZLMRTCPlayerImpl.kt index ebc522e3..72eada85 100644 --- a/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/play/ZLMRTCPlayerImpl.kt +++ b/webrtc_player/android/zlm/src/main/java/com/zlm/rtc/play/ZLMRTCPlayerImpl.kt @@ -24,15 +24,21 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven private var context: Context? = null + private var surfaceViewRenderer: SurfaceViewRenderer? = null + + private val eglBase = EglBase.create() + private val peerConnectionClient: PeerConnectionClient? by lazy { + + PeerConnectionClient( - context, EglBase.create(), + context, eglBase, PeerConnectionClient.PeerConnectionParameters( + false, true, false, - false, - 1080, - 960, + 1280, + 720, 0, 0, "VP8", @@ -78,7 +84,7 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven // Front facing camera not found, try something else for (deviceName in deviceNames) { - if (!enumerator.isFrontFacing(deviceName)) { + if (enumerator.isFrontFacing(deviceName)) { val videoCapturer: VideoCapturer? = enumerator.createCapturer(deviceName, null) if (videoCapturer != null) { return videoCapturer @@ -98,12 +104,15 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven return null } + override fun bind(context: Context, surface: SurfaceViewRenderer, localPreview: Boolean) { this.context = context - peerConnectionClient?.setAudioEnabled(true) + this.surfaceViewRenderer = surface + this.surfaceViewRenderer?.init(eglBase.eglBaseContext,null) + this.peerConnectionClient?.setAudioEnabled(true) peerConnectionClient?.createPeerConnectionFactory(PeerConnectionFactory.Options()) - peerConnectionClient?.createPeerConnection(createVideoCapture(context), BigInteger.ZERO) - peerConnectionClient?.createOffer((BigInteger.ZERO)) + peerConnectionClient?.createPeerConnection(createVideoCapture(context), BigInteger.ONE) + peerConnectionClient?.createOffer((BigInteger.ONE)) } @@ -157,7 +166,10 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven if (code == 0) { logger("handleId: " + doPost) val sdp = result.getString("sdp") - peerConnectionClient?.setRemoteDescription(handleId,SessionDescription(SessionDescription.Type.ANSWER,sdp)) + peerConnectionClient?.setRemoteDescription( + handleId, + SessionDescription(SessionDescription.Type.ANSWER, sdp) + ) } else { val msg = result.getString("msg") logger("handleId: " + msg) @@ -199,10 +211,13 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven } override fun onLocalRender(handleId: BigInteger?) { - + logger("onLocalRender: " + handleId) + //peerConnectionClient?.setVideoRender(handleId, surfaceViewRenderer) } override fun onRemoteRender(handleId: BigInteger?) { + logger("onRemoteRender: " + handleId) + peerConnectionClient?.setVideoRender(handleId, surfaceViewRenderer) }