Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
remove unnecessary FishjamTrackContext.kt file (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
karkakol authored May 22, 2024
1 parent 124bd36 commit e80328d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import org.membraneframework.rtc.models.RTCStats
import org.membraneframework.rtc.utils.Metadata
import org.webrtc.Logging

typealias TrackContext = FishjamTrackContext

data class Config(
val websocketUrl: String,
val token: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,19 @@ internal class FishjamClientInternal(
}

override fun onTrackAdded(ctx: TrackContext) {
val trackContext = TrackContext(ctx)
listener.onTrackAdded(trackContext)
listener.onTrackAdded(ctx)
}

override fun onTrackReady(ctx: TrackContext) {
val trackContext = TrackContext(ctx)
listener.onTrackReady(trackContext)
listener.onTrackReady(ctx)
}

override fun onTrackRemoved(ctx: TrackContext) {
val trackContext = TrackContext(ctx)
listener.onTrackRemoved(trackContext)
listener.onTrackRemoved(ctx)
}

override fun onTrackUpdated(ctx: TrackContext) {
val trackContext = TrackContext(ctx)
listener.onTrackUpdated(trackContext)
listener.onTrackUpdated(ctx)
}

override fun onBandwidthEstimationChanged(estimation: Long) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fishjamdev.client

import okhttp3.Response
import org.membraneframework.rtc.models.TrackContext
import timber.log.Timber

interface FishjamClientListener {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ class TrackContext(
* Some of those reasons are indicated in TrackContext.encodingReason
*/
fun setOnEncodingChangedListener(listener: OnEncodingChangedListener?) {
listener?.onEncodingChanged(this)
onTrackEncodingChangeListener = listener
}

/**
* Sets listener that is called every time an update about voice activity is received from the server.
*/
fun setOnVoiceActivityChangedListener(listener: OnVoiceActivityChangedListener?) {
listener?.onVoiceActivityChanged(this)
onVadNotificationListener = listener
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import com.fishjamdev.client.Config
import com.fishjamdev.client.FishjamClient
import com.fishjamdev.client.FishjamClientListener
import com.fishjamdev.client.Peer
import com.fishjamdev.client.TrackContext
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import org.membraneframework.rtc.SimulcastConfig
import org.membraneframework.rtc.media.LocalVideoTrack
import org.membraneframework.rtc.media.RemoteVideoTrack
import org.membraneframework.rtc.media.VideoParameters
import org.membraneframework.rtc.models.TrackContext

class RoomViewModel(application: Application) :
AndroidViewModel(application),
Expand Down Expand Up @@ -97,15 +97,15 @@ class RoomViewModel(application: Application) :

override fun onTrackReady(ctx: TrackContext) {
viewModelScope.launch {
val participant = mutableParticipants[ctx.peer.id] ?: return@launch
val participant = mutableParticipants[ctx.endpoint.id] ?: return@launch

val (id, newParticipant) =
when (ctx.track) {
is RemoteVideoTrack -> {
globalToLocalTrackId[ctx.trackId] = (ctx.track as RemoteVideoTrack).id()

val p = participant.copy(videoTrack = ctx.track as RemoteVideoTrack)
Pair(ctx.peer.id, p)
Pair(ctx.endpoint.id, p)
}

else ->
Expand All @@ -120,7 +120,7 @@ class RoomViewModel(application: Application) :

override fun onTrackRemoved(ctx: TrackContext) {
viewModelScope.launch {
val participant = mutableParticipants[ctx.peer.id] ?: return@launch
val participant = mutableParticipants[ctx.endpoint.id] ?: return@launch

val localTrackId = globalToLocalTrackId[ctx.trackId]
val videoTrackId = participant.videoTrack?.id()
Expand All @@ -134,7 +134,7 @@ class RoomViewModel(application: Application) :

globalToLocalTrackId.remove(ctx.trackId)

mutableParticipants[ctx.peer.id] = newParticipant
mutableParticipants[ctx.endpoint.id] = newParticipant

emitParticipants()
}
Expand Down

0 comments on commit e80328d

Please sign in to comment.