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

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

Issue 1225153002: Let WebRtcVideoChannel2::WebRtcVideoSendStream::InputFrame carry the input frame's timestamp to out… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Style Fix and Comment Fix Created 5 years, 5 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 | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/media/webrtc/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/media/webrtc/webrtcvideoengine2.cc
diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc
index 0a2152e5e4c891494f34df4a271acb13aa3ec90f..cf26ccfc3a4daa038d2535b53b90ddeff979af53 100644
--- a/talk/media/webrtc/webrtcvideoengine2.cc
+++ b/talk/media/webrtc/webrtcvideoengine2.cc
@@ -42,6 +42,7 @@
#include "webrtc/base/buffer.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringutils.h"
+#include "webrtc/base/timeutils.h"
#include "webrtc/call.h"
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
@@ -1663,7 +1664,9 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
capturer_(NULL),
sending_(false),
muted_(false),
- old_adapt_changes_(0) {
+ old_adapt_changes_(0),
+ first_frame_timestamp_ms_(0),
+ last_frame_timestamp_ms_(0) {
parameters_.config.rtp.max_packet_size = kVideoMtu;
sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
@@ -1727,6 +1730,15 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::InputFrame(
static_cast<int>(frame->GetWidth()),
static_cast<int>(frame->GetHeight()));
}
+
+ int64_t frame_delta_ms = frame->GetTimeStamp() / rtc::kNumNanosecsPerMillisec;
+ // frame->GetTimeStamp() is essentially a delta, align to webrtc time
+ if (first_frame_timestamp_ms_ == 0) {
+ first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms;
+ }
+
+ last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms;
+ video_frame.set_render_time_ms(last_frame_timestamp_ms_);
// Reconfigure codec if necessary.
SetDimensions(
video_frame.width(), video_frame.height(), capturer->IsScreencast());
@@ -1755,6 +1767,15 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer(
CreateBlackFrame(&black_frame, last_dimensions_.width,
last_dimensions_.height);
+
+ // Force this black frame not to be dropped due to timestamp order
+ // check. As IncomingCapturedFrame will drop the frame if this frame's
+ // 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_ +=
+ format_.interval / rtc::kNumNanosecsPerMillisec;
+ black_frame.set_render_time_ms(last_frame_timestamp_ms_);
stream_->Input()->IncomingCapturedFrame(black_frame);
}
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/media/webrtc/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698