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

Unified Diff: content/renderer/media/webmediaplayer_ms_unittest.cc

Issue 2150203002: Apply rotation for texture backed VideoFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 4 years, 5 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: content/renderer/media/webmediaplayer_ms_unittest.cc
diff --git a/content/renderer/media/webmediaplayer_ms_unittest.cc b/content/renderer/media/webmediaplayer_ms_unittest.cc
index d02bb0d1ec59c477d8cb989f33f6517a6874a332..96ed019d19a9ba284522e89be7e192d851612a61 100644
--- a/content/renderer/media/webmediaplayer_ms_unittest.cc
+++ b/content/renderer/media/webmediaplayer_ms_unittest.cc
@@ -137,7 +137,8 @@ class MockMediaStreamVideoRenderer : public MediaStreamVideoRenderer {
void QueueFrames(const std::vector<int>& timestamps_or_frame_type,
bool opaque_frame = true,
bool odd_size_frame = false,
- int double_size_index = -1);
+ int double_size_index = -1,
+ media::VideoRotation rotation = media::VIDEO_ROTATION_0);
bool Started() { return started_; }
bool Paused() { return paused_; }
@@ -197,7 +198,8 @@ void MockMediaStreamVideoRenderer::QueueFrames(
const std::vector<int>& timestamp_or_frame_type,
bool opaque_frame,
bool odd_size_frame,
- int double_size_index) {
+ int double_size_index,
+ media::VideoRotation rotation) {
gfx::Size standard_size = gfx::Size(kStandardWidth, kStandardHeight);
for (size_t i = 0; i < timestamp_or_frame_type.size(); i++) {
const int token = timestamp_or_frame_type[i];
@@ -222,11 +224,14 @@ void MockMediaStreamVideoRenderer::QueueFrames(
} else {
frame_size.SetSize(standard_size.width(), standard_size.height());
}
+
auto frame = media::VideoFrame::CreateZeroInitializedFrame(
opaque_frame ? media::PIXEL_FORMAT_YV12 : media::PIXEL_FORMAT_YV12A,
frame_size, gfx::Rect(frame_size), frame_size,
base::TimeDelta::FromMilliseconds(token));
+ frame->metadata()->SetRotation(media::VideoFrameMetadata::ROTATION,
+ rotation);
frame->metadata()->SetTimeTicks(
media::VideoFrameMetadata::Key::REFERENCE_TIME,
base::TimeTicks::Now() + base::TimeDelta::FromMilliseconds(token));
@@ -575,6 +580,9 @@ TEST_F(WebMediaPlayerMSTest, Playing_Normal) {
CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight)));
message_loop_controller_.RunAndWaitForStatus(
media::PipelineStatus::PIPELINE_OK);
+ const blink::WebSize& natural_size = player_->naturalSize();
+ EXPECT_EQ(kStandardWidth, natural_size.width);
+ EXPECT_EQ(kStandardHeight, natural_size.height);
testing::Mock::VerifyAndClearExpectations(this);
EXPECT_CALL(*this, DoSetWebLayer(false));
@@ -709,6 +717,35 @@ INSTANTIATE_TEST_CASE_P(,
::testing::Combine(::testing::Bool(),
::testing::Bool()));
+// During this test, we check that when we send rotated video frames, it applies
+// to player's natural size.
+TEST_F(WebMediaPlayerMSTest, RotatedVideoFrame) {
+ MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true);
+
+ static int tokens[] = {0, 33, 66};
+ std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int));
+ provider->QueueFrames(timestamps, false, false, 17, media::VIDEO_ROTATION_90);
+
+ EXPECT_CALL(*this, DoSetWebLayer(true));
+ EXPECT_CALL(*this, DoStartRendering());
+ EXPECT_CALL(*this, DoReadyStateChanged(
+ blink::WebMediaPlayer::ReadyStateHaveMetadata));
+ EXPECT_CALL(*this, DoReadyStateChanged(
+ blink::WebMediaPlayer::ReadyStateHaveEnoughData));
+ EXPECT_CALL(*this,
+ CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight)));
+ message_loop_controller_.RunAndWaitForStatus(
+ media::PipelineStatus::PIPELINE_OK);
+ const blink::WebSize& natural_size = player_->naturalSize();
+ // Check that height and width are flipped.
+ EXPECT_EQ(kStandardHeight, natural_size.width);
+ EXPECT_EQ(kStandardWidth, natural_size.height);
+ testing::Mock::VerifyAndClearExpectations(this);
+
+ EXPECT_CALL(*this, DoSetWebLayer(false));
+ EXPECT_CALL(*this, DoStopRendering());
+}
+
TEST_F(WebMediaPlayerMSTest, BackgroundRendering) {
// During this test, we will switch to background rendering mode, in which
// WebMediaPlayerMS::pause does not get called, but
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | content/renderer/media/webrtc/media_stream_remote_video_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698