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

Commit

Permalink
fix listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
skyman503 committed Aug 1, 2023
1 parent 8526414 commit eb1b17a
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import org.membraneframework.rtc.models.TrackContext
import org.membraneframework.rtc.models.VadStatus
import org.membraneframework.rtc.utils.Metadata

fun interface JellyfishOnVoiceActivityChangedListener {
fun onVoiceActivityChanged(trackContext: JellyfishTrackContext)
}

fun interface JellyfishOnEncodingChangedListener {
fun onEncodingChangedListener(trackContext: JellyfishTrackContext)
}

class JellyfishTrackContext(private val trackContext: TrackContext) {
val track: RemoteTrack?
get() {
Expand Down Expand Up @@ -45,11 +53,13 @@ class JellyfishTrackContext(private val trackContext: TrackContext) {
return trackContext.encodingReason
}

fun setOnEncodingChangedListener(listener: OnEncodingChangedListener) {
trackContext.setOnEncodingChangedListener(listener)
fun setOnEncodingChangedListener(listener: JellyfishOnEncodingChangedListener) {
val rtcListener = OnEncodingChangedListener { trackContext -> listener.onEncodingChangedListener(JellyfishTrackContext(trackContext)) }
trackContext.setOnEncodingChangedListener(rtcListener)
}

fun setOnVoiceActivityChangedListener(listener: OnVoiceActivityChangedListener) {
trackContext.setOnVoiceActivityChangedListener(listener)
fun setOnVoiceActivityChangedListener(listener: JellyfishOnVoiceActivityChangedListener) {
val rtcListener = OnVoiceActivityChangedListener { trackContext -> listener.onVoiceActivityChanged(JellyfishTrackContext(trackContext)) }
trackContext.setOnVoiceActivityChangedListener(rtcListener)
}
}

0 comments on commit eb1b17a

Please sign in to comment.