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

Side by Side Diff: media/cast/sender/h264_vt_encoder_unittest.cc

Issue 883013003: [Cast] Separate frame size from VideoSenderConfig in H264VideoToolboxEncoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « media/cast/sender/h264_vt_encoder.cc ('k') | media/cast/sender/video_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <queue> 5 #include <queue>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/launcher/unit_test_launcher.h" 10 #include "base/test/launcher/unit_test_launcher.h"
11 #include "base/test/simple_test_tick_clock.h" 11 #include "base/test/simple_test_tick_clock.h"
12 #include "base/test/test_suite.h" 12 #include "base/test/test_suite.h"
13 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
14 #include "media/base/media.h" 14 #include "media/base/media.h"
15 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
16 #include "media/cast/sender/h264_vt_encoder.h" 16 #include "media/cast/sender/h264_vt_encoder.h"
17 #include "media/cast/sender/video_frame_factory.h" 17 #include "media/cast/sender/video_frame_factory.h"
18 #include "media/cast/test/utility/default_config.h" 18 #include "media/cast/test/utility/default_config.h"
19 #include "media/cast/test/utility/video_utility.h" 19 #include "media/cast/test/utility/video_utility.h"
20 #include "media/ffmpeg/ffmpeg_common.h" 20 #include "media/ffmpeg/ffmpeg_common.h"
21 #include "media/filters/ffmpeg_glue.h" 21 #include "media/filters/ffmpeg_glue.h"
22 #include "media/filters/ffmpeg_video_decoder.h" 22 #include "media/filters/ffmpeg_video_decoder.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace { 25 namespace {
26 26
27 const int kVideoWidth = 1280;
28 const int kVideoHeight = 720;
29
27 class MediaTestSuite : public base::TestSuite { 30 class MediaTestSuite : public base::TestSuite {
28 public: 31 public:
29 MediaTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} 32 MediaTestSuite(int argc, char** argv) : TestSuite(argc, argv) {}
30 ~MediaTestSuite() override {} 33 ~MediaTestSuite() override {}
31 34
32 protected: 35 protected:
33 void Initialize() override; 36 void Initialize() override;
34 }; 37 };
35 38
36 void MediaTestSuite::Initialize() { 39 void MediaTestSuite::Initialize() {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 void SetUp() override { 198 void SetUp() override {
196 clock_ = new base::SimpleTestTickClock(); 199 clock_ = new base::SimpleTestTickClock();
197 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); 200 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
198 201
199 cast_environment_ = new CastEnvironment( 202 cast_environment_ = new CastEnvironment(
200 scoped_ptr<base::TickClock>(clock_).Pass(), 203 scoped_ptr<base::TickClock>(clock_).Pass(),
201 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), 204 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
202 message_loop_.message_loop_proxy()); 205 message_loop_.message_loop_proxy());
203 encoder_.reset(new H264VideoToolboxEncoder( 206 encoder_.reset(new H264VideoToolboxEncoder(
204 cast_environment_, video_sender_config_, 207 cast_environment_,
208 video_sender_config_,
209 gfx::Size(kVideoWidth, kVideoHeight),
205 base::Bind(&SaveInitializationStatus, &cast_initialization_status_))); 210 base::Bind(&SaveInitializationStatus, &cast_initialization_status_)));
206 message_loop_.RunUntilIdle(); 211 message_loop_.RunUntilIdle();
207 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, cast_initialization_status_); 212 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, cast_initialization_status_);
208 } 213 }
209 214
210 void TearDown() override { 215 void TearDown() override {
211 encoder_.reset(); 216 encoder_.reset();
212 message_loop_.RunUntilIdle(); 217 message_loop_.RunUntilIdle();
213 } 218 }
214 219
215 void AdvanceClockAndVideoFrameTimestamp() { 220 void AdvanceClockAndVideoFrameTimestamp() {
216 clock_->Advance(base::TimeDelta::FromMilliseconds(33)); 221 clock_->Advance(base::TimeDelta::FromMilliseconds(33));
217 frame_->set_timestamp(frame_->timestamp() + 222 frame_->set_timestamp(frame_->timestamp() +
218 base::TimeDelta::FromMilliseconds(33)); 223 base::TimeDelta::FromMilliseconds(33));
219 } 224 }
220 225
221 static void SetUpTestCase() { 226 static void SetUpTestCase() {
222 // Reusable test data. 227 // Reusable test data.
223 video_sender_config_ = GetDefaultVideoSenderConfig(); 228 video_sender_config_ = GetDefaultVideoSenderConfig();
224 video_sender_config_.codec = CODEC_VIDEO_H264; 229 video_sender_config_.codec = CODEC_VIDEO_H264;
225 gfx::Size size(video_sender_config_.width, video_sender_config_.height); 230 const gfx::Size size(kVideoWidth, kVideoHeight);
226 frame_ = media::VideoFrame::CreateFrame( 231 frame_ = media::VideoFrame::CreateFrame(
227 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); 232 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta());
228 PopulateVideoFrame(frame_.get(), 123); 233 PopulateVideoFrame(frame_.get(), 123);
229 } 234 }
230 235
231 static void TearDownTestCase() { frame_ = nullptr; } 236 static void TearDownTestCase() { frame_ = nullptr; }
232 237
233 static scoped_refptr<media::VideoFrame> frame_; 238 static scoped_refptr<media::VideoFrame> frame_;
234 static VideoSenderConfig video_sender_config_; 239 static VideoSenderConfig video_sender_config_;
235 240
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 auto video_frame_factory = encoder_->CreateVideoFrameFactory(); 304 auto video_frame_factory = encoder_->CreateVideoFrameFactory();
300 ASSERT_TRUE(video_frame_factory.get()); 305 ASSERT_TRUE(video_frame_factory.get());
301 CreateFrameAndMemsetPlane(video_frame_factory.get()); 306 CreateFrameAndMemsetPlane(video_frame_factory.get());
302 encoder_.reset(); 307 encoder_.reset();
303 message_loop_.RunUntilIdle(); 308 message_loop_.RunUntilIdle();
304 CreateFrameAndMemsetPlane(video_frame_factory.get()); 309 CreateFrameAndMemsetPlane(video_frame_factory.get());
305 } 310 }
306 311
307 } // namespace cast 312 } // namespace cast
308 } // namespace media 313 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/h264_vt_encoder.cc ('k') | media/cast/sender/video_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698