Extract ViESyncModule outside ViEChannel.
Moves functionality outside ViEChannel and away from the sender. BUG=webrtc:5494 R=danilchap@webrtc.org Review URL: https://codereview.webrtc.org/1698183002 . Cr-Commit-Position: refs/heads/master@{#11633}
This commit is contained in:
parent
a3dc79e072
commit
1794b2675f
@ -178,6 +178,7 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
1,
|
||||
false),
|
||||
vie_receiver_(vie_channel_.vie_receiver()),
|
||||
vie_sync_(vcm_.get()),
|
||||
rtp_rtcp_(vie_channel_.rtp_rtcp()) {
|
||||
LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
|
||||
|
||||
@ -302,12 +303,14 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
vie_channel_.RegisterPreRenderCallback(this);
|
||||
|
||||
process_thread_->RegisterModule(vcm_.get());
|
||||
process_thread_->RegisterModule(&vie_sync_);
|
||||
}
|
||||
|
||||
VideoReceiveStream::~VideoReceiveStream() {
|
||||
LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
|
||||
Stop();
|
||||
|
||||
process_thread_->DeRegisterModule(&vie_sync_);
|
||||
process_thread_->DeRegisterModule(vcm_.get());
|
||||
|
||||
// Deregister external decoders so that they are no longer running during
|
||||
@ -351,11 +354,13 @@ void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine,
|
||||
int audio_channel_id) {
|
||||
if (voice_engine != nullptr && audio_channel_id != -1) {
|
||||
VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine);
|
||||
vie_channel_.SetVoiceChannel(audio_channel_id, voe_sync_interface);
|
||||
vie_sync_.ConfigureSync(audio_channel_id, voe_sync_interface, rtp_rtcp_,
|
||||
vie_receiver_->GetRtpReceiver());
|
||||
voe_sync_interface->Release();
|
||||
} else {
|
||||
vie_channel_.SetVoiceChannel(-1, nullptr);
|
||||
return;
|
||||
}
|
||||
vie_sync_.ConfigureSync(-1, nullptr, rtp_rtcp_,
|
||||
vie_receiver_->GetRtpReceiver());
|
||||
}
|
||||
|
||||
VideoReceiveStream::Stats VideoReceiveStream::GetStats() const {
|
||||
|
||||
@ -100,6 +100,7 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
ReceiveStatisticsProxy stats_proxy_;
|
||||
ViEChannel vie_channel_;
|
||||
ViEReceiver* const vie_receiver_;
|
||||
ViESyncModule vie_sync_;
|
||||
RtpRtcp* const rtp_rtcp_;
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
@ -95,7 +95,6 @@ ViEChannel::ViEChannel(Transport* transport,
|
||||
vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
|
||||
vcm_(vcm),
|
||||
vie_receiver_(vcm_, remote_bitrate_estimator, this),
|
||||
vie_sync_(vcm_),
|
||||
stats_observer_(new ChannelStatsObserver(this)),
|
||||
receive_stats_callback_(nullptr),
|
||||
incoming_video_stream_(nullptr),
|
||||
@ -166,7 +165,6 @@ int32_t ViEChannel::Init() {
|
||||
vcm_->RegisterReceiveStatisticsCallback(this);
|
||||
vcm_->RegisterDecoderTimingCallback(this);
|
||||
vcm_->SetRenderDelay(kDefaultRenderDelayMs);
|
||||
module_process_thread_->RegisterModule(&vie_sync_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -178,8 +176,6 @@ ViEChannel::~ViEChannel() {
|
||||
vie_receiver_.GetReceiveStatistics());
|
||||
if (sender_) {
|
||||
send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>());
|
||||
} else {
|
||||
module_process_thread_->DeRegisterModule(&vie_sync_);
|
||||
}
|
||||
for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i)
|
||||
packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_);
|
||||
@ -1000,19 +996,6 @@ std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules(
|
||||
return modules;
|
||||
}
|
||||
|
||||
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface) {
|
||||
RTC_DCHECK(!sender_);
|
||||
return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface,
|
||||
rtp_rtcp_modules_[0],
|
||||
vie_receiver_.GetRtpReceiver());
|
||||
}
|
||||
|
||||
int32_t ViEChannel::VoiceChannel() {
|
||||
RTC_DCHECK(!sender_);
|
||||
return vie_sync_.VoiceChannel();
|
||||
}
|
||||
|
||||
void ViEChannel::RegisterPreRenderCallback(
|
||||
I420FrameCallback* pre_render_callback) {
|
||||
RTC_DCHECK(!sender_);
|
||||
|
||||
@ -211,10 +211,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
int32_t ResendPackets(const uint16_t* sequence_numbers,
|
||||
uint16_t length) override;
|
||||
|
||||
int32_t SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface);
|
||||
int32_t VoiceChannel();
|
||||
|
||||
void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback);
|
||||
|
||||
void RegisterSendFrameCountObserver(FrameCountObserver* observer);
|
||||
@ -359,7 +355,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
VideoCodingModule* const vcm_;
|
||||
ViEReceiver vie_receiver_;
|
||||
ViESyncModule vie_sync_;
|
||||
|
||||
// Helper to report call statistics.
|
||||
rtc::scoped_ptr<ChannelStatsObserver> stats_observer_;
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/video/vie_sync_module.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
||||
@ -60,17 +61,19 @@ ViESyncModule::ViESyncModule(VideoCodingModule* vcm)
|
||||
ViESyncModule::~ViESyncModule() {
|
||||
}
|
||||
|
||||
int ViESyncModule::ConfigureSync(int voe_channel_id,
|
||||
VoEVideoSync* voe_sync_interface,
|
||||
RtpRtcp* video_rtcp_module,
|
||||
RtpReceiver* video_receiver) {
|
||||
void ViESyncModule::ConfigureSync(int voe_channel_id,
|
||||
VoEVideoSync* voe_sync_interface,
|
||||
RtpRtcp* video_rtcp_module,
|
||||
RtpReceiver* video_receiver) {
|
||||
if (voe_channel_id != -1)
|
||||
RTC_DCHECK(voe_sync_interface);
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
// Prevent expensive no-ops.
|
||||
if (voe_channel_id_ == voe_channel_id &&
|
||||
voe_sync_interface_ == voe_sync_interface &&
|
||||
video_receiver_ == video_receiver &&
|
||||
video_rtp_rtcp_ == video_rtcp_module) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
voe_channel_id_ = voe_channel_id;
|
||||
voe_sync_interface_ = voe_sync_interface;
|
||||
@ -78,20 +81,6 @@ int ViESyncModule::ConfigureSync(int voe_channel_id,
|
||||
video_rtp_rtcp_ = video_rtcp_module;
|
||||
sync_.reset(
|
||||
new StreamSynchronization(video_rtp_rtcp_->SSRC(), voe_channel_id));
|
||||
|
||||
if (!voe_sync_interface) {
|
||||
voe_channel_id_ = -1;
|
||||
if (voe_channel_id >= 0) {
|
||||
// Trying to set a voice channel but no interface exist.
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViESyncModule::VoiceChannel() {
|
||||
return voe_channel_id_;
|
||||
}
|
||||
|
||||
int64_t ViESyncModule::TimeUntilNextProcess() {
|
||||
|
||||
@ -33,12 +33,10 @@ class ViESyncModule : public Module {
|
||||
explicit ViESyncModule(VideoCodingModule* vcm);
|
||||
~ViESyncModule();
|
||||
|
||||
int ConfigureSync(int voe_channel_id,
|
||||
VoEVideoSync* voe_sync_interface,
|
||||
RtpRtcp* video_rtcp_module,
|
||||
RtpReceiver* video_receiver);
|
||||
|
||||
int VoiceChannel();
|
||||
void ConfigureSync(int voe_channel_id,
|
||||
VoEVideoSync* voe_sync_interface,
|
||||
RtpRtcp* video_rtcp_module,
|
||||
RtpReceiver* video_receiver);
|
||||
|
||||
// Implements Module.
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user