본문으로 건너뛰기
Version: 7.1

오디오 리시버

오디오 리시버 기능을 이용하면 실제 오디오 스트림에 영향을 주지 않고 오디오 데이터를 얻을 수 있습니다. 애플리케이션에서는 이 기능을 이용해 오디오 데이터의 복사본을 받아 다양한 용도로 사용할 수 있습니다.

지원 통화 유형최소 SDK 버전
1대1 통화, 그룹 통화(컨퍼런스)PlanetKit 7.0
Note

오디오 리시버를 통해 얻은 오디오 데이터는 VQE 제어가 적용되기 전의 오디오 스트림입니다.

활용 사례​

오디오 리시버의 주요 활용 사례는 다음과 같습니다.

  • 오디오 분석 및 전사(음성→텍스트 변환)
  • 음성 활동 감지(VAD)
  • 오디오 품질 모니터링
  • 통화 분석 및 지표 수집
  • 실시간 오디오 시각화 및 레벨 미터링
  • 통화 오디오를 파일로 녹음

구현 단계​

오디오 리시버 기능을 구현하려면 다음 단계를 따르세요.

로컬 사용자용 오디오 리시버​

로컬 사용자용 오디오 리시버 구현​

로컬 사용자의 오디오 데이터 수신을 위해 PlanetKitAudioMicCaptureDelegate를 준수하는 클래스를 만드세요.

import PlanetKit

class MicrophoneAudioReceiver: NSObject, PlanetKitAudioMicCaptureDelegate {
func didCapture(frameCnt: UInt32,
channels: UInt32,
sampleRate: UInt32,
sampleType: PlanetKitAudioSampleType,
timestamp: AudioTimeStamp,
outData: UnsafeMutableRawPointer!,
outDataLen: UInt32) {

// Audio data parameters:
// - frameCnt: Number of audio frames in this callback
// - channels: Number of audio channels
// - sampleRate: Sample rate
// - sampleType: Sample type
// - timestamp: Audio timestamp structure
// - outData: Pointer to audio data
// - outDataLen: Size of audio data in bytes

// Use the audio data for your use case
// Note: Audio data pointer is only valid during this callback
// Copy the data if you need to process it asynchronously
}
}

오디오 리시버 설정​

로컬 사용자의 오디오 데이터 수신을 시작하려면 오디오 세션을 통해 리시버를 등록하세요.

let audioSession = PlanetKitAudioManager.shared.session
let micReceiver = MicrophoneAudioReceiver()

audioSession.addMicReceiver(micReceiver)

오디오 리시버 해제​

오디오 데이터 수신을 중지하려면 리시버 등록을 해제하세요.

audioSession.removeMicReceiver(micReceiver)

피어용 오디오 리시버​

피어용 오디오 리시버 구현​

피어의 오디오 데이터 수신을 위해 PlanetKitAudioSpkPlayDelegate를 준수하는 클래스를 만드세요.

import PlanetKit

class SpeakerAudioReceiver: NSObject, PlanetKitAudioSpkPlayDelegate {
func willPlay(frameCnt: UInt32,
channels: UInt32,
sampleRate: UInt32,
sampleType: PlanetKitAudioSampleType,
timestamp: AudioTimeStamp,
playBuf: UnsafeMutableRawPointer!,
playBufSize: UInt32) -> Int32 {

// Audio data parameters:
// - frameCnt: Number of audio frames in this callback
// - channels: Number of audio channels
// - sampleRate: Sample rate
// - sampleType: Sample type
// - timestamp: Audio timestamp structure
// - playBuf: Pointer to audio data to be played
// - playBufSize: Size of audio data in bytes

// Use the audio data for your use case
// Note: Audio data pointer is only valid during this callback
// Copy the data if you need to process it asynchronously

// Return the number of bytes consumed
// Typically, return the full buffer size
return Int32(playBufSize)
}
}

오디오 리시버 설정​

오디오 데이터 수신을 시작하려면 오디오 세션을 통해 리시버를 등록하세요.

let audioSession = PlanetKitAudioManager.shared.session
let speakerReceiver = SpeakerAudioReceiver()

audioSession.addSpeakerReceiver(speakerReceiver)

오디오 리시버 해제​

오디오 데이터 수신을 중지하려면 리시버 등록을 해제하세요.

audioSession.removeSpeakerReceiver(speakerReceiver)

관련 API​

오디오 리시버 기능과 관련된 API는 다음과 같습니다.