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

Reason for revert:
Will reland after downstream projects are updated.

Original issue's description:
> 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
>
> Committed: https://crrev.com/bca69e87de5df290f728833a4b3d8af3ae5d88e6
> Cr-Commit-Position: refs/heads/master@{#14038}

TBR=perkj@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682

Review-Url: https://codereview.webrtc.org/2310043002
Cr-Commit-Position: refs/heads/master@{#14089}
This commit is contained in:
nisse 2016-09-06 04:46:18 -07:00 committed by Commit bot
parent 857a8fb861
commit fa1ba19c5c
6 changed files with 18 additions and 25 deletions

View File

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

View File

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

View File

@ -45,13 +45,6 @@ class VideoFrame {
virtual int64_t timestamp_us() const = 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.
virtual webrtc::VideoRotation rotation() const = 0;

View File

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

View File

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

View File

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