diff options
author | miu <miu@chromium.org> | 2014-10-06 21:54:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 04:55:55 +0000 |
commit | 7a944362f541a76411ad242be5582337a659f261 (patch) | |
tree | e2c3e4b9d552be1533bd74ff071f2a96561538fa /media/cast/sender/video_sender_unittest.cc | |
parent | a0a73e578b6785c23cc945021fc9a955b19f8231 (diff) | |
download | chromium_src-7a944362f541a76411ad242be5582337a659f261.zip chromium_src-7a944362f541a76411ad242be5582337a659f261.tar.gz chromium_src-7a944362f541a76411ad242be5582337a659f261.tar.bz2 |
[Cast] Video encoder clean-ups (stricter interfaces, encapsulation, etc.)
Note: There are no functional or behavioral differences in this change.
Clean-up code throughout the media/cast video encoder code paths to
simplify and clarify behavior and improve the encapsulation of
functionality in the right places.
1. Video RTP timestamps are computed from the VideoFrame::timestamp(),
not the reference time. For MediaStream sources, this has no effect
since both timestamps are currently fixed to increment at the same rate.
2. Corrected terminology, renaming "capture timestamp" to "reference
timestamp" everywhere. Added placeholder fix for the logging of a video
frame's "capture begin" event in VideoSender::InsertRawVideoFrame().
3. SoftwareVideoEncoders can no longer fail in a call to Encode(), and
VideoEncoderImpl can no longer silently drop frames it has accepted for
asynchronous encoding. VideoSender depends on this to work correctly.
4. VP8Encoder: Re-ordered vpx_codec_enc_cfg_t field assignments to match
VP8 docs and declaration ordering, and added code comments to document
meanings/decisions. Also, the VP8 "structs" are now local private
members of the VP8Encoder class (composition, instead of indirection).
BUG=418323
Review URL: https://codereview.chromium.org/602413003
Cr-Commit-Position: refs/heads/master@{#298375}
Diffstat (limited to 'media/cast/sender/video_sender_unittest.cc')
-rw-r--r-- | media/cast/sender/video_sender_unittest.cc | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/media/cast/sender/video_sender_unittest.cc b/media/cast/sender/video_sender_unittest.cc index d0cbdb2..29cbfb4 100644 --- a/media/cast/sender/video_sender_unittest.cc +++ b/media/cast/sender/video_sender_unittest.cc @@ -221,19 +221,25 @@ class VideoSenderTest : public ::testing::Test { } scoped_refptr<media::VideoFrame> GetNewVideoFrame() { + if (first_frame_timestamp_.is_null()) + first_frame_timestamp_ = testing_clock_->NowTicks(); gfx::Size size(kWidth, kHeight); scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( - VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); + VideoFrame::I420, size, gfx::Rect(size), size, + testing_clock_->NowTicks() - first_frame_timestamp_); PopulateVideoFrame(video_frame.get(), last_pixel_value_++); return video_frame; } scoped_refptr<media::VideoFrame> GetLargeNewVideoFrame() { + if (first_frame_timestamp_.is_null()) + first_frame_timestamp_ = testing_clock_->NowTicks(); gfx::Size size(kWidth, kHeight); scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( - VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); + VideoFrame::I420, size, gfx::Rect(size), size, + testing_clock_->NowTicks() - first_frame_timestamp_); PopulateVideoFrameWithNoise(video_frame.get()); return video_frame; } @@ -250,6 +256,7 @@ class VideoSenderTest : public ::testing::Test { std::vector<uint32> stored_bitrates_; scoped_refptr<CastEnvironment> cast_environment_; int last_pixel_value_; + base::TimeTicks first_frame_timestamp_; DISALLOW_COPY_AND_ASSIGN(VideoSenderTest); }; @@ -258,8 +265,8 @@ TEST_F(VideoSenderTest, BuiltInEncoder) { EXPECT_EQ(STATUS_VIDEO_INITIALIZED, InitEncoder(false, true)); scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); - const base::TimeTicks capture_time = testing_clock_->NowTicks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + const base::TimeTicks reference_time = testing_clock_->NowTicks(); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); task_runner_->RunTasks(); EXPECT_LE(1, transport_.number_of_rtp_packets()); @@ -271,12 +278,12 @@ TEST_F(VideoSenderTest, ExternalEncoder) { scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); - const base::TimeTicks capture_time = testing_clock_->NowTicks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + const base::TimeTicks reference_time = testing_clock_->NowTicks(); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); task_runner_->RunTasks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); task_runner_->RunTasks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); task_runner_->RunTasks(); // Fixed bitrate is used for external encoder. Bitrate is only once @@ -298,8 +305,8 @@ TEST_F(VideoSenderTest, RtcpTimer) { scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); - const base::TimeTicks capture_time = testing_clock_->NowTicks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + const base::TimeTicks reference_time = testing_clock_->NowTicks(); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); // Make sure that we send at least one RTCP packet. base::TimeDelta max_rtcp_timeout = @@ -322,8 +329,8 @@ TEST_F(VideoSenderTest, ResendTimer) { scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); - const base::TimeTicks capture_time = testing_clock_->NowTicks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + const base::TimeTicks reference_time = testing_clock_->NowTicks(); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); // ACK the key frame. RtcpCastMessage cast_feedback(1); @@ -332,7 +339,7 @@ TEST_F(VideoSenderTest, ResendTimer) { video_sender_->OnReceivedCastFeedback(cast_feedback); video_frame = GetNewVideoFrame(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); base::TimeDelta max_resend_timeout = base::TimeDelta::FromMilliseconds(1 + kDefaultRtpMaxDelayMs); @@ -354,8 +361,8 @@ TEST_F(VideoSenderTest, LogAckReceivedEvent) { for (int i = 0; i < num_frames; i++) { scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); - const base::TimeTicks capture_time = testing_clock_->NowTicks(); - video_sender_->InsertRawVideoFrame(video_frame, capture_time); + const base::TimeTicks reference_time = testing_clock_->NowTicks(); + video_sender_->InsertRawVideoFrame(video_frame, reference_time); RunTasks(33); } |