AudioRenderer是Audio的渲染類,負(fù)責(zé)音頻的渲染
public static class AudioFrame {
public byte[] audio_data; //音頻數(shù)據(jù)
public int bits_per_sample; //bit音頻的示例
public int sample_rate; //示例比特率
public int number_of_channels; //聲道的數(shù)量
public int number_of_frames; //幀的數(shù)量
//構(gòu)造方法
public AudioFrame(byte[] audio_data, int bits_per_sample, int sample_rate, int number_of_channels, int number_of_frames) {
this.audio_data = audio_data;
this.sample_rate = sample_rate;
this.bits_per_sample = bits_per_sample;
this.number_of_channels = number_of_channels;
this.number_of_frames = number_of_frames;
}
}
//回調(diào)接口,當(dāng)有音頻幀的時(shí)候產(chǎn)生回調(diào)用的
public static interface Callbacks {
public void onAudioFrame(AudioFrame frame);
}
long nativeAudioRenderer;
//創(chuàng)建AudioRenderer
public AudioRenderer(Callbacks callbacks) {
nativeAudioRenderer = nativeWrapAudioRenderer(callbacks);
}
private static native long nativeWrapAudioRenderer(Callbacks callbacks);
/銷毀掉audioRenderer
public void dispose() {
if (nativeAudioRenderer == 0) {
return;
}
// todo free native audio renderer
nativeAudioRenderer = 0;
}