davidliu
Committed by GitHub

Expose remote audio track buffers (#268)

@@ -17,6 +17,31 @@ @@ -17,6 +17,31 @@
17 package io.livekit.android.room.track 17 package io.livekit.android.room.track
18 18
19 import org.webrtc.AudioTrack 19 import org.webrtc.AudioTrack
  20 +import org.webrtc.AudioTrackSink
20 import org.webrtc.RtpReceiver 21 import org.webrtc.RtpReceiver
21 22
22 -class RemoteAudioTrack(name: String, rtcTrack: AudioTrack, internal val receiver: RtpReceiver) : io.livekit.android.room.track.AudioTrack(name, rtcTrack) 23 +class RemoteAudioTrack(
  24 + name: String,
  25 + rtcTrack: AudioTrack,
  26 + internal val receiver: RtpReceiver
  27 +) : io.livekit.android.room.track.AudioTrack(name, rtcTrack) {
  28 +
  29 + /**
  30 + * Adds a sink that receives the audio bytes and related information
  31 + * for this audio track. Repeated calls using the same sink will
  32 + * only add the sink once.
  33 + *
  34 + * Implementations should copy the audio data into a local copy if they wish
  35 + * to use the data after this function returns.
  36 + */
  37 + fun addSink(sink: AudioTrackSink) {
  38 + rtcTrack.addSink(sink)
  39 + }
  40 +
  41 + /**
  42 + * Removes a previously added sink.
  43 + */
  44 + fun removeSink(sink: AudioTrackSink) {
  45 + rtcTrack.removeSink(sink)
  46 + }
  47 +}