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

Unified Diff: media/cast/sender/h264_vt_encoder_unittest.cc

Issue 1100643002: [cast] Handle frame size changes directly in the VideoToolbox encoder (v2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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: media/cast/sender/h264_vt_encoder_unittest.cc
diff --git a/media/cast/sender/h264_vt_encoder_unittest.cc b/media/cast/sender/h264_vt_encoder_unittest.cc
index 04f3d629da95b23a9d9f8786347b5eb691ddacfd..58c5435ab1d387b4cf11e85ebd0256d20bfcf21c 100644
--- a/media/cast/sender/h264_vt_encoder_unittest.cc
+++ b/media/cast/sender/h264_vt_encoder_unittest.cc
@@ -192,8 +192,7 @@ void CreateFrameAndMemsetPlane(VideoFrameFactory* const video_frame_factory) {
class H264VideoToolboxEncoderTest : public ::testing::Test {
protected:
- H264VideoToolboxEncoderTest()
- : operational_status_(STATUS_UNINITIALIZED) {
+ H264VideoToolboxEncoderTest() : operational_status_(STATUS_UNINITIALIZED) {
frame_->set_timestamp(base::TimeDelta());
}
@@ -206,10 +205,7 @@ class H264VideoToolboxEncoderTest : public ::testing::Test {
message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
message_loop_.message_loop_proxy());
encoder_.reset(new H264VideoToolboxEncoder(
- cast_environment_,
- video_sender_config_,
- gfx::Size(kVideoWidth, kVideoHeight),
- 0u,
+ cast_environment_, video_sender_config_,
base::Bind(&SaveOperationalStatus, &operational_status_)));
message_loop_.RunUntilIdle();
EXPECT_EQ(STATUS_INITIALIZED, operational_status_);
@@ -260,6 +256,12 @@ TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) {
VideoEncoder::FrameEncodedCallback cb = base::Bind(
&MetadataRecorder::CompareFrameWithExpected, metadata_recorder.get());
+ // The first call to |EncodeVideoFrame| will return null but post a task to
+ // the encoder to initialize for the specified frame size. We then drain the
+ // message loop. After that, the encoder should have initialized.
+ ASSERT_FALSE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
+ message_loop_.RunUntilIdle();
+
metadata_recorder->PushExpectation(
0, 0, TimeDeltaToRtpDelta(frame_->timestamp(), kVideoFrequency),
clock_->NowTicks());
@@ -287,9 +289,15 @@ TEST_F(H264VideoToolboxEncoderTest, CheckFramesAreDecodable) {
frame_->coded_size(), frame_->visible_rect(),
frame_->natural_size(), nullptr, 0, false);
scoped_refptr<EndToEndFrameChecker> checker(new EndToEndFrameChecker(config));
-
VideoEncoder::FrameEncodedCallback cb =
base::Bind(&EndToEndFrameChecker::EncodeDone, checker.get());
+
+ // The first call to |EncodeVideoFrame| will return null but post a task to
+ // the encoder to initialize for the specified frame size. We then drain the
+ // message loop. After that, the encoder should have initialized.
+ ASSERT_FALSE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
+ message_loop_.RunUntilIdle();
+
for (uint32 frame_id = 0; frame_id < 6; ++frame_id) {
checker->PushExpectation(frame_);
EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb));
@@ -306,10 +314,12 @@ TEST_F(H264VideoToolboxEncoderTest, CheckFramesAreDecodable) {
TEST_F(H264VideoToolboxEncoderTest, CheckVideoFrameFactory) {
auto video_frame_factory = encoder_->CreateVideoFrameFactory();
ASSERT_TRUE(video_frame_factory.get());
- CreateFrameAndMemsetPlane(video_frame_factory.get());
- // TODO(jfroy): Need to test that the encoder can encode VideoFrames provided
- // by the VideoFrameFactory.
- encoder_.reset();
+ // The first call to |MaybeCreateFrame| will return null but post a task to
+ // the encoder to initialize for the specified frame size. We then drain the
+ // message loop. After that, the encoder should have initialized and we
+ // request a frame again.
+ ASSERT_FALSE(video_frame_factory->MaybeCreateFrame(
+ gfx::Size(kVideoWidth, kVideoHeight), base::TimeDelta()));
message_loop_.RunUntilIdle();
CreateFrameAndMemsetPlane(video_frame_factory.get());
}

Powered by Google App Engine
This is Rietveld 408576698