| OLD | NEW |
| 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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 namespace media { | 60 namespace media { |
| 61 namespace cast { | 61 namespace cast { |
| 62 | 62 |
| 63 // See comment in end2end_unittest.cc for details on this value. | 63 // See comment in end2end_unittest.cc for details on this value. |
| 64 const double kVideoAcceptedPSNR = 38.0; | 64 const double kVideoAcceptedPSNR = 38.0; |
| 65 | 65 |
| 66 void SavePipelineStatus(PipelineStatus* out_status, PipelineStatus in_status) { | 66 void SavePipelineStatus(PipelineStatus* out_status, PipelineStatus in_status) { |
| 67 *out_status = in_status; | 67 *out_status = in_status; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void SaveInitializationStatus(CastInitializationStatus* out_status, | 70 void SaveOperationalStatus(OperationalStatus* out_status, |
| 71 CastInitializationStatus in_status) { | 71 OperationalStatus in_status) { |
| 72 *out_status = in_status; | 72 *out_status = in_status; |
| 73 } | 73 } |
| 74 | 74 |
| 75 class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> { | 75 class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> { |
| 76 public: | 76 public: |
| 77 MetadataRecorder() : count_frames_delivered_(0) {} | 77 MetadataRecorder() : count_frames_delivered_(0) {} |
| 78 | 78 |
| 79 int count_frames_delivered() const { return count_frames_delivered_; } | 79 int count_frames_delivered() const { return count_frames_delivered_; } |
| 80 | 80 |
| 81 void PushExpectation(uint32 expected_frame_id, | 81 void PushExpectation(uint32 expected_frame_id, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 CVPixelBufferLockBaseAddress(cv_pixel_buffer, 0); | 183 CVPixelBufferLockBaseAddress(cv_pixel_buffer, 0); |
| 184 auto ptr = CVPixelBufferGetBaseAddressOfPlane(cv_pixel_buffer, 0); | 184 auto ptr = CVPixelBufferGetBaseAddressOfPlane(cv_pixel_buffer, 0); |
| 185 ASSERT_TRUE(ptr); | 185 ASSERT_TRUE(ptr); |
| 186 memset(ptr, 0xfe, CVPixelBufferGetBytesPerRowOfPlane(cv_pixel_buffer, 0) * | 186 memset(ptr, 0xfe, CVPixelBufferGetBytesPerRowOfPlane(cv_pixel_buffer, 0) * |
| 187 CVPixelBufferGetHeightOfPlane(cv_pixel_buffer, 0)); | 187 CVPixelBufferGetHeightOfPlane(cv_pixel_buffer, 0)); |
| 188 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0); | 188 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0); |
| 189 } | 189 } |
| 190 | 190 |
| 191 class H264VideoToolboxEncoderTest : public ::testing::Test { | 191 class H264VideoToolboxEncoderTest : public ::testing::Test { |
| 192 protected: | 192 protected: |
| 193 H264VideoToolboxEncoderTest() { | 193 H264VideoToolboxEncoderTest() |
| 194 cast_initialization_status_ = STATUS_VIDEO_UNINITIALIZED; | 194 : operational_status_(STATUS_UNINITIALIZED) { |
| 195 frame_->set_timestamp(base::TimeDelta()); | 195 frame_->set_timestamp(base::TimeDelta()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void SetUp() override { | 198 void SetUp() override { |
| 199 clock_ = new base::SimpleTestTickClock(); | 199 clock_ = new base::SimpleTestTickClock(); |
| 200 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); | 200 clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); |
| 201 | 201 |
| 202 cast_environment_ = new CastEnvironment( | 202 cast_environment_ = new CastEnvironment( |
| 203 scoped_ptr<base::TickClock>(clock_).Pass(), | 203 scoped_ptr<base::TickClock>(clock_).Pass(), |
| 204 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), | 204 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), |
| 205 message_loop_.message_loop_proxy()); | 205 message_loop_.message_loop_proxy()); |
| 206 encoder_.reset(new H264VideoToolboxEncoder( | 206 encoder_.reset(new H264VideoToolboxEncoder( |
| 207 cast_environment_, | 207 cast_environment_, |
| 208 video_sender_config_, | 208 video_sender_config_, |
| 209 gfx::Size(kVideoWidth, kVideoHeight), | 209 gfx::Size(kVideoWidth, kVideoHeight), |
| 210 base::Bind(&SaveInitializationStatus, &cast_initialization_status_))); | 210 base::Bind(&SaveOperationalStatus, &operational_status_))); |
| 211 message_loop_.RunUntilIdle(); | 211 message_loop_.RunUntilIdle(); |
| 212 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, cast_initialization_status_); | 212 EXPECT_EQ(STATUS_INITIALIZED, operational_status_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void TearDown() override { | 215 void TearDown() override { |
| 216 encoder_.reset(); | 216 encoder_.reset(); |
| 217 message_loop_.RunUntilIdle(); | 217 message_loop_.RunUntilIdle(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void AdvanceClockAndVideoFrameTimestamp() { | 220 void AdvanceClockAndVideoFrameTimestamp() { |
| 221 clock_->Advance(base::TimeDelta::FromMilliseconds(33)); | 221 clock_->Advance(base::TimeDelta::FromMilliseconds(33)); |
| 222 frame_->set_timestamp(frame_->timestamp() + | 222 frame_->set_timestamp(frame_->timestamp() + |
| (...skipping 12 matching lines...) Expand all Loading... |
| 235 | 235 |
| 236 static void TearDownTestCase() { frame_ = nullptr; } | 236 static void TearDownTestCase() { frame_ = nullptr; } |
| 237 | 237 |
| 238 static scoped_refptr<media::VideoFrame> frame_; | 238 static scoped_refptr<media::VideoFrame> frame_; |
| 239 static VideoSenderConfig video_sender_config_; | 239 static VideoSenderConfig video_sender_config_; |
| 240 | 240 |
| 241 base::SimpleTestTickClock* clock_; // Owned by CastEnvironment. | 241 base::SimpleTestTickClock* clock_; // Owned by CastEnvironment. |
| 242 base::MessageLoop message_loop_; | 242 base::MessageLoop message_loop_; |
| 243 scoped_refptr<CastEnvironment> cast_environment_; | 243 scoped_refptr<CastEnvironment> cast_environment_; |
| 244 scoped_ptr<VideoEncoder> encoder_; | 244 scoped_ptr<VideoEncoder> encoder_; |
| 245 CastInitializationStatus cast_initialization_status_; | 245 OperationalStatus operational_status_; |
| 246 | 246 |
| 247 private: | 247 private: |
| 248 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoderTest); | 248 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoderTest); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 // static | 251 // static |
| 252 scoped_refptr<media::VideoFrame> H264VideoToolboxEncoderTest::frame_; | 252 scoped_refptr<media::VideoFrame> H264VideoToolboxEncoderTest::frame_; |
| 253 VideoSenderConfig H264VideoToolboxEncoderTest::video_sender_config_; | 253 VideoSenderConfig H264VideoToolboxEncoderTest::video_sender_config_; |
| 254 | 254 |
| 255 TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) { | 255 TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 auto video_frame_factory = encoder_->CreateVideoFrameFactory(); | 304 auto video_frame_factory = encoder_->CreateVideoFrameFactory(); |
| 305 ASSERT_TRUE(video_frame_factory.get()); | 305 ASSERT_TRUE(video_frame_factory.get()); |
| 306 CreateFrameAndMemsetPlane(video_frame_factory.get()); | 306 CreateFrameAndMemsetPlane(video_frame_factory.get()); |
| 307 encoder_.reset(); | 307 encoder_.reset(); |
| 308 message_loop_.RunUntilIdle(); | 308 message_loop_.RunUntilIdle(); |
| 309 CreateFrameAndMemsetPlane(video_frame_factory.get()); | 309 CreateFrameAndMemsetPlane(video_frame_factory.get()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace cast | 312 } // namespace cast |
| 313 } // namespace media | 313 } // namespace media |
| OLD | NEW |