Skip to content

Commit

Permalink
Rename the sink properties to track
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Feb 23, 2023
1 parent 82b3c74 commit ef33012
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ fun VideoCallScreen() {
) {
var parentSize: IntSize by remember { mutableStateOf(IntSize(0, 0)) }

val remoteVideoTrackState by sessionManager.remoteVideoSinkFlow.collectAsState(null)
val remoteVideoTrackState by sessionManager.remoteVideoTrackFlow.collectAsState(null)
val remoteVideoTrack = remoteVideoTrackState

val localVideoTrackState by sessionManager.localVideoSinkFlow.collectAsState(null)
val localVideoTrackState by sessionManager.localVideoTrackFlow.collectAsState(null)
val localVideoTrack = localVideoTrackState

if (remoteVideoTrack != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ interface WebRtcSessionManager {

val peerConnectionFactory: StreamPeerConnectionFactory

val localVideoSinkFlow: SharedFlow<VideoTrack>
val localVideoTrackFlow: SharedFlow<VideoTrack>

val remoteVideoSinkFlow: SharedFlow<VideoTrack>
val remoteVideoTrackFlow: SharedFlow<VideoTrack>

fun onSessionScreenReady()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class WebRtcSessionManagerImpl(
private val sessionManagerScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

// used to send local video track to the fragment
private val _localVideoSinkFlow = MutableSharedFlow<VideoTrack>()
override val localVideoSinkFlow: SharedFlow<VideoTrack> = _localVideoSinkFlow
private val _localVideoTrackFlow = MutableSharedFlow<VideoTrack>()
override val localVideoTrackFlow: SharedFlow<VideoTrack> = _localVideoTrackFlow

// used to send remote video track to the sender
private val _remoteVideoSinkFlow = MutableSharedFlow<VideoTrack>()
override val remoteVideoSinkFlow: SharedFlow<VideoTrack> = _remoteVideoSinkFlow
private val _remoteVideoTrackFlow = MutableSharedFlow<VideoTrack>()
override val remoteVideoTrackFlow: SharedFlow<VideoTrack> = _remoteVideoTrackFlow

// declaring video constraints and setting OfferToReceiveVideo to true
// this step is mandatory to create valid offer and answer
Expand Down Expand Up @@ -169,7 +169,7 @@ class WebRtcSessionManagerImpl(
if (track.kind() == MediaStreamTrack.VIDEO_TRACK_KIND) {
val videoTrack = track as VideoTrack
sessionManagerScope.launch {
_remoteVideoSinkFlow.emit(videoTrack)
_remoteVideoTrackFlow.emit(videoTrack)
}
}
}
Expand All @@ -196,7 +196,7 @@ class WebRtcSessionManagerImpl(
peerConnection.connection.addTrack(localAudioTrack)
sessionManagerScope.launch {
// sending local video track to show local video from start
_localVideoSinkFlow.emit(localVideoTrack)
_localVideoTrackFlow.emit(localVideoTrack)

if (offer != null) {
sendAnswer()
Expand All @@ -216,10 +216,10 @@ class WebRtcSessionManagerImpl(

override fun disconnect() {
// dispose audio & video tracks.
remoteVideoSinkFlow.replayCache.forEach { videoTrack ->
remoteVideoTrackFlow.replayCache.forEach { videoTrack ->
videoTrack.dispose()
}
localVideoSinkFlow.replayCache.forEach { videoTrack ->
localVideoTrackFlow.replayCache.forEach { videoTrack ->
videoTrack.dispose()
}
localAudioTrack.dispose()
Expand Down

0 comments on commit ef33012

Please sign in to comment.