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

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

Issue 1865283002: Use microsecond timestamp in cricket::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use rtc::Optional. Created 4 years, 8 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
Index: webrtc/media/engine/webrtcvideoframe.cc
diff --git a/webrtc/media/engine/webrtcvideoframe.cc b/webrtc/media/engine/webrtcvideoframe.cc
index 3a2d2def0e3af094681610aab54803ad0a98eba1..a2edfdc0a1dfcabeba3fe324a2d4f7df535ffb51 100644
--- a/webrtc/media/engine/webrtcvideoframe.cc
+++ b/webrtc/media/engine/webrtcvideoframe.cc
@@ -22,17 +22,17 @@ using webrtc::kVPlane;
namespace cricket {
-WebRtcVideoFrame::WebRtcVideoFrame():
- time_stamp_ns_(0),
- rotation_(webrtc::kVideoRotation_0) {}
+WebRtcVideoFrame::WebRtcVideoFrame()
+ : timestamp_us_(0), rotation_(webrtc::kVideoRotation_0) {}
WebRtcVideoFrame::WebRtcVideoFrame(
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation)
: video_frame_buffer_(buffer),
- time_stamp_ns_(time_stamp_ns),
rotation_(rotation) {
+ // Convert to usecs.
+ SetTimeStamp(time_stamp_ns);
}
WebRtcVideoFrame::~WebRtcVideoFrame() {}
@@ -46,17 +46,24 @@ bool WebRtcVideoFrame::Init(uint32_t format,
size_t sample_size,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation) {
- return Reset(format, w, h, dw, dh, sample, sample_size,
- time_stamp_ns, rotation,
- true /*apply_rotation*/);
+ if (!Reset(format, w, h, dw, dh, sample, sample_size, rotation,
+ true /*apply_rotation*/))
+ return false;
+
+ SetTimeStamp(time_stamp_ns);
+ return true;
}
bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh,
bool apply_rotation) {
- return Reset(frame->fourcc, frame->width, frame->height, dw, dh,
- static_cast<uint8_t*>(frame->data), frame->data_size,
- frame->time_stamp,
- frame->rotation, apply_rotation);
+ if (!Reset(frame->fourcc, frame->width, frame->height, dw, dh,
+ static_cast<uint8_t*>(frame->data), frame->data_size,
+ frame->rotation, apply_rotation)) {
+ return false;
+ }
+ SetTimeStamp(frame->time_stamp);
+
+ return true;
}
bool WebRtcVideoFrame::InitToBlack(int w, int h,
@@ -127,7 +134,9 @@ WebRtcVideoFrame::GetVideoFrameBuffer() const {
VideoFrame* WebRtcVideoFrame::Copy() const {
WebRtcVideoFrame* new_frame = new WebRtcVideoFrame(
- video_frame_buffer_, time_stamp_ns_, rotation_);
+ video_frame_buffer_, 0 /* Dummy timestamp, overwridden below */,
pbos-webrtc 2016/04/13 12:04:04 That seems weird? rtc::kNumNanosecsPerMicrosec * t
nisse-webrtc 2016/04/13 13:02:12 I added a constructor with us timestamp (and argum
+ rotation_);
+ new_frame->set_timestamp_us(timestamp_us_);
return new_frame;
}
@@ -147,7 +156,6 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
int dh,
uint8_t* sample,
size_t sample_size,
- int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation) {
if (!Validate(format, w, h, sample, sample_size)) {
@@ -166,8 +174,7 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
new_height = dw;
}
- InitToEmptyBuffer(new_width, new_height,
- time_stamp_ns);
+ InitToEmptyBuffer(new_width, new_height);
rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
int horiz_crop = ((w - dw) / 2) & ~1;
@@ -197,16 +204,21 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
VideoFrame* WebRtcVideoFrame::CreateEmptyFrame(
int w, int h,
pbos-webrtc 2016/04/13 12:04:04 git cl format here
nisse-webrtc 2016/04/13 13:02:12 Done.
- int64_t time_stamp_ns) const {
+ int64_t timestamp_us) const {
WebRtcVideoFrame* frame = new WebRtcVideoFrame();
- frame->InitToEmptyBuffer(w, h, time_stamp_ns);
+ frame->InitToEmptyBuffer(w, h, rtc::kNumNanosecsPerMicrosec * timestamp_us);
return frame;
}
+void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) {
+ video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
+ rotation_ = webrtc::kVideoRotation_0;
+}
+
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h,
int64_t time_stamp_ns) {
video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
- time_stamp_ns_ = time_stamp_ns;
+ SetTimeStamp(time_stamp_ns);
rotation_ = webrtc::kVideoRotation_0;
}
@@ -237,8 +249,8 @@ const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const {
rotated_height = orig_width;
}
- rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height,
- GetTimeStamp()));
+ rotated_frame_.reset(
+ CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_));
// TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
// VideoRotation to libyuv::RotationMode.

Powered by Google App Engine
This is Rietveld 408576698