Use microsecond timestamp in cricket::VideoFrame.

BUG=webrtc:5740

Review URL: https://codereview.webrtc.org/1865283002

Cr-Commit-Position: refs/heads/master@{#12348}
This commit is contained in:
nisse
2016-04-13 09:36:54 -07:00
committed by Commit bot
parent 6d6e7c5e1a
commit f30ba114bb
11 changed files with 113 additions and 72 deletions

View File

@ -27,6 +27,13 @@ struct CapturedFrame;
class WebRtcVideoFrame : public VideoFrame {
public:
WebRtcVideoFrame();
// Preferred construction, with microsecond timestamp.
WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
webrtc::VideoRotation rotation,
int64_t timestamp_us);
// TODO(nisse): Deprecate/delete.
WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation);
@ -47,8 +54,13 @@ class WebRtcVideoFrame : public VideoFrame {
int64_t time_stamp_ns,
webrtc::VideoRotation rotation);
// The timestamp of the captured frame is expected to use the same
// timescale and epoch as rtc::Time.
// TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if
// the time is too far off.
bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation);
void InitToEmptyBuffer(int w, int h);
void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
bool InitToBlack(int w, int h, int64_t time_stamp_ns);
@ -69,10 +81,9 @@ class WebRtcVideoFrame : public VideoFrame {
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer()
const override;
int64_t GetTimeStamp() const override { return time_stamp_ns_; }
void SetTimeStamp(int64_t time_stamp_ns) override {
time_stamp_ns_ = time_stamp_ns;
}
/* System monotonic clock */
int64_t timestamp_us() const override { return timestamp_us_; }
void set_timestamp_us(int64_t time_us) { timestamp_us_ = time_us; };
webrtc::VideoRotation rotation() const override { return rotation_; }
@ -95,15 +106,15 @@ class WebRtcVideoFrame : public VideoFrame {
// |dh| is destination height, like |dw|, but must be a positive number.
// Returns whether the function succeeded or failed.
bool Reset(uint32_t format,
int w,
int h,
int dw,
int dh,
uint8_t* sample,
size_t sample_size,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation);
int w,
int h,
int dw,
int dh,
uint8_t* sample,
size_t sample_size,
int64_t timestamp_us,
webrtc::VideoRotation rotation,
bool apply_rotation);
private:
VideoFrame* CreateEmptyFrame(int w, int h,
@ -111,7 +122,7 @@ class WebRtcVideoFrame : public VideoFrame {
// An opaque reference counted handle that stores the pixel data.
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
int64_t time_stamp_ns_;
int64_t timestamp_us_;
webrtc::VideoRotation rotation_;
// This is mutable as the calculation is expensive but once calculated, it