Revert of Delete cricket::VideoFrame::GetTimeStamp. (patchset #1 id:1 of https://codereview.webrtc.org/2305623002/ )

Reason for revert:
Broke downstream project.

Original issue's description:
> Delete cricket::VideoFrame::GetTimeStamp.
>
> TBR=tkchin@webrtc.org  # Trivial change to VideoRendererAdapter
> BUG=webrtc:5682
>
> Committed: https://crrev.com/fd6c99e43137d01fa6c120f7160f7c2999d1d8a3
> Cr-Commit-Position: refs/heads/master@{#14037}

TBR=perkj@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5682

Review-Url: https://codereview.webrtc.org/2306953002
Cr-Commit-Position: refs/heads/master@{#14038}
This commit is contained in:
nisse
2016-09-02 02:07:02 -07:00
committed by Commit bot
parent fd6c99e431
commit bca69e87de
7 changed files with 27 additions and 19 deletions

View File

@ -26,7 +26,7 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
width_(0), width_(0),
height_(0), height_(0),
rotation_(webrtc::kVideoRotation_0), rotation_(webrtc::kVideoRotation_0),
timestamp_us_(0), timestamp_(0),
num_rendered_frames_(0), num_rendered_frames_(0),
black_frame_(false) {} black_frame_(false) {}
@ -43,7 +43,7 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
width_ = frame.width(); width_ = frame.width();
height_ = frame.height(); height_ = frame.height();
rotation_ = frame.rotation(); rotation_ = frame.rotation();
timestamp_us_ = frame.timestamp_us(); timestamp_ = frame.GetTimeStamp();
SignalRenderFrame(&frame); SignalRenderFrame(&frame);
} }
@ -61,9 +61,9 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
return rotation_; return rotation_;
} }
int64_t timestamp_us() const { int64_t timestamp() const {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
return timestamp_us_; return timestamp_;
} }
int num_rendered_frames() const { int num_rendered_frames() const {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
@ -133,7 +133,7 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
int width_; int width_;
int height_; int height_;
webrtc::VideoRotation rotation_; webrtc::VideoRotation rotation_;
int64_t timestamp_us_; int64_t timestamp_;
int num_rendered_frames_; int num_rendered_frames_;
bool black_frame_; bool black_frame_;
rtc::CriticalSection crit_; rtc::CriticalSection crit_;

View File

@ -143,9 +143,9 @@ TEST(VideoBroadcasterTest, SinkWantsBlackFrames) {
10 /* timestamp_us */, 0 /* frame_id */); 10 /* timestamp_us */, 0 /* frame_id */);
broadcaster.OnFrame(frame1); broadcaster.OnFrame(frame1);
EXPECT_TRUE(sink1.black_frame()); EXPECT_TRUE(sink1.black_frame());
EXPECT_EQ(10, sink1.timestamp_us()); EXPECT_EQ(10000, sink1.timestamp());
EXPECT_FALSE(sink2.black_frame()); EXPECT_FALSE(sink2.black_frame());
EXPECT_EQ(10, sink2.timestamp_us()); EXPECT_EQ(10000, sink2.timestamp());
// Switch the sink wants. // Switch the sink wants.
wants1.black_frames = false; wants1.black_frames = false;
@ -157,7 +157,7 @@ TEST(VideoBroadcasterTest, SinkWantsBlackFrames) {
30 /* timestamp_us */, 0 /* frame_id */); 30 /* timestamp_us */, 0 /* frame_id */);
broadcaster.OnFrame(frame2); broadcaster.OnFrame(frame2);
EXPECT_FALSE(sink1.black_frame()); EXPECT_FALSE(sink1.black_frame());
EXPECT_EQ(30, sink1.timestamp_us()); EXPECT_EQ(30000, sink1.timestamp());
EXPECT_TRUE(sink2.black_frame()); EXPECT_TRUE(sink2.black_frame());
EXPECT_EQ(30, sink2.timestamp_us()); EXPECT_EQ(30000, sink2.timestamp());
} }

View File

