Skip to main content
Version: 7.0

Audio receiver

The audio receiver feature provides a way to get audio data without affecting the actual audio stream. This feature allows your application to receive copies of audio data and use the data for various purposes.

Supported call typeMinimum SDK version
1-to-1 call, group call (conference)PlanetKit 7.0
Note

Audio data obtained through the audio receiver feature is an unprocessed audio stream before VQE control is applied.

Use cases

The main use cases for audio receivers are as follows.

  • Audio analysis and transcription
  • Voice activity detection
  • Audio quality monitoring
  • Call analytics and metrics collection
  • Real-time audio visualization and level meters
  • Recording call audio to files

Implementation steps

To implement the audio receiver feature, follow these steps.

Implement an audio receiver

Create a class that implements the PlanetKitAudioReceiver interface to receive audio data through callbacks.

import com.linecorp.planetkit.session.PlanetKitAudioReceiver
import com.linecorp.planetkit.audio.AudioFrame

class AudioDataReceiver : PlanetKitAudioReceiver {
override fun onAudioReceived(data: AudioFrame) {
// Access audio data properties
val buffer = data.getBuffer() // ByteBuffer: audio data
val sampleType = data.getSampleType() // PlanetKitAudioSampleType: audio sample type
val size = data.getSize() // Long: size in bytes
val samplingRate = data.getSamplingRate() // PlanetKitAudioSampleRate: audio sample rate
val sampleCount = data.getSampleCount() // Int: number of samples
val timestamp = data.getTimestamp() // Long: timestamp in nanoseconds

// Use the audio data for your use case

// Release the frame when done
data.release()
}
}

Set the audio receiver

Register the receiver to start receiving audio data from the 1-to-1 call or group call.

// Create receiver instance
val myAudioReceiver = AudioDataReceiver()
val peerAudioReceiver = AudioDataReceiver()

// For 1-to-1 call
call.setMyAudioReceiver(myAudioReceiver) // Local user's audio
call.setPeerAudioReceiver(peerAudioReceiver) // Remote peer's audio

// For group call
conference.setMyAudioReceiver(myAudioReceiver) // Local user's audio
conference.setPeerAudioReceiver(peerAudioReceiver) // Mixed audio from all peers

Clear the audio receiver

Unregister the receiver to stop receiving audio data and clean up resources.

// For 1-to-1 call
call.clearMyAudioReceiver()
call.clearPeerAudioReceiver()

// For group call
conference.clearMyAudioReceiver()
conference.clearPeerAudioReceiver()

The APIs related to the audio receiver feature are as follows.

Common

1-to-1 call

Group call