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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 EXPECT_EQ(0, transport_.number_of_rtp_packets()); | 556 EXPECT_EQ(0, transport_.number_of_rtp_packets()); |
557 } | 557 } |
558 | 558 |
559 TEST_F(VideoSenderTest, CheckVideoFrameFactoryIsNull) { | 559 TEST_F(VideoSenderTest, CheckVideoFrameFactoryIsNull) { |
560 InitEncoder(false, true); | 560 InitEncoder(false, true); |
561 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); | 561 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); |
562 | 562 |
563 EXPECT_EQ(nullptr, video_sender_->CreateVideoFrameFactory().get()); | 563 EXPECT_EQ(nullptr, video_sender_->CreateVideoFrameFactory().get()); |
564 } | 564 } |
565 | 565 |
| 566 TEST_F(VideoSenderTest, PopulatesStressLevelInFrameMetadata) { |
| 567 InitEncoder(false, true); |
| 568 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); |
| 569 |
| 570 for (int i = 0; i < 3; ++i) { |
| 571 scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); |
| 572 ASSERT_FALSE(video_frame->metadata()->HasKey( |
| 573 media::VideoFrameMetadata::STRESS_LEVEL)); |
| 574 |
| 575 const base::TimeTicks reference_time = testing_clock_->NowTicks(); |
| 576 video_sender_->InsertRawVideoFrame(video_frame, reference_time); |
| 577 |
| 578 // Run encode tasks. VideoSender::OnEncodedVideoFrame() will be called once |
| 579 // encoding of the frame is complete, and this is when the STRESS_LEVEL |
| 580 // metadata is populated. |
| 581 RunTasks(33); |
| 582 |
| 583 // The first frame will be a key frame, so no stress level will be reported. |
| 584 // The second and third frames should have non-negative values. We don't |
| 585 // check for specific values because they are dependent on real-world CPU |
| 586 // encode time. |
| 587 if (i == 0) { |
| 588 EXPECT_FALSE(video_frame->metadata()->HasKey( |
| 589 media::VideoFrameMetadata::STRESS_LEVEL)); |
| 590 } else { |
| 591 double stress_level = -1.0; |
| 592 EXPECT_TRUE(video_frame->metadata()->GetDouble( |
| 593 media::VideoFrameMetadata::STRESS_LEVEL, &stress_level)); |
| 594 EXPECT_LE(0.0, stress_level); |
| 595 DVLOG(1) << "Stress level computed by VideoSender is: " << stress_level; |
| 596 } |
| 597 } |
| 598 } |
| 599 |
566 } // namespace cast | 600 } // namespace cast |
567 } // namespace media | 601 } // namespace media |
OLD | NEW |