webrtc代码解读二:音视频播放同步过程

在rtp包来是获取当前时间戳到本地变量:

Channel::OnRtpPacket -> Channel::UpdatePlayoutTimestamp -> AudioCodingModuleImpl::PlayoutTimestamp -> AcmReceiver::GetPlayoutTimestamp -> NetEqImpl::GetPlayoutTimestamp 

从成员变量读取播放时间戳:

VideoReceiveStream::OnFrame -> RtpStreamsSynchronizer::GetStreamSyncOffsetInMs -> AudioReceiveStream::GetPlayoutTimestamp -> ChannelProxy::GetPlayoutTimestamp -> Channel::GetPlayoutTimestamp 获取 playout_timestamp_rtp_

void VideoReceiveStream::OnFrame(const VideoFrame& video_frame) {
  int64_t sync_offset_ms;
  double estimated_freq_khz;
  // TODO(tommi): GetStreamSyncOffsetInMs grabs three locks.  One inside the
  // function itself, another in GetChannel() and a third in
  // GetPlayoutTimestamp.  Seems excessive.  Anyhow, I'm assuming the function
  // succeeds most of the time, which leads to grabbing a fourth lock.
  if (rtp_stream_sync_.GetStreamSyncOffsetInMs(video_frame.timestamp(),
                                               video_frame.render_time_ms(),
                                               &sync_offset_ms,
                                               &estimated_freq_khz)) {
    // TODO(tommi): OnSyncOffsetUpdated grabs a lock.
    stats_proxy_.OnSyncOffsetUpdated(sync_offset_ms, estimated_freq_khz);
  }
  // config_.renderer must never be null if we're getting this callback.
  config_.renderer->OnFrame(video_frame);

  // TODO(tommi): OnRenderFrame grabs a lock too.
  stats_proxy_.OnRenderedFrame(video_frame);
}

猜你喜欢

转载自blog.csdn.net/u011382962/article/details/87881386