public class AgoraExternalAudioProcessor
extends java.lang.Object
IExternalAudioProcessorObserver| Modifier and Type | Field and Description |
|---|---|
private AgoraServiceConfig |
agoraServiceConfig
Agora service configuration
|
private AudioFrame |
audioFrame
Audio frame buffer
|
private AgoraAudioPcmDataSender |
audioFrameSender
Audio PCM data sender
|
private long |
cptr
Native pointer to the external audio processor
|
private AgoraLocalAudioTrack |
customAudioTrack
Custom audio track
|
private boolean |
initialized
Whether the processor has been initialized
|
private AgoraExternalAudioProcessorObserverWrapper |
observerWrapper
Observer wrapper - must be kept alive to prevent GC
|
| Constructor and Description |
|---|
AgoraExternalAudioProcessor(AgoraService agoraService,
AgoraMediaNodeFactory mediaNodeFactory,
AgoraServiceConfig agoraServiceConfig)
Constructs an AgoraExternalAudioProcessor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
destroy()
Releases the external audio processor and associated resources.
|
int |
initialize(AgoraApmConfig apmConfig,
int outputSampleRate,
int outputChannels,
AgoraAudioVadConfigV2 vadConfig,
IExternalAudioProcessorObserver observer)
Initializes the external audio processor with specified audio parameters.
|
private long |
nativeCreate()
Native method to create the processor.
|
private int |
nativeDestroy(long cptr)
Native method to destroy the processor.
|
private int |
nativeInitialize(long cptr,
long trackerCptr,
java.lang.String apmConfigJson,
boolean enableDump,
int outputSampleRate,
int outputChannels,
AgoraExternalAudioProcessorObserverWrapper externalAudioProcessorObserverWrapper)
Native method to initialize the processor.
|
int |
pushAudioPcmData(byte[] data,
int sampleRate,
int channels,
long presentationMs)
Pushes PCM audio data for processing.
|
private long cptr
private volatile AgoraAudioPcmDataSender audioFrameSender
private volatile AgoraLocalAudioTrack customAudioTrack
private volatile boolean initialized
private AgoraServiceConfig agoraServiceConfig
private AudioFrame audioFrame
private volatile AgoraExternalAudioProcessorObserverWrapper observerWrapper
AgoraExternalAudioProcessor(AgoraService agoraService, AgoraMediaNodeFactory mediaNodeFactory, AgoraServiceConfig agoraServiceConfig)
agoraService - The Agora service instancemediaNodeFactory - The media node factoryagoraServiceConfig - The Agora service configurationpublic int initialize(AgoraApmConfig apmConfig, int outputSampleRate, int outputChannels, AgoraAudioVadConfigV2 vadConfig, IExternalAudioProcessorObserver observer)
apmConfig - The APM (Audio Processing Module) configurationoutputSampleRate - The output sample rate (e.g., 16000, 48000)outputChannels - The output number of channels (1 for mono, 2 for
stereo)vadConfig - The VAD (Voice Activity Detection) configurationobserver - The observer for receiving processed audio framespublic int pushAudioPcmData(byte[] data,
int sampleRate,
int channels,
long presentationMs)
data - The PCM audio data buffersampleRate - The sample ratechannels - The number of channelspresentationMs - The presentation timestamp in millisecondspublic int destroy()
private long nativeCreate()
private int nativeInitialize(long cptr,
long trackerCptr,
java.lang.String apmConfigJson,
boolean enableDump,
int outputSampleRate,
int outputChannels,
AgoraExternalAudioProcessorObserverWrapper externalAudioProcessorObserverWrapper)
cptr - Native pointertrackerCptr - Native pointer to the audio
trackapmConfigJson - APM configuration in JSON formatenableDump - Whether to enable dumpoutputSampleRate - Output sample rateoutputChannels - Output channelsexternalAudioProcessorObserverWrapper - Observer for callbacksprivate int nativeDestroy(long cptr)
cptr - Native pointer