最近升级webrtc(m72版本),发现webrtc源码发生了不小的变动,尤其是在视频编解码这块,之前的MediaCodecVideoEncoder,MediaCodecVideoDecoder已经不再使用了,改成HardwareVideoDecoderFactory,HardwareVideoEncoderFactory了,创建编解码器也交给了上层去创建了,下面是创建编解码器的代码:
private static void createPeerConnectionFactoryInternal(Context context) {
if (factory == null) {
if (options == null) {
options = new PeerConnectionFactory.Options();
options.disableNetworkMonitor = true;
}
//创建egl
if (eglBase == null) {
eglBase = EglBase.create();
}
//创建audio device module
adm = JavaAudioDeviceModule.builder(context)
.setSamplesReadyCallback(null)
.setUseHardwareAcousticEchoCanceler(false)
.setUseHardwareNoiseSuppressor(false)
.setAudioRecordErrorCallback(null)
.setAudioTrackErrorCallback(null)
.createAudioDeviceModule();
final boolean enableH264HighProfile = true;
final VideoEncoderFactory encoderFactory;
final VideoDecoderFactory decoderFactory;
//编码