Skip to content

v3.x_Audio_Frame

xiaoxiaochupei edited this page May 25, 2017 · 1 revision

SDK提供OnAudioRawData回调返回原始的音频数据,开发者可以通过原始数据自定义处理(例如:噪声消除、变调等)

1. v3.x 说明

  • 接口:com.ksy.recordlib.service.streamer.OnAudioRawDataListener
  • 设置方式:通过KSYStreamer的接口setOnAudioRawDataListener接口来设置
  • 回调触发时机:硬编、软编模式下均在推流过程中触发
  • 自定义音频帧数据处理生效:硬编和软编模式下,预览和播放端均可体现

2. 接口说明

public interface OnAudioRawDataListener {
    /**
     * Called on every audio frame captured.
     *
     * @param data  audio frame data in 44100Hz 16bit mono.
     * @param count sample count
     * @return filtered audio data in the same format.
     */
    short[] OnAudioRawData(short[] data, int count);
}

    mStreamer.setOnAudioRawDataListener(mOnAudioRawDataListener);
    private OnAudioRawDataListener mOnAudioRawDataListener = new OnAudioRawDataListener() {
        @Override
        public short[] OnAudioRawData(short[] data, int count) {
            //audio pcm data
            return data;
        }
    };
Clone this wiki locally