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

Unified Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2282713002: Introduce webrtc::VideoFrame::timestamp_us, and corresponding constructor. (Closed)
Patch Set: Rename timestamp_ --> timestamp_rtp_ Created 4 years, 3 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/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine2.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
index be8eb85ac7e037ff41b636d58cf61c23b4f5532a..53c2e07fd5ab1a3ce3ab1db8c972ba3a67e9960f 100644
--- a/webrtc/media/engine/webrtcvideoengine2.cc
+++ b/webrtc/media/engine/webrtcvideoengine2.cc
@@ -1587,7 +1587,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
pending_encoder_reconfiguration_(false),
allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false),
sending_(false),
- last_frame_timestamp_ms_(0) {
+ last_frame_timestamp_us_(0) {
parameters_.config.rtp.max_packet_size = kVideoMtu;
parameters_.conference_mode = send_params.conference_mode;
@@ -1639,8 +1639,10 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::UpdateHistograms() const {
void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame(
const VideoFrame& frame) {
TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame");
- webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0,
- frame.rotation());
+ webrtc::VideoFrame video_frame(frame.video_frame_buffer(),
+ frame.rotation(),
+ frame.timestamp_us());
+
rtc::CritScope cs(&lock_);
if (video_frame.width() != last_frame_info_.width ||
@@ -1664,17 +1666,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame(
return;
}
- int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec;
-
- // frame->GetTimeStamp() is essentially a delta, align to webrtc time
- if (!first_frame_timestamp_ms_) {
- first_frame_timestamp_ms_ =
- rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms);
- }
-
- last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms;
-
- video_frame.set_render_time_ms(last_frame_timestamp_ms_);
+ last_frame_timestamp_us_ = video_frame.timestamp_us();
if (pending_encoder_reconfiguration_) {
ReconfigureEncoder();
@@ -1723,11 +1715,6 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend(
}
if (source_changing) {
- // Reset timestamps to realign new incoming frames to a webrtc timestamp.
- // A new source may have a different timestamp delta than the previous
- // one.
- first_frame_timestamp_ms_ = rtc::Optional<int64_t>();
-
if (source == nullptr && stream_ != nullptr) {
LOG(LS_VERBOSE) << "Disabling capturer, sending black frame.";
// Force this black frame not to be dropped due to timestamp order
@@ -1735,15 +1722,15 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend(
// timestamp is less than or equal to last frame's timestamp, it is
// necessary to give this black frame a larger timestamp than the
// previous one.
- last_frame_timestamp_ms_ += 1;
+ last_frame_timestamp_us_ += rtc::kNumMicrosecsPerMillisec;
rtc::scoped_refptr<webrtc::I420Buffer> black_buffer(
webrtc::I420Buffer::Create(last_frame_info_.width,
last_frame_info_.height));
black_buffer->SetToBlack();
stream_->Input()->IncomingCapturedFrame(webrtc::VideoFrame(
- black_buffer, 0 /* timestamp (90 kHz) */,
- last_frame_timestamp_ms_, last_frame_info_.rotation));
+ black_buffer, last_frame_info_.rotation,
+ last_frame_timestamp_us_));
}
source_ = source;
}
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698