【WebRTC---源码篇】(三:一)音频轨

音频轨的创建时序在Conductor::AddTracks()中

  rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
      peer_connection_factory_->CreateAudioTrack(
          kAudioLabel, peer_connection_factory_->CreateAudioSource(
                           cricket::AudioOptions())));

通过代码我们可以看出,创建音频轨需要两个参数,第二个参数为通过PcFactory构建的音频源

rtc::scoped_refptr<AudioSourceInterface>
PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) {
  RTC_DCHECK(signaling_thread_->IsCurrent());
  rtc::scoped_refptr<LocalAudioSource> source(
      LocalAudioSource::Create(&options));
  return source;
}

通过上面的代码我们可以看出,CreateAudioSource只是简单的创建了一个LocalAudioSource对象并返回

rtc::scoped_refptr<AudioTrackInterface> PeerConnectionFactory::CreateAudioTrack(
    const std::string& id,
    AudioSourceInterfa

猜你喜欢

转载自blog.csdn.net/qq_40179458/article/details/132061416