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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, | 117 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, |
118 CastTransportSender* const transport_sender) | 118 CastTransportSender* const transport_sender) |
119 : VideoSender(cast_environment, | 119 : VideoSender(cast_environment, |
120 video_config, | 120 video_config, |
121 status_change_cb, | 121 status_change_cb, |
122 create_vea_cb, | 122 create_vea_cb, |
123 create_video_encode_mem_cb, | 123 create_video_encode_mem_cb, |
124 transport_sender, | 124 transport_sender, |
125 base::Bind(&IgnorePlayoutDelayChanges)) {} | 125 base::Bind(&IgnorePlayoutDelayChanges)) {} |
126 using VideoSender::OnReceivedCastFeedback; | 126 using VideoSender::OnReceivedCastFeedback; |
| 127 using VideoSender::OnReceivedPli; |
127 }; | 128 }; |
128 | 129 |
129 class TransportClient : public CastTransportSender::Client { | 130 class TransportClient : public CastTransportSender::Client { |
130 public: | 131 public: |
131 TransportClient() {} | 132 TransportClient() {} |
132 | 133 |
133 void OnStatusChanged(CastTransportStatus status) final { | 134 void OnStatusChanged(CastTransportStatus status) final { |
134 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); | 135 EXPECT_EQ(TRANSPORT_VIDEO_INITIALIZED, status); |
135 }; | 136 }; |
136 void OnLoggingEventsReceived( | 137 void OnLoggingEventsReceived( |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 double utilization = -1.0; | 596 double utilization = -1.0; |
596 EXPECT_TRUE(video_frame->metadata()->GetDouble( | 597 EXPECT_TRUE(video_frame->metadata()->GetDouble( |
597 media::VideoFrameMetadata::RESOURCE_UTILIZATION, &utilization)); | 598 media::VideoFrameMetadata::RESOURCE_UTILIZATION, &utilization)); |
598 EXPECT_LE(0.0, utilization); | 599 EXPECT_LE(0.0, utilization); |
599 if (i == 0) | 600 if (i == 0) |
600 EXPECT_GE(1.0, utilization); // Key frames never exceed 1.0. | 601 EXPECT_GE(1.0, utilization); // Key frames never exceed 1.0. |
601 DVLOG(1) << "Utilization computed by VideoSender is: " << utilization; | 602 DVLOG(1) << "Utilization computed by VideoSender is: " << utilization; |
602 } | 603 } |
603 } | 604 } |
604 | 605 |
| 606 TEST_F(VideoSenderTest, CancelSendingOnReceivingPli) { |
| 607 InitEncoder(false, true); |
| 608 ASSERT_EQ(STATUS_INITIALIZED, operational_status_); |
| 609 |
| 610 // Send a frame and ACK it. |
| 611 scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame(); |
| 612 video_sender_->InsertRawVideoFrame(video_frame, testing_clock_->NowTicks()); |
| 613 RunTasks(33); |
| 614 |
| 615 RtcpCastMessage cast_feedback(1); |
| 616 cast_feedback.media_ssrc = 2; |
| 617 cast_feedback.ack_frame_id = 0; |
| 618 video_sender_->OnReceivedCastFeedback(cast_feedback); |
| 619 EXPECT_EQ(1, transport_->number_of_rtp_packets()); |
| 620 |
| 621 transport_->SetPause(true); |
| 622 // Send three more frames. |
| 623 for (int i = 0; i < 3; i++) { |
| 624 video_frame = GetNewVideoFrame(); |
| 625 video_sender_->InsertRawVideoFrame(video_frame, testing_clock_->NowTicks()); |
| 626 RunTasks(33); |
| 627 } |
| 628 |
| 629 // Frames should be in buffer, waiting. |
| 630 // Received PLI from receiver. |
| 631 video_sender_->OnReceivedPli(); |
| 632 video_frame = GetNewVideoFrame(); |
| 633 video_sender_->InsertRawVideoFrame( |
| 634 video_frame, |
| 635 testing_clock_->NowTicks() + base::TimeDelta::FromMilliseconds(500)); |
| 636 RunTasks(33); |
| 637 transport_->SetPause(false); |
| 638 RunTasks(33); |
| 639 EXPECT_EQ(2, transport_->number_of_rtp_packets()); |
| 640 } |
| 641 |
605 } // namespace cast | 642 } // namespace cast |
606 } // namespace media | 643 } // namespace media |
OLD | NEW |