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> | 10 #include <algorithm> |
(...skipping 4127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4138 #define MAYBE_PictureIdStateRetainedAfterReinitingVp8 \ | 4138 #define MAYBE_PictureIdStateRetainedAfterReinitingVp8 \ |
4139 PictureIdStateRetainedAfterReinitingVp8 | 4139 PictureIdStateRetainedAfterReinitingVp8 |
4140 #define MAYBE_PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter \ | 4140 #define MAYBE_PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter \ |
4141 PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter | 4141 PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter |
4142 #endif | 4142 #endif |
4143 TEST_F(EndToEndTest, MAYBE_PictureIdStateRetainedAfterReinitingVp8) { | 4143 TEST_F(EndToEndTest, MAYBE_PictureIdStateRetainedAfterReinitingVp8) { |
4144 std::unique_ptr<VideoEncoder> encoder(VP8Encoder::Create()); | 4144 std::unique_ptr<VideoEncoder> encoder(VP8Encoder::Create()); |
4145 TestPictureIdStatePreservation(encoder.get()); | 4145 TestPictureIdStatePreservation(encoder.get()); |
4146 } | 4146 } |
4147 | 4147 |
| 4148 TEST_F(EndToEndTest, TestFlexfecRtpStatePreservation) { |
| 4149 class RtpSequenceObserver : public test::RtpRtcpObserver { |
| 4150 public: |
| 4151 RtpSequenceObserver() |
| 4152 : test::RtpRtcpObserver(kDefaultTimeoutMs), |
| 4153 num_flexfec_packets_sent_(0) {} |
| 4154 |
| 4155 void ResetPacketCount() { |
| 4156 rtc::CritScope lock(&crit_); |
| 4157 num_flexfec_packets_sent_ = 0; |
| 4158 } |
| 4159 |
| 4160 private: |
| 4161 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 4162 rtc::CritScope lock(&crit_); |
| 4163 |
| 4164 RTPHeader header; |
| 4165 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 4166 const uint16_t sequence_number = header.sequenceNumber; |
| 4167 const uint32_t timestamp = header.timestamp; |
| 4168 const uint32_t ssrc = header.ssrc; |
| 4169 |
| 4170 if (ssrc == kVideoSendSsrcs[0] || ssrc == kSendRtxSsrcs[0]) { |
| 4171 return SEND_PACKET; |
| 4172 } |
| 4173 EXPECT_EQ(kFlexfecSendSsrc, ssrc) << "Unknown SSRC sent."; |
| 4174 |
| 4175 ++num_flexfec_packets_sent_; |
| 4176 |
| 4177 // If this is the first packet, we have nothing to compare to. |
| 4178 if (!last_observed_sequence_number_) { |
| 4179 last_observed_sequence_number_.emplace(sequence_number); |
| 4180 last_observed_timestamp_.emplace(timestamp); |
| 4181 |
| 4182 return SEND_PACKET; |
| 4183 } |
| 4184 |
| 4185 // Verify continuity and monotonicity of RTP sequence numbers. |
| 4186 EXPECT_EQ(static_cast<uint16_t>(*last_observed_sequence_number_ + 1), |
| 4187 sequence_number); |
| 4188 last_observed_sequence_number_.emplace(sequence_number); |
| 4189 |
| 4190 // Timestamps should be non-decreasing... |
| 4191 const bool timestamp_is_same_or_newer = |
| 4192 timestamp == *last_observed_timestamp_ || |
| 4193 IsNewerTimestamp(timestamp, *last_observed_timestamp_); |
| 4194 EXPECT_TRUE(timestamp_is_same_or_newer); |
| 4195 // ...but reasonably close in time. |
| 4196 const int k10SecondsInRtpTimestampBase = 10 * kVideoPayloadTypeFrequency; |
| 4197 EXPECT_TRUE(IsNewerTimestamp( |
| 4198 *last_observed_timestamp_ + k10SecondsInRtpTimestampBase, timestamp)); |
| 4199 last_observed_timestamp_.emplace(timestamp); |
| 4200 |
| 4201 // Pass test when enough packets have been let through. |
| 4202 if (num_flexfec_packets_sent_ >= 10) { |
| 4203 observation_complete_.Set(); |
| 4204 } |
| 4205 |
| 4206 return SEND_PACKET; |
| 4207 } |
| 4208 |
| 4209 rtc::Optional<uint16_t> last_observed_sequence_number_ GUARDED_BY(crit_); |
| 4210 rtc::Optional<uint32_t> last_observed_timestamp_ GUARDED_BY(crit_); |
| 4211 size_t num_flexfec_packets_sent_ GUARDED_BY(crit_); |
| 4212 rtc::CriticalSection crit_; |
| 4213 } observer; |
| 4214 |
| 4215 Call::Config config(event_log_.get()); |
| 4216 CreateCalls(config, config); |
| 4217 |
| 4218 FakeNetworkPipe::Config lossy_delayed_link; |
| 4219 lossy_delayed_link.loss_percent = 2; |
| 4220 lossy_delayed_link.queue_delay_ms = 50; |
| 4221 test::PacketTransport send_transport(sender_call_.get(), &observer, |
| 4222 test::PacketTransport::kSender, |
| 4223 payload_type_map_, lossy_delayed_link); |
| 4224 send_transport.SetReceiver(receiver_call_->Receiver()); |
| 4225 |
| 4226 FakeNetworkPipe::Config flawless_link; |
| 4227 test::PacketTransport receive_transport(nullptr, &observer, |
| 4228 test::PacketTransport::kReceiver, |
| 4229 payload_type_map_, flawless_link); |
| 4230 receive_transport.SetReceiver(sender_call_->Receiver()); |
| 4231 |
| 4232 // For reduced flakyness, we use a real VP8 encoder together with NACK |
| 4233 // and RTX. |
| 4234 const int kNumVideoStreams = 1; |
| 4235 const int kNumFlexfecStreams = 1; |
| 4236 CreateSendConfig(kNumVideoStreams, 0, kNumFlexfecStreams, &send_transport); |
| 4237 std::unique_ptr<VideoEncoder> encoder(VP8Encoder::Create()); |
| 4238 video_send_config_.encoder_settings.encoder = encoder.get(); |
| 4239 video_send_config_.encoder_settings.payload_name = "VP8"; |
| 4240 video_send_config_.encoder_settings.payload_type = kVideoSendPayloadType; |
| 4241 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 4242 video_send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]); |
| 4243 video_send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; |
| 4244 |
| 4245 CreateMatchingReceiveConfigs(&receive_transport); |
| 4246 video_receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 4247 video_receive_configs_[0].rtp.rtx_ssrc = kSendRtxSsrcs[0]; |
| 4248 video_receive_configs_[0].rtp.rtx_payload_types[kVideoSendPayloadType] = |
| 4249 kSendRtxPayloadType; |
| 4250 |
| 4251 // The matching FlexFEC receive config is not created by |
| 4252 // CreateMatchingReceiveConfigs since this is not a test::BaseTest. |
| 4253 // Set up the receive config manually instead. |
| 4254 FlexfecReceiveStream::Config flexfec_receive_config(&receive_transport); |
| 4255 flexfec_receive_config.payload_type = |
| 4256 video_send_config_.rtp.flexfec.payload_type; |
| 4257 flexfec_receive_config.remote_ssrc = video_send_config_.rtp.flexfec.ssrc; |
| 4258 flexfec_receive_config.protected_media_ssrcs = |
| 4259 video_send_config_.rtp.flexfec.protected_media_ssrcs; |
| 4260 flexfec_receive_config.local_ssrc = kReceiverLocalVideoSsrc; |
| 4261 flexfec_receive_config.transport_cc = true; |
| 4262 flexfec_receive_config.rtp_header_extensions.emplace_back( |
| 4263 RtpExtension::kTransportSequenceNumberUri, |
| 4264 test::kTransportSequenceNumberExtensionId); |
| 4265 flexfec_receive_configs_.push_back(flexfec_receive_config); |
| 4266 |
| 4267 CreateFlexfecStreams(); |
| 4268 CreateVideoStreams(); |
| 4269 |
| 4270 // RTCP might be disabled if the network is "down". |
| 4271 sender_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); |
| 4272 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); |
| 4273 |
| 4274 const int kFrameMaxWidth = 320; |
| 4275 const int kFrameMaxHeight = 180; |
| 4276 const int kFrameRate = 15; |
| 4277 CreateFrameGeneratorCapturer(kFrameRate, kFrameMaxWidth, kFrameMaxHeight); |
| 4278 |
| 4279 // Initial test. |
| 4280 Start(); |
| 4281 EXPECT_TRUE(observer.Wait()) << "Timed out waiting for packets."; |
| 4282 |
| 4283 // Ensure monotonicity when the VideoSendStream is restarted. |
| 4284 Stop(); |
| 4285 observer.ResetPacketCount(); |
| 4286 Start(); |
| 4287 EXPECT_TRUE(observer.Wait()) << "Timed out waiting for packets."; |
| 4288 |
| 4289 // Ensure monotonicity when the VideoSendStream is recreated. |
| 4290 frame_generator_capturer_->Stop(); |
| 4291 sender_call_->DestroyVideoSendStream(video_send_stream_); |
| 4292 observer.ResetPacketCount(); |
| 4293 video_send_stream_ = sender_call_->CreateVideoSendStream( |
| 4294 video_send_config_.Copy(), video_encoder_config_.Copy()); |
| 4295 video_send_stream_->Start(); |
| 4296 CreateFrameGeneratorCapturer(kFrameRate, kFrameMaxWidth, kFrameMaxHeight); |
| 4297 frame_generator_capturer_->Start(); |
| 4298 EXPECT_TRUE(observer.Wait()) << "Timed out waiting for packets."; |
| 4299 |
| 4300 // Cleanup. |
| 4301 send_transport.StopSending(); |
| 4302 receive_transport.StopSending(); |
| 4303 Stop(); |
| 4304 DestroyStreams(); |
| 4305 } |
| 4306 |
4148 TEST_F(EndToEndTest, | 4307 TEST_F(EndToEndTest, |
4149 MAYBE_PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter) { | 4308 MAYBE_PictureIdStateRetainedAfterReinitingSimulcastEncoderAdapter) { |
4150 class VideoEncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 4309 class VideoEncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
4151 public: | 4310 public: |
4152 explicit VideoEncoderFactoryAdapter( | 4311 explicit VideoEncoderFactoryAdapter( |
4153 cricket::WebRtcVideoEncoderFactory* factory) | 4312 cricket::WebRtcVideoEncoderFactory* factory) |
4154 : factory_(factory) {} | 4313 : factory_(factory) {} |
4155 virtual ~VideoEncoderFactoryAdapter() {} | 4314 virtual ~VideoEncoderFactoryAdapter() {} |
4156 | 4315 |
4157 // Implements webrtc::VideoEncoderFactory. | 4316 // Implements webrtc::VideoEncoderFactory. |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4759 std::unique_ptr<VideoEncoder> encoder_; | 4918 std::unique_ptr<VideoEncoder> encoder_; |
4760 std::unique_ptr<VideoDecoder> decoder_; | 4919 std::unique_ptr<VideoDecoder> decoder_; |
4761 rtc::CriticalSection crit_; | 4920 rtc::CriticalSection crit_; |
4762 int recorded_frames_ GUARDED_BY(crit_); | 4921 int recorded_frames_ GUARDED_BY(crit_); |
4763 } test(this); | 4922 } test(this); |
4764 | 4923 |
4765 RunBaseTest(&test); | 4924 RunBaseTest(&test); |
4766 } | 4925 } |
4767 | 4926 |
4768 } // namespace webrtc | 4927 } // namespace webrtc |
OLD | NEW |