| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
| 10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int num_called_; | 53 int num_called_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(TestVideoReceiverCallback); | 55 DISALLOW_COPY_AND_ASSIGN(TestVideoReceiverCallback); |
| 56 }; | 56 }; |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 class PeerVideoReceiver : public VideoReceiver { | 59 class PeerVideoReceiver : public VideoReceiver { |
| 60 public: | 60 public: |
| 61 PeerVideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 61 PeerVideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
| 62 const VideoReceiverConfig& video_config, | 62 const VideoReceiverConfig& video_config, |
| 63 transport::PacedPacketSender* const packet_sender) | 63 transport::PacedPacketSender* const packet_sender, |
| 64 : VideoReceiver(cast_environment, video_config, packet_sender) {} | 64 const SetTargetDelayCallback& target_delay_cb) |
| 65 : VideoReceiver(cast_environment, |
| 66 video_config, |
| 67 packet_sender, |
| 68 target_delay_cb) {} |
| 65 using VideoReceiver::IncomingParsedRtpPacket; | 69 using VideoReceiver::IncomingParsedRtpPacket; |
| 66 }; | 70 }; |
| 67 | 71 |
| 68 class VideoReceiverTest : public ::testing::Test { | 72 class VideoReceiverTest : public ::testing::Test { |
| 69 protected: | 73 protected: |
| 70 VideoReceiverTest() { | 74 VideoReceiverTest() { |
| 71 // Configure to use vp8 software implementation. | 75 // Configure to use vp8 software implementation. |
| 72 config_.codec = transport::kVp8; | 76 config_.codec = transport::kVp8; |
| 73 config_.use_external_decoder = false; | 77 config_.use_external_decoder = false; |
| 74 testing_clock_ = new base::SimpleTestTickClock(); | 78 testing_clock_ = new base::SimpleTestTickClock(); |
| 75 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); | 79 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); |
| 76 cast_environment_ = | 80 cast_environment_ = |
| 77 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), | 81 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
| 78 task_runner_, | 82 task_runner_, |
| 79 task_runner_, | 83 task_runner_, |
| 80 task_runner_, | 84 task_runner_, |
| 81 task_runner_, | 85 task_runner_, |
| 82 task_runner_, | 86 task_runner_, |
| 83 task_runner_, | 87 task_runner_, |
| 84 GetLoggingConfigWithRawEventsAndStatsEnabled()); | 88 GetLoggingConfigWithRawEventsAndStatsEnabled()); |
| 85 receiver_.reset( | 89 receiver_.reset(new PeerVideoReceiver( |
| 86 new PeerVideoReceiver(cast_environment_, config_, &mock_transport_)); | 90 cast_environment_, config_, &mock_transport_, target_delay_cb_)); |
| 87 testing_clock_->Advance( | 91 testing_clock_->Advance( |
| 88 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 92 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
| 89 video_receiver_callback_ = new TestVideoReceiverCallback(); | 93 video_receiver_callback_ = new TestVideoReceiverCallback(); |
| 90 | 94 |
| 91 payload_.assign(kPacketSize, 0); | 95 payload_.assign(kPacketSize, 0); |
| 92 | 96 |
| 93 // Always start with a key frame. | 97 // Always start with a key frame. |
| 94 rtp_header_.is_key_frame = true; | 98 rtp_header_.is_key_frame = true; |
| 95 rtp_header_.frame_id = 1234; | 99 rtp_header_.frame_id = 1234; |
| 96 rtp_header_.packet_id = 0; | 100 rtp_header_.packet_id = 0; |
| 97 rtp_header_.max_packet_id = 0; | 101 rtp_header_.max_packet_id = 0; |
| 98 rtp_header_.is_reference = false; | 102 rtp_header_.is_reference = false; |
| 99 rtp_header_.reference_frame_id = 0; | 103 rtp_header_.reference_frame_id = 0; |
| 100 rtp_header_.webrtc.header.timestamp = 9000; | 104 rtp_header_.webrtc.header.timestamp = 9000; |
| 101 } | 105 } |
| 102 | 106 |
| 103 virtual ~VideoReceiverTest() {} | 107 virtual ~VideoReceiverTest() {} |
| 104 | 108 |
| 105 transport::MockPacedPacketSender mock_transport_; | 109 transport::MockPacedPacketSender mock_transport_; |
| 106 VideoReceiverConfig config_; | 110 VideoReceiverConfig config_; |
| 107 scoped_ptr<PeerVideoReceiver> receiver_; | 111 scoped_ptr<PeerVideoReceiver> receiver_; |
| 108 std::vector<uint8> payload_; | 112 std::vector<uint8> payload_; |
| 109 RtpCastHeader rtp_header_; | 113 RtpCastHeader rtp_header_; |
| 110 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. | 114 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
| 111 | 115 |
| 112 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 116 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 113 scoped_refptr<CastEnvironment> cast_environment_; | 117 scoped_refptr<CastEnvironment> cast_environment_; |
| 114 scoped_refptr<TestVideoReceiverCallback> video_receiver_callback_; | 118 scoped_refptr<TestVideoReceiverCallback> video_receiver_callback_; |
| 119 SetTargetDelayCallback target_delay_cb_; |
| 115 | 120 |
| 116 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); | 121 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 TEST_F(VideoReceiverTest, GetOnePacketEncodedframe) { | 124 TEST_F(VideoReceiverTest, GetOnePacketEncodedframe) { |
| 120 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) | 125 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) |
| 121 .WillRepeatedly(testing::Return(true)); | 126 .WillRepeatedly(testing::Return(true)); |
| 122 receiver_->IncomingParsedRtpPacket( | 127 receiver_->IncomingParsedRtpPacket( |
| 123 payload_.data(), payload_.size(), rtp_header_); | 128 payload_.data(), payload_.size(), rtp_header_); |
| 124 | 129 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 &TestVideoReceiverCallback::DecodeComplete, video_receiver_callback_); | 181 &TestVideoReceiverCallback::DecodeComplete, video_receiver_callback_); |
| 177 receiver_->GetRawVideoFrame(frame_decoded_callback); | 182 receiver_->GetRawVideoFrame(frame_decoded_callback); |
| 178 task_runner_->RunTasks(); | 183 task_runner_->RunTasks(); |
| 179 EXPECT_EQ(video_receiver_callback_->number_times_called(), 0); | 184 EXPECT_EQ(video_receiver_callback_->number_times_called(), 0); |
| 180 } | 185 } |
| 181 | 186 |
| 182 // TODO(pwestin): add encoded frames. | 187 // TODO(pwestin): add encoded frames. |
| 183 | 188 |
| 184 } // namespace cast | 189 } // namespace cast |
| 185 } // namespace media | 190 } // namespace media |
| OLD | NEW |