WebRTC研究:sending_

RTCPSender.sending_ 默认为 false,即当前为接收端:

RTCPSender::RTCPSender(
    bool audio,
    Clock* clock,
    ReceiveStatistics* receive_statistics,
    RtcpPacketTypeCounterObserver* packet_type_counter_observer,
    RtcEventLog* event_log,
    Transport* outgoing_transport)
    :sending_(false),
    ...
    ...
    ...
{
  ...
  ...
  ...
}

当调用 AudioSendStream::Start() 时,sending_ 会变成 true,表示当前为发送端:

void AudioSendStream::Start() 
{
  RTC_DCHECK(thread_checker_.CalledOnValidThread());
  ScopedVoEInterface<VoEBase> base(voice_engine());
  
  //开始发送
  int error = base->StartSend(config_.voe_channel_id);
  if (error != 0) 
  {
    LOG(LS_ERROR) << "AudioSendStream::Start failed with error: " << error;
  }
}

当调用 AudioSendStream::Stop()、亦或者删除 / 销毁 Channel,sending_ 会变成 false,表示当前为接收端:

void AudioSendStream::Stop() 
{
  RTC_DCHECK(thread_checker_.CalledOnValidThread());
  ScopedVoEInterface<VoEBase> base(voice_engine());

  // 停止发送
  int error = base->StopSend(config_.voe_channel_id);
  if (error != 0) 
  {
    LOG(LS_ERROR) << "AudioSendStream::Stop failed with error: " << error;
  }
}
发布了112 篇原创文章 · 获赞 22 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/u010601662/article/details/105270268
今日推荐