@ -45,6 +45,13 @@ class VideoFrame {
virtual int64_t timestamp_us() const = 0; virtual int64_t timestamp_us() const = 0;
virtual void set_timestamp_us(int64_t time_us) = 0; virtual void set_timestamp_us(int64_t time_us) = 0;
// Deprecated methods, for backwards compatibility.
// TODO(nisse): Delete when usage in Chrome and other applications
// have been replaced.
virtual int64_t GetTimeStamp() const {
return rtc::kNumNanosecsPerMicrosec * timestamp_us();
}
// Indicates the rotation angle in degrees. // Indicates the rotation angle in degrees.
virtual webrtc::VideoRotation rotation() const = 0; virtual webrtc::VideoRotation rotation() const = 0;

View File

@ -453,7 +453,7 @@ class VideoFrameTest : public testing::Test {
static bool IsEqual(const cricket::VideoFrame& frame, static bool IsEqual(const cricket::VideoFrame& frame,
int width, int width,
int height, int height,
int64_t timestamp_us, int64_t time_stamp,
const uint8_t* y, const uint8_t* y,
uint32_t ypitch, uint32_t ypitch,
const uint8_t* u, const uint8_t* u,
@ -461,8 +461,7 @@ class VideoFrameTest : public testing::Test {
const uint8_t* v, const uint8_t* v,
uint32_t vpitch, uint32_t vpitch,
int max_error) { int max_error) {
return IsSize(frame, width, height) && return IsSize(frame, width, height) && frame.GetTimeStamp() == time_stamp &&
frame.timestamp_us() == timestamp_us &&
IsPlaneEqual("y", frame.video_frame_buffer()->DataY(), IsPlaneEqual("y", frame.video_frame_buffer()->DataY(),
frame.video_frame_buffer()->StrideY(), y, ypitch, frame.video_frame_buffer()->StrideY(), y, ypitch,
static_cast<uint32_t>(width), static_cast<uint32_t>(width),
@ -482,7 +481,7 @@ class VideoFrameTest : public testing::Test {
int max_error) { int max_error) {
return IsEqual(frame1, return IsEqual(frame1,
frame2.width(), frame2.height(), frame2.width(), frame2.height(),
frame2.timestamp_us(), frame2.GetTimeStamp(),
frame2.video_frame_buffer()->DataY(), frame2.video_frame_buffer()->DataY(),
frame2.video_frame_buffer()->StrideY(), frame2.video_frame_buffer()->StrideY(),
frame2.video_frame_buffer()->DataU(), frame2.video_frame_buffer()->DataU(),
@ -500,7 +499,7 @@ class VideoFrameTest : public testing::Test {
IsEqual(frame1, IsEqual(frame1,
frame2.width() - hcrop * 2, frame2.width() - hcrop * 2,
frame2.height() - vcrop * 2, frame2.height() - vcrop * 2,
frame2.timestamp_us(), frame2.GetTimeStamp(),
frame2.video_frame_buffer()->DataY() frame2.video_frame_buffer()->DataY()
+ vcrop * frame2.video_frame_buffer()->StrideY() + vcrop * frame2.video_frame_buffer()->StrideY()
+ hcrop, + hcrop,

View File

@ -1664,8 +1664,9 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame(
return; return;
} }
int64_t frame_delta_ms = frame.timestamp_us() / rtc::kNumMicrosecsPerMillisec; int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec;
// frame->GetTimeStamp() is essentially a delta, align to webrtc time
if (!first_frame_timestamp_ms_) { if (!first_frame_timestamp_ms_) {
first_frame_timestamp_ms_ = first_frame_timestamp_ms_ =
rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms); rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms);

View File

@ -186,13 +186,15 @@ TEST_F(WebRtcVideoFrameTest, TextureInitialValues) {
webrtc::NativeHandleBuffer* buffer = webrtc::NativeHandleBuffer* buffer =
new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>( new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
dummy_handle, 640, 480); dummy_handle, 640, 480);
// Timestamp is converted from ns to us, so last three digits are lost.
WebRtcVideoFrame frame(buffer, webrtc::kVideoRotation_0, 20); WebRtcVideoFrame frame(buffer, 20000, webrtc::kVideoRotation_0);
EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle());
EXPECT_EQ(640, frame.width()); EXPECT_EQ(640, frame.width());
EXPECT_EQ(480, frame.height()); EXPECT_EQ(480, frame.height());
EXPECT_EQ(20000, frame.GetTimeStamp());
EXPECT_EQ(20, frame.timestamp_us()); EXPECT_EQ(20, frame.timestamp_us());
frame.set_timestamp_us(40); frame.set_timestamp_us(40);
EXPECT_EQ(40000, frame.GetTimeStamp());
EXPECT_EQ(40, frame.timestamp_us()); EXPECT_EQ(40, frame.timestamp_us());
} }

View File

@ -30,8 +30,7 @@ class VideoRendererAdapter
RTCVideoFrame* videoFrame = [[RTCVideoFrame alloc] RTCVideoFrame* videoFrame = [[RTCVideoFrame alloc]
initWithVideoBuffer:nativeVideoFrame.video_frame_buffer() initWithVideoBuffer:nativeVideoFrame.video_frame_buffer()
rotation:nativeVideoFrame.rotation() rotation:nativeVideoFrame.rotation()
timeStampNs:nativeVideoFrame.timestamp_us() * timeStampNs:nativeVideoFrame.GetTimeStamp()];
rtc::kNumNanosecsPerMicrosec];
CGSize current_size = (videoFrame.rotation % 180 == 0) CGSize current_size = (videoFrame.rotation % 180 == 0)
? CGSizeMake(videoFrame.width, videoFrame.height) ? CGSizeMake(videoFrame.width, videoFrame.height)
: CGSizeMake(videoFrame.height, videoFrame.width); : CGSizeMake(videoFrame.height, videoFrame.width);