OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 std::vector<VideoReceiveStream::Config>* receive_configs, | 116 std::vector<VideoReceiveStream::Config>* receive_configs, |
117 VideoEncoderConfig* encoder_config) override { | 117 VideoEncoderConfig* encoder_config) override { |
118 send_config->rtp.c_name = kCName; | 118 send_config->rtp.c_name = kCName; |
119 } | 119 } |
120 | 120 |
121 void PerformTest() override { | 121 void PerformTest() override { |
122 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP with CNAME."; | 122 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP with CNAME."; |
123 } | 123 } |
124 } test; | 124 } test; |
125 | 125 |
126 RunBaseTest(&test, FakeNetworkPipe::Config()); | 126 RunBaseTest(&test); |
127 } | 127 } |
128 | 128 |
129 TEST_F(VideoSendStreamTest, SupportsAbsoluteSendTime) { | 129 TEST_F(VideoSendStreamTest, SupportsAbsoluteSendTime) { |
130 class AbsoluteSendTimeObserver : public test::SendTest { | 130 class AbsoluteSendTimeObserver : public test::SendTest { |
131 public: | 131 public: |
132 AbsoluteSendTimeObserver() : SendTest(kDefaultTimeoutMs) { | 132 AbsoluteSendTimeObserver() : SendTest(kDefaultTimeoutMs) { |
133 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( | 133 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( |
134 kRtpExtensionAbsoluteSendTime, test::kAbsSendTimeExtensionId)); | 134 kRtpExtensionAbsoluteSendTime, test::kAbsSendTimeExtensionId)); |
135 } | 135 } |
136 | 136 |
(...skipping 17 matching lines...) Expand all Loading... |
154 send_config->rtp.extensions.clear(); | 154 send_config->rtp.extensions.clear(); |
155 send_config->rtp.extensions.push_back(RtpExtension( | 155 send_config->rtp.extensions.push_back(RtpExtension( |
156 RtpExtension::kAbsSendTime, test::kAbsSendTimeExtensionId)); | 156 RtpExtension::kAbsSendTime, test::kAbsSendTimeExtensionId)); |
157 } | 157 } |
158 | 158 |
159 void PerformTest() override { | 159 void PerformTest() override { |
160 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet."; | 160 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet."; |
161 } | 161 } |
162 } test; | 162 } test; |
163 | 163 |
164 RunBaseTest(&test, FakeNetworkPipe::Config()); | 164 RunBaseTest(&test); |
165 } | 165 } |
166 | 166 |
167 TEST_F(VideoSendStreamTest, SupportsTransmissionTimeOffset) { | 167 TEST_F(VideoSendStreamTest, SupportsTransmissionTimeOffset) { |
168 static const int kEncodeDelayMs = 5; | 168 static const int kEncodeDelayMs = 5; |
169 class TransmissionTimeOffsetObserver : public test::SendTest { | 169 class TransmissionTimeOffsetObserver : public test::SendTest { |
170 public: | 170 public: |
171 TransmissionTimeOffsetObserver() | 171 TransmissionTimeOffsetObserver() |
172 : SendTest(kDefaultTimeoutMs), | 172 : SendTest(kDefaultTimeoutMs), |
173 encoder_(Clock::GetRealTimeClock(), kEncodeDelayMs) { | 173 encoder_(Clock::GetRealTimeClock(), kEncodeDelayMs) { |
174 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( | 174 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( |
(...skipping 24 matching lines...) Expand all Loading... |
199 RtpExtension(RtpExtension::kTOffset, test::kTOffsetExtensionId)); | 199 RtpExtension(RtpExtension::kTOffset, test::kTOffsetExtensionId)); |
200 } | 200 } |
201 | 201 |
202 void PerformTest() override { | 202 void PerformTest() override { |
203 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; | 203 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; |
204 } | 204 } |
205 | 205 |
206 test::DelayedEncoder encoder_; | 206 test::DelayedEncoder encoder_; |
207 } test; | 207 } test; |
208 | 208 |
209 RunBaseTest(&test, FakeNetworkPipe::Config()); | 209 RunBaseTest(&test); |
210 } | 210 } |
211 | 211 |
212 TEST_F(VideoSendStreamTest, SupportsTransportWideSequenceNumbers) { | 212 TEST_F(VideoSendStreamTest, SupportsTransportWideSequenceNumbers) { |
213 static const uint8_t kExtensionId = 13; | 213 static const uint8_t kExtensionId = 13; |
214 class TransportWideSequenceNumberObserver : public test::SendTest { | 214 class TransportWideSequenceNumberObserver : public test::SendTest { |
215 public: | 215 public: |
216 TransportWideSequenceNumberObserver() | 216 TransportWideSequenceNumberObserver() |
217 : SendTest(kDefaultTimeoutMs), encoder_(Clock::GetRealTimeClock()) { | 217 : SendTest(kDefaultTimeoutMs), encoder_(Clock::GetRealTimeClock()) { |
218 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( | 218 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( |
219 kRtpExtensionTransportSequenceNumber, kExtensionId)); | 219 kRtpExtensionTransportSequenceNumber, kExtensionId)); |
(...skipping 23 matching lines...) Expand all Loading... |
243 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId)); | 243 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId)); |
244 } | 244 } |
245 | 245 |
246 void PerformTest() override { | 246 void PerformTest() override { |
247 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; | 247 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; |
248 } | 248 } |
249 | 249 |
250 test::FakeEncoder encoder_; | 250 test::FakeEncoder encoder_; |
251 } test; | 251 } test; |
252 | 252 |
253 RunBaseTest(&test, FakeNetworkPipe::Config()); | 253 RunBaseTest(&test); |
254 } | 254 } |
255 | 255 |
256 class FakeReceiveStatistics : public NullReceiveStatistics { | 256 class FakeReceiveStatistics : public NullReceiveStatistics { |
257 public: | 257 public: |
258 FakeReceiveStatistics(uint32_t send_ssrc, | 258 FakeReceiveStatistics(uint32_t send_ssrc, |
259 uint32_t last_sequence_number, | 259 uint32_t last_sequence_number, |
260 uint32_t cumulative_lost, | 260 uint32_t cumulative_lost, |
261 uint8_t fraction_lost) | 261 uint8_t fraction_lost) |
262 : lossy_stats_(new LossyStatistician(last_sequence_number, | 262 : lossy_stats_(new LossyStatistician(last_sequence_number, |
263 cumulative_lost, | 263 cumulative_lost, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 int send_count_; | 416 int send_count_; |
417 bool received_media_; | 417 bool received_media_; |
418 bool received_fec_; | 418 bool received_fec_; |
419 bool header_extensions_enabled_; | 419 bool header_extensions_enabled_; |
420 RTPHeader prev_header_; | 420 RTPHeader prev_header_; |
421 }; | 421 }; |
422 | 422 |
423 TEST_F(VideoSendStreamTest, SupportsFecWithExtensions) { | 423 TEST_F(VideoSendStreamTest, SupportsFecWithExtensions) { |
424 FecObserver test(true); | 424 FecObserver test(true); |
425 | 425 |
426 RunBaseTest(&test, FakeNetworkPipe::Config()); | 426 RunBaseTest(&test); |
427 } | 427 } |
428 | 428 |
429 TEST_F(VideoSendStreamTest, SupportsFecWithoutExtensions) { | 429 TEST_F(VideoSendStreamTest, SupportsFecWithoutExtensions) { |
430 FecObserver test(false); | 430 FecObserver test(false); |
431 | 431 |
432 RunBaseTest(&test, FakeNetworkPipe::Config()); | 432 RunBaseTest(&test); |
433 } | 433 } |
434 | 434 |
435 void VideoSendStreamTest::TestNackRetransmission( | 435 void VideoSendStreamTest::TestNackRetransmission( |
436 uint32_t retransmit_ssrc, | 436 uint32_t retransmit_ssrc, |
437 uint8_t retransmit_payload_type) { | 437 uint8_t retransmit_payload_type) { |
438 class NackObserver : public test::SendTest { | 438 class NackObserver : public test::SendTest { |
439 public: | 439 public: |
440 explicit NackObserver(uint32_t retransmit_ssrc, | 440 explicit NackObserver(uint32_t retransmit_ssrc, |
441 uint8_t retransmit_payload_type) | 441 uint8_t retransmit_payload_type) |
442 : SendTest(kDefaultTimeoutMs), | 442 : SendTest(kDefaultTimeoutMs), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 EXPECT_TRUE(Wait()) << "Timed out while waiting for NACK retransmission."; | 505 EXPECT_TRUE(Wait()) << "Timed out while waiting for NACK retransmission."; |
506 } | 506 } |
507 | 507 |
508 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 508 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; |
509 int send_count_; | 509 int send_count_; |
510 uint32_t retransmit_ssrc_; | 510 uint32_t retransmit_ssrc_; |
511 uint8_t retransmit_payload_type_; | 511 uint8_t retransmit_payload_type_; |
512 int nacked_sequence_number_; | 512 int nacked_sequence_number_; |
513 } test(retransmit_ssrc, retransmit_payload_type); | 513 } test(retransmit_ssrc, retransmit_payload_type); |
514 | 514 |
515 RunBaseTest(&test, FakeNetworkPipe::Config()); | 515 RunBaseTest(&test); |
516 } | 516 } |
517 | 517 |
518 TEST_F(VideoSendStreamTest, RetransmitsNack) { | 518 TEST_F(VideoSendStreamTest, RetransmitsNack) { |
519 // Normal NACKs should use the send SSRC. | 519 // Normal NACKs should use the send SSRC. |
520 TestNackRetransmission(kVideoSendSsrcs[0], kFakeVideoSendPayloadType); | 520 TestNackRetransmission(kVideoSendSsrcs[0], kFakeVideoSendPayloadType); |
521 } | 521 } |
522 | 522 |
523 TEST_F(VideoSendStreamTest, RetransmitsNackOverRtx) { | 523 TEST_F(VideoSendStreamTest, RetransmitsNackOverRtx) { |
524 // NACKs over RTX should use a separate SSRC. | 524 // NACKs over RTX should use a separate SSRC. |
525 TestNackRetransmission(kSendRtxSsrcs[0], kSendRtxPayloadType); | 525 TestNackRetransmission(kSendRtxSsrcs[0], kSendRtxPayloadType); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 716 |
717 size_t current_size_rtp_; | 717 size_t current_size_rtp_; |
718 Atomic32 current_size_frame_; | 718 Atomic32 current_size_frame_; |
719 }; | 719 }; |
720 | 720 |
721 // Don't auto increment if FEC is used; continue sending frame size until | 721 // Don't auto increment if FEC is used; continue sending frame size until |
722 // a FEC packet has been received. | 722 // a FEC packet has been received. |
723 FrameFragmentationTest test( | 723 FrameFragmentationTest test( |
724 kMaxPacketSize, start, stop, format == kGeneric, with_fec); | 724 kMaxPacketSize, start, stop, format == kGeneric, with_fec); |
725 | 725 |
726 RunBaseTest(&test, FakeNetworkPipe::Config()); | 726 RunBaseTest(&test); |
727 } | 727 } |
728 | 728 |
729 // TODO(sprang): Is there any way of speeding up these tests? | 729 // TODO(sprang): Is there any way of speeding up these tests? |
730 TEST_F(VideoSendStreamTest, FragmentsGenericAccordingToMaxPacketSize) { | 730 TEST_F(VideoSendStreamTest, FragmentsGenericAccordingToMaxPacketSize) { |
731 TestPacketFragmentationSize(kGeneric, false); | 731 TestPacketFragmentationSize(kGeneric, false); |
732 } | 732 } |
733 | 733 |
734 TEST_F(VideoSendStreamTest, FragmentsGenericAccordingToMaxPacketSizeWithFec) { | 734 TEST_F(VideoSendStreamTest, FragmentsGenericAccordingToMaxPacketSizeWithFec) { |
735 TestPacketFragmentationSize(kGeneric, true); | 735 TestPacketFragmentationSize(kGeneric, true); |
736 } | 736 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 886 |
887 rtc::CriticalSection crit_; | 887 rtc::CriticalSection crit_; |
888 TestState test_state_ GUARDED_BY(crit_); | 888 TestState test_state_ GUARDED_BY(crit_); |
889 int rtp_count_ GUARDED_BY(crit_); | 889 int rtp_count_ GUARDED_BY(crit_); |
890 int last_sequence_number_ GUARDED_BY(crit_); | 890 int last_sequence_number_ GUARDED_BY(crit_); |
891 int suspended_frame_count_ GUARDED_BY(crit_); | 891 int suspended_frame_count_ GUARDED_BY(crit_); |
892 int low_remb_bps_ GUARDED_BY(crit_); | 892 int low_remb_bps_ GUARDED_BY(crit_); |
893 int high_remb_bps_ GUARDED_BY(crit_); | 893 int high_remb_bps_ GUARDED_BY(crit_); |
894 } test; | 894 } test; |
895 | 895 |
896 RunBaseTest(&test, FakeNetworkPipe::Config()); | 896 RunBaseTest(&test); |
897 } | 897 } |
898 | 898 |
899 TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { | 899 TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { |
900 class NoPaddingWhenVideoIsMuted : public test::SendTest { | 900 class NoPaddingWhenVideoIsMuted : public test::SendTest { |
901 public: | 901 public: |
902 NoPaddingWhenVideoIsMuted() | 902 NoPaddingWhenVideoIsMuted() |
903 : SendTest(kDefaultTimeoutMs), | 903 : SendTest(kDefaultTimeoutMs), |
904 clock_(Clock::GetRealTimeClock()), | 904 clock_(Clock::GetRealTimeClock()), |
905 last_packet_time_ms_(-1), | 905 last_packet_time_ms_(-1), |
906 capturer_(nullptr) { | 906 capturer_(nullptr) { |
(...skipping 21 matching lines...) Expand all Loading... |
928 | 928 |
929 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); | 929 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); |
930 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); | 930 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); |
931 | 931 |
932 RTCPSender::FeedbackState feedback_state; | 932 RTCPSender::FeedbackState feedback_state; |
933 | 933 |
934 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); | 934 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); |
935 return SEND_PACKET; | 935 return SEND_PACKET; |
936 } | 936 } |
937 | 937 |
938 void OnTransportsCreated( | 938 test::PacketTransport* CreateReceiveTransport() override { |
939 test::PacketTransport* send_transport, | 939 test::PacketTransport* transport = new test::PacketTransport( |
940 test::PacketTransport* receive_transport) override { | 940 nullptr, this, test::PacketTransport::kReceiver, |
941 transport_adapter_.reset( | 941 FakeNetworkPipe::Config()); |
942 new internal::TransportAdapter(receive_transport)); | 942 transport_adapter_.reset(new internal::TransportAdapter(transport)); |
943 transport_adapter_->Enable(); | 943 transport_adapter_->Enable(); |
| 944 return transport; |
944 } | 945 } |
945 | 946 |
946 size_t GetNumVideoStreams() const override { return 3; } | 947 size_t GetNumVideoStreams() const override { return 3; } |
947 | 948 |
948 virtual void OnFrameGeneratorCapturerCreated( | 949 virtual void OnFrameGeneratorCapturerCreated( |
949 test::FrameGeneratorCapturer* frame_generator_capturer) { | 950 test::FrameGeneratorCapturer* frame_generator_capturer) { |
950 rtc::CritScope lock(&crit_); | 951 rtc::CritScope lock(&crit_); |
951 capturer_ = frame_generator_capturer; | 952 capturer_ = frame_generator_capturer; |
952 } | 953 } |
953 | 954 |
954 void PerformTest() override { | 955 void PerformTest() override { |
955 EXPECT_TRUE(Wait()) | 956 EXPECT_TRUE(Wait()) |
956 << "Timed out while waiting for RTP packets to stop being sent."; | 957 << "Timed out while waiting for RTP packets to stop being sent."; |
957 } | 958 } |
958 | 959 |
959 Clock* const clock_; | 960 Clock* const clock_; |
960 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 961 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; |
961 rtc::CriticalSection crit_; | 962 rtc::CriticalSection crit_; |
962 int64_t last_packet_time_ms_ GUARDED_BY(crit_); | 963 int64_t last_packet_time_ms_ GUARDED_BY(crit_); |
963 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); | 964 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); |
964 } test; | 965 } test; |
965 | 966 |
966 RunBaseTest(&test, FakeNetworkPipe::Config()); | 967 RunBaseTest(&test); |
967 } | 968 } |
968 | 969 |
969 // This test first observes "high" bitrate use at which point it sends a REMB to | 970 // This test first observes "high" bitrate use at which point it sends a REMB to |
970 // indicate that it should be lowered significantly. The test then observes that | 971 // indicate that it should be lowered significantly. The test then observes that |
971 // the bitrate observed is sinking well below the min-transmit-bitrate threshold | 972 // the bitrate observed is sinking well below the min-transmit-bitrate threshold |
972 // to verify that the min-transmit bitrate respects incoming REMB. | 973 // to verify that the min-transmit bitrate respects incoming REMB. |
973 // | 974 // |
974 // Note that the test starts at "high" bitrate and does not ramp up to "higher" | 975 // Note that the test starts at "high" bitrate and does not ramp up to "higher" |
975 // bitrate since no receiver block or remb is sent in the initial phase. | 976 // bitrate since no receiver block or remb is sent in the initial phase. |
976 TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { | 977 TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 EXPECT_TRUE(Wait()) | 1045 EXPECT_TRUE(Wait()) |
1045 << "Timeout while waiting for low bitrate stats after REMB."; | 1046 << "Timeout while waiting for low bitrate stats after REMB."; |
1046 } | 1047 } |
1047 | 1048 |
1048 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; | 1049 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; |
1049 rtc::scoped_ptr<internal::TransportAdapter> feedback_transport_; | 1050 rtc::scoped_ptr<internal::TransportAdapter> feedback_transport_; |
1050 VideoSendStream* stream_; | 1051 VideoSendStream* stream_; |
1051 bool bitrate_capped_; | 1052 bool bitrate_capped_; |
1052 } test; | 1053 } test; |
1053 | 1054 |
1054 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1055 RunBaseTest(&test); |
1055 } | 1056 } |
1056 | 1057 |
1057 TEST_F(VideoSendStreamTest, CanReconfigureToUseStartBitrateAbovePreviousMax) { | 1058 TEST_F(VideoSendStreamTest, CanReconfigureToUseStartBitrateAbovePreviousMax) { |
1058 class StartBitrateObserver : public test::FakeEncoder { | 1059 class StartBitrateObserver : public test::FakeEncoder { |
1059 public: | 1060 public: |
1060 StartBitrateObserver() | 1061 StartBitrateObserver() |
1061 : FakeEncoder(Clock::GetRealTimeClock()), start_bitrate_kbps_(0) {} | 1062 : FakeEncoder(Clock::GetRealTimeClock()), start_bitrate_kbps_(0) {} |
1062 int32_t InitEncode(const VideoCodec* config, | 1063 int32_t InitEncode(const VideoCodec* config, |
1063 int32_t number_of_cores, | 1064 int32_t number_of_cores, |
1064 size_t max_payload_size) override { | 1065 size_t max_payload_size) override { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 | 1354 |
1354 rtc::CriticalSection crit_; | 1355 rtc::CriticalSection crit_; |
1355 VideoSendStream* stream_; | 1356 VideoSendStream* stream_; |
1356 bool initialized_ GUARDED_BY(crit_); | 1357 bool initialized_ GUARDED_BY(crit_); |
1357 bool callback_registered_ GUARDED_BY(crit_); | 1358 bool callback_registered_ GUARDED_BY(crit_); |
1358 size_t num_releases_ GUARDED_BY(crit_); | 1359 size_t num_releases_ GUARDED_BY(crit_); |
1359 bool released_ GUARDED_BY(crit_); | 1360 bool released_ GUARDED_BY(crit_); |
1360 VideoEncoderConfig encoder_config_; | 1361 VideoEncoderConfig encoder_config_; |
1361 } test_encoder; | 1362 } test_encoder; |
1362 | 1363 |
1363 RunBaseTest(&test_encoder, FakeNetworkPipe::Config()); | 1364 RunBaseTest(&test_encoder); |
1364 | 1365 |
1365 EXPECT_TRUE(test_encoder.IsReleased()); | 1366 EXPECT_TRUE(test_encoder.IsReleased()); |
1366 EXPECT_EQ(1u, test_encoder.num_releases()); | 1367 EXPECT_EQ(1u, test_encoder.num_releases()); |
1367 } | 1368 } |
1368 | 1369 |
1369 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) { | 1370 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) { |
1370 class VideoCodecConfigObserver : public test::SendTest, | 1371 class VideoCodecConfigObserver : public test::SendTest, |
1371 public test::FakeEncoder { | 1372 public test::FakeEncoder { |
1372 public: | 1373 public: |
1373 VideoCodecConfigObserver() | 1374 VideoCodecConfigObserver() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 EXPECT_EQ(2u, num_initializations_) | 1413 EXPECT_EQ(2u, num_initializations_) |
1413 << "ReconfigureVideoEncoder did not reinitialize the encoder with " | 1414 << "ReconfigureVideoEncoder did not reinitialize the encoder with " |
1414 "new encoder settings."; | 1415 "new encoder settings."; |
1415 } | 1416 } |
1416 | 1417 |
1417 size_t num_initializations_; | 1418 size_t num_initializations_; |
1418 VideoSendStream* stream_; | 1419 VideoSendStream* stream_; |
1419 VideoEncoderConfig encoder_config_; | 1420 VideoEncoderConfig encoder_config_; |
1420 } test; | 1421 } test; |
1421 | 1422 |
1422 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1423 RunBaseTest(&test); |
1423 } | 1424 } |
1424 | 1425 |
1425 static const size_t kVideoCodecConfigObserverNumberOfTemporalLayers = 4; | 1426 static const size_t kVideoCodecConfigObserverNumberOfTemporalLayers = 4; |
1426 template <typename T> | 1427 template <typename T> |
1427 class VideoCodecConfigObserver : public test::SendTest, | 1428 class VideoCodecConfigObserver : public test::SendTest, |
1428 public test::FakeEncoder { | 1429 public test::FakeEncoder { |
1429 public: | 1430 public: |
1430 VideoCodecConfigObserver(VideoCodecType video_codec_type, | 1431 VideoCodecConfigObserver(VideoCodecType video_codec_type, |
1431 const char* codec_name) | 1432 const char* codec_name) |
1432 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), | 1433 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 // reconfiguring the encoder and not match the set config. | 1541 // reconfiguring the encoder and not match the set config. |
1541 VideoCodecVP9 encoder_settings = encoder_settings_; | 1542 VideoCodecVP9 encoder_settings = encoder_settings_; |
1542 encoder_settings.numberOfTemporalLayers = | 1543 encoder_settings.numberOfTemporalLayers = |
1543 kVideoCodecConfigObserverNumberOfTemporalLayers; | 1544 kVideoCodecConfigObserverNumberOfTemporalLayers; |
1544 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP9, &encoder_settings, | 1545 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP9, &encoder_settings, |
1545 sizeof(encoder_settings_))); | 1546 sizeof(encoder_settings_))); |
1546 } | 1547 } |
1547 | 1548 |
1548 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { | 1549 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { |
1549 VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8"); | 1550 VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8"); |
1550 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1551 RunBaseTest(&test); |
1551 } | 1552 } |
1552 | 1553 |
1553 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { | 1554 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { |
1554 VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9"); | 1555 VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9"); |
1555 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1556 RunBaseTest(&test); |
1556 } | 1557 } |
1557 | 1558 |
1558 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesH264Config) { | 1559 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesH264Config) { |
1559 VideoCodecConfigObserver<VideoCodecH264> test(kVideoCodecH264, "H264"); | 1560 VideoCodecConfigObserver<VideoCodecH264> test(kVideoCodecH264, "H264"); |
1560 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1561 RunBaseTest(&test); |
1561 } | 1562 } |
1562 | 1563 |
1563 TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) { | 1564 TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) { |
1564 class RtcpSenderReportTest : public test::SendTest { | 1565 class RtcpSenderReportTest : public test::SendTest { |
1565 public: | 1566 public: |
1566 RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs), | 1567 RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs), |
1567 rtp_packets_sent_(0), | 1568 rtp_packets_sent_(0), |
1568 media_bytes_sent_(0) {} | 1569 media_bytes_sent_(0) {} |
1569 | 1570 |
1570 private: | 1571 private: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 | 1603 |
1603 void PerformTest() override { | 1604 void PerformTest() override { |
1604 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP sender report."; | 1605 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP sender report."; |
1605 } | 1606 } |
1606 | 1607 |
1607 rtc::CriticalSection crit_; | 1608 rtc::CriticalSection crit_; |
1608 size_t rtp_packets_sent_ GUARDED_BY(&crit_); | 1609 size_t rtp_packets_sent_ GUARDED_BY(&crit_); |
1609 size_t media_bytes_sent_ GUARDED_BY(&crit_); | 1610 size_t media_bytes_sent_ GUARDED_BY(&crit_); |
1610 } test; | 1611 } test; |
1611 | 1612 |
1612 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1613 RunBaseTest(&test); |
1613 } | 1614 } |
1614 | 1615 |
1615 TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { | 1616 TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { |
1616 static const int kScreencastTargetBitrateKbps = 200; | 1617 static const int kScreencastTargetBitrateKbps = 200; |
1617 class ScreencastTargetBitrateTest : public test::SendTest, | 1618 class ScreencastTargetBitrateTest : public test::SendTest, |
1618 public test::FakeEncoder { | 1619 public test::FakeEncoder { |
1619 public: | 1620 public: |
1620 ScreencastTargetBitrateTest() | 1621 ScreencastTargetBitrateTest() |
1621 : SendTest(kDefaultTimeoutMs), | 1622 : SendTest(kDefaultTimeoutMs), |
1622 test::FakeEncoder(Clock::GetRealTimeClock()) {} | 1623 test::FakeEncoder(Clock::GetRealTimeClock()) {} |
(...skipping 20 matching lines...) Expand all Loading... |
1643 kScreencastTargetBitrateKbps * 1000); | 1644 kScreencastTargetBitrateKbps * 1000); |
1644 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; | 1645 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; |
1645 } | 1646 } |
1646 | 1647 |
1647 void PerformTest() override { | 1648 void PerformTest() override { |
1648 EXPECT_TRUE(Wait()) | 1649 EXPECT_TRUE(Wait()) |
1649 << "Timed out while waiting for the encoder to be initialized."; | 1650 << "Timed out while waiting for the encoder to be initialized."; |
1650 } | 1651 } |
1651 } test; | 1652 } test; |
1652 | 1653 |
1653 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1654 RunBaseTest(&test); |
1654 } | 1655 } |
1655 | 1656 |
1656 // Disabled on LinuxAsan: | 1657 // Disabled on LinuxAsan: |
1657 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5382 | 1658 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5382 |
1658 #if defined(ADDRESS_SANITIZER) && defined(WEBRTC_LINUX) | 1659 #if defined(ADDRESS_SANITIZER) && defined(WEBRTC_LINUX) |
1659 #define MAYBE_ReconfigureBitratesSetsEncoderBitratesCorrectly \ | 1660 #define MAYBE_ReconfigureBitratesSetsEncoderBitratesCorrectly \ |
1660 DISABLED_ReconfigureBitratesSetsEncoderBitratesCorrectly | 1661 DISABLED_ReconfigureBitratesSetsEncoderBitratesCorrectly |
1661 #else | 1662 #else |
1662 #define MAYBE_ReconfigureBitratesSetsEncoderBitratesCorrectly \ | 1663 #define MAYBE_ReconfigureBitratesSetsEncoderBitratesCorrectly \ |
1663 ReconfigureBitratesSetsEncoderBitratesCorrectly | 1664 ReconfigureBitratesSetsEncoderBitratesCorrectly |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 EXPECT_EQ(3, num_initializations_) | 1762 EXPECT_EQ(3, num_initializations_) |
1762 << "Encoder should have been reconfigured with the new value."; | 1763 << "Encoder should have been reconfigured with the new value."; |
1763 } | 1764 } |
1764 | 1765 |
1765 int num_initializations_; | 1766 int num_initializations_; |
1766 webrtc::Call* call_; | 1767 webrtc::Call* call_; |
1767 webrtc::VideoSendStream* send_stream_; | 1768 webrtc::VideoSendStream* send_stream_; |
1768 webrtc::VideoEncoderConfig encoder_config_; | 1769 webrtc::VideoEncoderConfig encoder_config_; |
1769 } test; | 1770 } test; |
1770 | 1771 |
1771 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1772 RunBaseTest(&test); |
1772 } | 1773 } |
1773 | 1774 |
1774 TEST_F(VideoSendStreamTest, ReportsSentResolution) { | 1775 TEST_F(VideoSendStreamTest, ReportsSentResolution) { |
1775 static const size_t kNumStreams = 3; | 1776 static const size_t kNumStreams = 3; |
1776 // Unusual resolutions to make sure that they are the ones being reported. | 1777 // Unusual resolutions to make sure that they are the ones being reported. |
1777 static const struct { | 1778 static const struct { |
1778 int width; | 1779 int width; |
1779 int height; | 1780 int height; |
1780 } kEncodedResolution[kNumStreams] = { | 1781 } kEncodedResolution[kNumStreams] = { |
1781 {241, 181}, {300, 121}, {121, 221}}; | 1782 {241, 181}, {300, 121}, {121, 221}}; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1842 |
1842 void OnVideoStreamsCreated( | 1843 void OnVideoStreamsCreated( |
1843 VideoSendStream* send_stream, | 1844 VideoSendStream* send_stream, |
1844 const std::vector<VideoReceiveStream*>& receive_streams) override { | 1845 const std::vector<VideoReceiveStream*>& receive_streams) override { |
1845 send_stream_ = send_stream; | 1846 send_stream_ = send_stream; |
1846 } | 1847 } |
1847 | 1848 |
1848 VideoSendStream* send_stream_; | 1849 VideoSendStream* send_stream_; |
1849 } test; | 1850 } test; |
1850 | 1851 |
1851 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1852 RunBaseTest(&test); |
1852 } | 1853 } |
1853 | 1854 |
1854 class Vp9HeaderObserver : public test::SendTest { | 1855 class Vp9HeaderObserver : public test::SendTest { |
1855 public: | 1856 public: |
1856 Vp9HeaderObserver() | 1857 Vp9HeaderObserver() |
1857 : SendTest(VideoSendStreamTest::kLongTimeoutMs), | 1858 : SendTest(VideoSendStreamTest::kLongTimeoutMs), |
1858 vp9_encoder_(VP9Encoder::Create()), | 1859 vp9_encoder_(VP9Encoder::Create()), |
1859 vp9_settings_(VideoEncoder::GetDefaultVp9Settings()), | 1860 vp9_settings_(VideoEncoder::GetDefaultVp9Settings()), |
1860 packets_sent_(0), | 1861 packets_sent_(0), |
1861 frames_sent_(0) {} | 1862 frames_sent_(0) {} |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 l_field_ ? num_temporal_layers_ : 0); | 2202 l_field_ ? num_temporal_layers_ : 0); |
2202 | 2203 |
2203 if (frames_sent_ > kNumFramesToSend) | 2204 if (frames_sent_ > kNumFramesToSend) |
2204 observation_complete_.Set(); | 2205 observation_complete_.Set(); |
2205 } | 2206 } |
2206 const uint8_t num_temporal_layers_; | 2207 const uint8_t num_temporal_layers_; |
2207 const uint8_t num_spatial_layers_; | 2208 const uint8_t num_spatial_layers_; |
2208 const bool l_field_; | 2209 const bool l_field_; |
2209 } test(num_temporal_layers, num_spatial_layers); | 2210 } test(num_temporal_layers, num_spatial_layers); |
2210 | 2211 |
2211 RunBaseTest(&test, FakeNetworkPipe::Config()); | 2212 RunBaseTest(&test); |
2212 } | 2213 } |
2213 | 2214 |
2214 #if !defined(MEMORY_SANITIZER) | 2215 #if !defined(MEMORY_SANITIZER) |
2215 // Fails under MemorySanitizer: | 2216 // Fails under MemorySanitizer: |
2216 // See https://code.google.com/p/webrtc/issues/detail?id=5402. | 2217 // See https://code.google.com/p/webrtc/issues/detail?id=5402. |
2217 TEST_F(VideoSendStreamTest, Vp9FlexModeRefCount) { | 2218 TEST_F(VideoSendStreamTest, Vp9FlexModeRefCount) { |
2218 class FlexibleMode : public Vp9HeaderObserver { | 2219 class FlexibleMode : public Vp9HeaderObserver { |
2219 void ModifyVideoConfigsHook( | 2220 void ModifyVideoConfigsHook( |
2220 VideoSendStream::Config* send_config, | 2221 VideoSendStream::Config* send_config, |
2221 std::vector<VideoReceiveStream::Config>* receive_configs, | 2222 std::vector<VideoReceiveStream::Config>* receive_configs, |
2222 VideoEncoderConfig* encoder_config) override { | 2223 VideoEncoderConfig* encoder_config) override { |
2223 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; | 2224 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; |
2224 vp9_settings_.flexibleMode = true; | 2225 vp9_settings_.flexibleMode = true; |
2225 vp9_settings_.numberOfTemporalLayers = 1; | 2226 vp9_settings_.numberOfTemporalLayers = 1; |
2226 vp9_settings_.numberOfSpatialLayers = 2; | 2227 vp9_settings_.numberOfSpatialLayers = 2; |
2227 } | 2228 } |
2228 | 2229 |
2229 void InspectHeader(const RTPVideoHeaderVP9& vp9_header) override { | 2230 void InspectHeader(const RTPVideoHeaderVP9& vp9_header) override { |
2230 EXPECT_TRUE(vp9_header.flexible_mode); | 2231 EXPECT_TRUE(vp9_header.flexible_mode); |
2231 EXPECT_EQ(kNoTl0PicIdx, vp9_header.tl0_pic_idx); | 2232 EXPECT_EQ(kNoTl0PicIdx, vp9_header.tl0_pic_idx); |
2232 if (vp9_header.inter_pic_predicted) { | 2233 if (vp9_header.inter_pic_predicted) { |
2233 EXPECT_GT(vp9_header.num_ref_pics, 0u); | 2234 EXPECT_GT(vp9_header.num_ref_pics, 0u); |
2234 observation_complete_.Set(); | 2235 observation_complete_.Set(); |
2235 } | 2236 } |
2236 } | 2237 } |
2237 } test; | 2238 } test; |
2238 | 2239 |
2239 RunBaseTest(&test, FakeNetworkPipe::Config()); | 2240 RunBaseTest(&test); |
2240 } | 2241 } |
2241 #endif | 2242 #endif |
2242 | 2243 |
2243 } // namespace webrtc | 2244 } // namespace webrtc |
OLD | NEW |