-
-
Save skydoves/4d0f6f6151c174bcf9544480d0098fd5 to your computer and use it in GitHub Desktop.
session_manager_create_sdp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2023 Stream.IO, Inc. All Rights Reserved. | |
// SPDX-License-Identifier: Apache-2.0 | |
override fun onSessionScreenReady() { | |
peerConnection.connection.addTrack(localVideoTrack) | |
peerConnection.connection.addTrack(localAudioTrack) | |
sessionManagerScope.launch { | |
// sending local video track to show local video from start | |
_localVideoSinkFlow.emit(localVideoTrack) | |
if (offer != null) { | |
sendAnswer() | |
} else { | |
sendOffer() | |
} | |
} | |
} | |
private suspend fun sendOffer() { | |
val offer = peerConnection.createOffer().getOrThrow() | |
val result = peerConnection.setLocalDescription(offer) | |
result.onSuccess { | |
signalingClient.sendCommand(SignalingCommand.OFFER, offer.description) | |
} | |
logger.d { "[SDP] send offer: ${offer.stringify()}" } | |
} | |
private suspend fun sendAnswer() { | |
peerConnection.setRemoteDescription( | |
SessionDescription(SessionDescription.Type.OFFER, offer) | |
) | |
val answer = peerConnection.createAnswer().getOrThrow() | |
val result = peerConnection.setLocalDescription(answer) | |
result.onSuccess { | |
signalingClient.sendCommand(SignalingCommand.ANSWER, answer.description) | |
} | |
logger.d { "[SDP] send answer: ${answer.stringify()}" } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment