Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: webrtc/video/rtp_streams_synchronizer.cc

Issue 2452163004: Stop using VoEVideoSync in Call/VideoReceiveStream. (Closed)
Patch Set: comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/video/rtp_streams_synchronizer.h ('k') | webrtc/video/stream_synchronization.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/rtp_streams_synchronizer.cc
diff --git a/webrtc/video/rtp_streams_synchronizer.cc b/webrtc/video/rtp_streams_synchronizer.cc
index 0d026b310a492d0463f6d9ac12ff0d4f46bec1d3..1edb9b8e4fcfb4fc8cd8fea956fdba418dda7bcf 100644
--- a/webrtc/video/rtp_streams_synchronizer.cc
+++ b/webrtc/video/rtp_streams_synchronizer.cc
@@ -14,83 +14,48 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/base/trace_event.h"
-#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
-#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
+#include "webrtc/call/syncable.h"
#include "webrtc/modules/video_coding/video_coding_impl.h"
-#include "webrtc/system_wrappers/include/clock.h"
-#include "webrtc/video/stream_synchronization.h"
-#include "webrtc/video_frame.h"
-#include "webrtc/voice_engine/include/voe_video_sync.h"
namespace webrtc {
namespace {
bool UpdateMeasurements(StreamSynchronization::Measurements* stream,
- RtpRtcp* rtp_rtcp,
- RtpReceiver* receiver) {
- if (!receiver->Timestamp(&stream->latest_timestamp))
- return false;
- if (!receiver->LastReceivedTimeMs(&stream->latest_receive_time_ms))
- return false;
-
- uint32_t ntp_secs = 0;
- uint32_t ntp_frac = 0;
- uint32_t rtp_timestamp = 0;
- if (rtp_rtcp->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr,
- &rtp_timestamp) != 0) {
- return false;
- }
-
+ const Syncable::Info& info) {
+ RTC_DCHECK(stream);
+ stream->latest_timestamp = info.latest_received_capture_timestamp;
+ stream->latest_receive_time_ms = info.latest_receive_time_ms;
bool new_rtcp_sr = false;
- if (!stream->rtp_to_ntp.UpdateMeasurements(ntp_secs, ntp_frac, rtp_timestamp,
+ if (!stream->rtp_to_ntp.UpdateMeasurements(info.capture_time_ntp_secs,
+ info.capture_time_ntp_frac,
+ info.capture_time_source_clock,
&new_rtcp_sr)) {
return false;
}
-
return true;
}
} // namespace
-RtpStreamsSynchronizer::RtpStreamsSynchronizer(
- vcm::VideoReceiver* video_receiver,
- RtpStreamReceiver* rtp_stream_receiver)
- : clock_(Clock::GetRealTimeClock()),
- video_receiver_(video_receiver),
- video_rtp_receiver_(rtp_stream_receiver->GetRtpReceiver()),
- video_rtp_rtcp_(rtp_stream_receiver->rtp_rtcp()),
- voe_channel_id_(-1),
- voe_sync_interface_(nullptr),
- audio_rtp_receiver_(nullptr),
- audio_rtp_rtcp_(nullptr),
+RtpStreamsSynchronizer::RtpStreamsSynchronizer(Syncable* syncable_video)
+ : syncable_video_(syncable_video),
+ syncable_audio_(nullptr),
sync_(),
last_sync_time_(rtc::TimeNanos()) {
+ RTC_DCHECK(syncable_video);
process_thread_checker_.DetachFromThread();
}
-void RtpStreamsSynchronizer::ConfigureSync(int voe_channel_id,
- VoEVideoSync* voe_sync_interface) {
- if (voe_channel_id != -1)
- RTC_DCHECK(voe_sync_interface);
-
+void RtpStreamsSynchronizer::ConfigureSync(Syncable* syncable_audio) {
rtc::CritScope lock(&crit_);
- if (voe_channel_id_ == voe_channel_id &&
- voe_sync_interface_ == voe_sync_interface) {
+ if (syncable_audio == syncable_audio_) {
// This prevents expensive no-ops.
return;
}
- voe_channel_id_ = voe_channel_id;
- voe_sync_interface_ = voe_sync_interface;
- audio_rtp_rtcp_ = nullptr;
- audio_rtp_receiver_ = nullptr;
+ syncable_audio_ = syncable_audio;
sync_.reset(nullptr);
-
- if (voe_channel_id_ != -1) {
- voe_sync_interface_->GetRtpRtcp(voe_channel_id_, &audio_rtp_rtcp_,
- &audio_rtp_receiver_);
- RTC_DCHECK(audio_rtp_rtcp_);
- RTC_DCHECK(audio_rtp_receiver_);
- sync_.reset(new StreamSynchronization(video_rtp_rtcp_->SSRC(),
- voe_channel_id_));
+ if (syncable_audio_) {
+ sync_.reset(new StreamSynchronization(syncable_video_->id(),
+ syncable_audio_->id()));
}
}
@@ -103,35 +68,22 @@ int64_t RtpStreamsSynchronizer::TimeUntilNextProcess() {
void RtpStreamsSynchronizer::Process() {
RTC_DCHECK_RUN_ON(&process_thread_checker_);
-
- const int current_video_delay_ms = video_receiver_->Delay();
last_sync_time_ = rtc::TimeNanos();
rtc::CritScope lock(&crit_);
- if (voe_channel_id_ == -1) {
+ if (!syncable_audio_) {
return;
}
- RTC_DCHECK(voe_sync_interface_);
RTC_DCHECK(sync_.get());
- int audio_jitter_buffer_delay_ms = 0;
- int playout_buffer_delay_ms = 0;
- if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_,
- &audio_jitter_buffer_delay_ms,
- &playout_buffer_delay_ms) != 0) {
+ rtc::Optional<Syncable::Info> audio_info = syncable_audio_->GetInfo();
+ if (!audio_info || !UpdateMeasurements(&audio_measurement_, *audio_info)) {
return;
}
- const int current_audio_delay_ms = audio_jitter_buffer_delay_ms +
- playout_buffer_delay_ms;
int64_t last_video_receive_ms = video_measurement_.latest_receive_time_ms;
- if (!UpdateMeasurements(&video_measurement_, video_rtp_rtcp_,
- video_rtp_receiver_)) {
- return;
- }
-
- if (!UpdateMeasurements(&audio_measurement_, audio_rtp_rtcp_,
- audio_rtp_receiver_)) {
+ rtc::Optional<Syncable::Info> video_info = syncable_video_->GetInfo();
+ if (!video_info || !UpdateMeasurements(&video_measurement_, *video_info)) {
return;
}
@@ -147,41 +99,38 @@ void RtpStreamsSynchronizer::Process() {
return;
}
- TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay", current_video_delay_ms);
- TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay", current_audio_delay_ms);
+ TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay",
+ video_info->current_delay_ms);
+ TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay",
+ audio_info->current_delay_ms);
TRACE_COUNTER1("webrtc", "SyncRelativeDelay", relative_delay_ms);
int target_audio_delay_ms = 0;
- int target_video_delay_ms = current_video_delay_ms;
+ int target_video_delay_ms = video_info->current_delay_ms;
// Calculate the necessary extra audio delay and desired total video
// delay to get the streams in sync.
if (!sync_->ComputeDelays(relative_delay_ms,
- current_audio_delay_ms,
+ audio_info->current_delay_ms,
&target_audio_delay_ms,
&target_video_delay_ms)) {
return;
}
- if (voe_sync_interface_->SetMinimumPlayoutDelay(
- voe_channel_id_, target_audio_delay_ms) == -1) {
- LOG(LS_ERROR) << "Error setting voice delay.";
- }
- video_receiver_->SetMinimumPlayoutDelay(target_video_delay_ms);
+ syncable_audio_->SetMinimumPlayoutDelay(target_audio_delay_ms);
+ syncable_video_->SetMinimumPlayoutDelay(target_video_delay_ms);
}
bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs(
- const VideoFrame& frame,
+ uint32_t timestamp,
+ int64_t render_time_ms,
int64_t* stream_offset_ms,
double* estimated_freq_khz) const {
rtc::CritScope lock(&crit_);
- if (voe_channel_id_ == -1)
- return false;
-
- uint32_t playout_timestamp = 0;
- if (voe_sync_interface_->GetPlayoutTimestamp(voe_channel_id_,
- playout_timestamp) != 0) {
+ if (!syncable_audio_) {
return false;
}
+ uint32_t playout_timestamp = syncable_audio_->GetPlayoutTimestamp();
+
int64_t latest_audio_ntp;
if (!audio_measurement_.rtp_to_ntp.Estimate(playout_timestamp,
&latest_audio_ntp)) {
@@ -189,13 +138,11 @@ bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs(
}
int64_t latest_video_ntp;
- if (!video_measurement_.rtp_to_ntp.Estimate(frame.timestamp(),
- &latest_video_ntp)) {
+ if (!video_measurement_.rtp_to_ntp.Estimate(timestamp, &latest_video_ntp)) {
return false;
}
- int64_t time_to_render_ms =
- frame.render_time_ms() - clock_->TimeInMilliseconds();
+ int64_t time_to_render_ms = render_time_ms - rtc::TimeMillis();
if (time_to_render_ms > 0)
latest_video_ntp += time_to_render_ms;
« no previous file with comments | « webrtc/video/rtp_streams_synchronizer.h ('k') | webrtc/video/stream_synchronization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698