This commit is contained in:
li 2024-05-11 17:41:52 +08:00
parent 6632cc308c
commit cc465f03f8
2 changed files with 26 additions and 11 deletions

View File

@ -636,7 +636,7 @@ public class PeerConnectionClient {
sdpMediaConstraints.mandatory.add( sdpMediaConstraints.mandatory.add(
new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")); new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
"OfferToReceiveVideo", Boolean.toString(isVideoCallEnabled()))); "OfferToReceiveVideo", Boolean.toString(true)));//这里
} }
private void createPeerConnectionInternal(final BigInteger handleId) { private void createPeerConnectionInternal(final BigInteger handleId) {

View File

@ -24,15 +24,21 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven
private var context: Context? = null private var context: Context? = null
private var surfaceViewRenderer: SurfaceViewRenderer? = null
private val eglBase = EglBase.create()
private val peerConnectionClient: PeerConnectionClient? by lazy { private val peerConnectionClient: PeerConnectionClient? by lazy {
PeerConnectionClient( PeerConnectionClient(
context, EglBase.create(), context, eglBase,
PeerConnectionClient.PeerConnectionParameters( PeerConnectionClient.PeerConnectionParameters(
false,
true, true,
false, false,
false, 1280,
1080, 720,
960,
0, 0,
0, 0,
"VP8", "VP8",
@ -78,7 +84,7 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven
// Front facing camera not found, try something else // Front facing camera not found, try something else
for (deviceName in deviceNames) { for (deviceName in deviceNames) {
if (!enumerator.isFrontFacing(deviceName)) { if (enumerator.isFrontFacing(deviceName)) {
val videoCapturer: VideoCapturer? = enumerator.createCapturer(deviceName, null) val videoCapturer: VideoCapturer? = enumerator.createCapturer(deviceName, null)
if (videoCapturer != null) { if (videoCapturer != null) {
return videoCapturer return videoCapturer
@ -98,12 +104,15 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven
return null return null
} }
override fun bind(context: Context, surface: SurfaceViewRenderer, localPreview: Boolean) { override fun bind(context: Context, surface: SurfaceViewRenderer, localPreview: Boolean) {
this.context = context this.context = context
peerConnectionClient?.setAudioEnabled(true) this.surfaceViewRenderer = surface
this.surfaceViewRenderer?.init(eglBase.eglBaseContext,null)
this.peerConnectionClient?.setAudioEnabled(true)
peerConnectionClient?.createPeerConnectionFactory(PeerConnectionFactory.Options()) peerConnectionClient?.createPeerConnectionFactory(PeerConnectionFactory.Options())
peerConnectionClient?.createPeerConnection(createVideoCapture(context), BigInteger.ZERO) peerConnectionClient?.createPeerConnection(createVideoCapture(context), BigInteger.ONE)
peerConnectionClient?.createOffer((BigInteger.ZERO)) peerConnectionClient?.createOffer((BigInteger.ONE))
} }
@ -157,7 +166,10 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven
if (code == 0) { if (code == 0) {
logger("handleId: " + doPost) logger("handleId: " + doPost)
val sdp = result.getString("sdp") val sdp = result.getString("sdp")
peerConnectionClient?.setRemoteDescription(handleId,SessionDescription(SessionDescription.Type.ANSWER,sdp)) peerConnectionClient?.setRemoteDescription(
handleId,
SessionDescription(SessionDescription.Type.ANSWER, sdp)
)
} else { } else {
val msg = result.getString("msg") val msg = result.getString("msg")
logger("handleId: " + msg) logger("handleId: " + msg)
@ -199,10 +211,13 @@ class ZLMRTCPlayerImpl : ZLMRTCPlayer(), PeerConnectionClient.PeerConnectionEven
} }
override fun onLocalRender(handleId: BigInteger?) { override fun onLocalRender(handleId: BigInteger?) {
logger("onLocalRender: " + handleId)
//peerConnectionClient?.setVideoRender(handleId, surfaceViewRenderer)
} }
override fun onRemoteRender(handleId: BigInteger?) { override fun onRemoteRender(handleId: BigInteger?) {
logger("onRemoteRender: " + handleId)
peerConnectionClient?.setVideoRender(handleId, surfaceViewRenderer)
} }