当前位置:   article > 正文

ExoPlayer音画同步原理_exoplayer 音画同步

exoplayer 音画同步

ExoPlayer和大部分播放器一样,默认采用Audio Master的同步方式,其视频同步原因在MediaCodecVideoRender.java的processOutputBuffer()函数中,下面结合函数详细看下音画同步的原理。

  1. protected boolean processOutputBuffer(
  2. long positionUs,
  3. long elapsedRealtimeUs,
  4. @Nullable MediaCodecAdapter codec,
  5. @Nullable ByteBuffer buffer,
  6. int bufferIndex,
  7. int bufferFlags,
  8. int sampleCount,
  9. long bufferPresentationTimeUs,
  10. boolean isDecodeOnlyBuffer,
  11. boolean isLastBuffer,
  12. Format format)
  13. throws ExoPlaybackException {
  14. //Video不支持Bypass
  15. Assertions.checkNotNull(codec); // Can not render video without codec
  16. if (initialPositionUs == C.TIME_UNSET) {
  17. initialPositionUs = positionUs;
  18. }
  19. if (bufferPresentationTimeUs != lastBufferPresentationTimeUs) {
  20. frameReleaseHelper.onNextFrame(bufferPresentationTimeUs);
  21. this.lastBufferPresentationTimeUs = bufferPresentationTimeUs;
  22. }
  23. //outputStreamOffsetUs通常为0
  24. long outputStreamOffsetUs = getOutputStreamOffsetUs();
  25. long presentationTimeUs = bufferPresentationTimeUs - outputStreamOffsetUs;
  26. //isDecodeOnlyBuffer直接跳过
  27. if (isDecodeOnlyBuffer && !isLastBuffer) {
  28. skipOutputBuffer(codec, bufferIndex, presentationTimeUs);
  29. return true;
  30. }
  31. // Note: Use of double rather
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/295822
推荐阅读
相关标签
  

闽ICP备14008679号