android webrtc使用opensl es

1. java层开启开关

peerConnectionParameters =
        new PeerConnectionClient.PeerConnectionParameters();

接口中的useOpensles参数设置为true

2. /system/etc/permissions/下新增android.hardware.audio.low_latency.xml文件,内容如下:

< ?xml version="1.0" encoding="utf-8"?>
 <permissions>
     <feature name="android.hardware.audio.low_latency" />
  </permissions>

ps:webrtc创建不同的音频播放方式源码代码如下:

audio_device_imp.cc文件  int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()接口

if (audioLayer == kPlatformDefaultAudio) {
    if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
        _audioManagerAndroid->IsLowLatencyRecordSupported()) {
      // Use OpenSL ES for both playout and recording.
      audioLayer = kAndroidOpenSLESAudio;
    } else if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
               !_audioManagerAndroid->IsLowLatencyRecordSupported()) {
      // Use OpenSL ES for output on devices that only supports the
      // low-latency output audio path.
      audioLayer = kAndroidJavaInputAndOpenSLESOutputAudio;
    } else {
      // Use Java-based audio in both directions when low-latency output is
      // not supported.
      audioLayer = kAndroidJavaAudio;
    }
  }

判断条件源码在audio_manager.cc

bool AudioManager::IsLowLatencyPlayoutSupported() const {
  RTC_DCHECK(thread_checker_.CalledOnValidThread());
  ALOGD("IsLowLatencyPlayoutSupported()");
  // Some devices are blacklisted for usage of OpenSL ES even if they report
  // that low-latency playout is supported. See b/21485703 for details.
  return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ?
      false : low_latency_playout_;
}

转载于:https://my.oschina.net/xgcode/blog/2209073

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值