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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); | 50 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); |
51 | 51 |
52 class VideoSendStreamTest : public test::CallTest { | 52 class VideoSendStreamTest : public test::CallTest { |
53 protected: | 53 protected: |
54 void TestNackRetransmission(uint32_t retransmit_ssrc, | 54 void TestNackRetransmission(uint32_t retransmit_ssrc, |
55 uint8_t retransmit_payload_type); | 55 uint8_t retransmit_payload_type); |
56 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 56 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); |
57 | 57 |
58 void TestVp9NonFlexMode(uint8_t num_temporal_layers, | 58 void TestVp9NonFlexMode(uint8_t num_temporal_layers, |
59 uint8_t num_spatial_layers); | 59 uint8_t num_spatial_layers); |
| 60 |
| 61 void TestRequestSourceRotateVideo(bool support_orientation_ext); |
60 }; | 62 }; |
61 | 63 |
62 TEST_F(VideoSendStreamTest, CanStartStartedStream) { | 64 TEST_F(VideoSendStreamTest, CanStartStartedStream) { |
63 CreateSenderCall(Call::Config(&event_log_)); | 65 CreateSenderCall(Call::Config(&event_log_)); |
64 | 66 |
65 test::NullTransport transport; | 67 test::NullTransport transport; |
66 CreateSendConfig(1, 0, &transport); | 68 CreateSendConfig(1, 0, &transport); |
67 CreateVideoStreams(); | 69 CreateVideoStreams(); |
68 video_send_stream_->Start(); | 70 video_send_stream_->Start(); |
69 video_send_stream_->Start(); | 71 video_send_stream_->Start(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 void PerformTest() override { | 250 void PerformTest() override { |
249 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; | 251 EXPECT_TRUE(Wait()) << "Timed out while waiting for a single RTP packet."; |
250 } | 252 } |
251 | 253 |
252 test::FakeEncoder encoder_; | 254 test::FakeEncoder encoder_; |
253 } test; | 255 } test; |
254 | 256 |
255 RunBaseTest(&test); | 257 RunBaseTest(&test); |
256 } | 258 } |
257 | 259 |
| 260 TEST_F(VideoSendStreamTest, SupportsVideoRotation) { |
| 261 class VideoRotationObserver : public test::SendTest { |
| 262 public: |
| 263 VideoRotationObserver() : SendTest(kDefaultTimeoutMs) { |
| 264 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension( |
| 265 kRtpExtensionVideoRotation, test::kVideoRotationExtensionId)); |
| 266 } |
| 267 |
| 268 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 269 RTPHeader header; |
| 270 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 271 EXPECT_TRUE(header.extension.hasVideoRotation); |
| 272 EXPECT_EQ(kVideoRotation_90, header.extension.videoRotation); |
| 273 observation_complete_.Set(); |
| 274 return SEND_PACKET; |
| 275 } |
| 276 |
| 277 void ModifyVideoConfigs( |
| 278 VideoSendStream::Config* send_config, |
| 279 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 280 VideoEncoderConfig* encoder_config) override { |
| 281 send_config->rtp.extensions.clear(); |
| 282 send_config->rtp.extensions.push_back(RtpExtension( |
| 283 RtpExtension::kVideoRotationUri, test::kVideoRotationExtensionId)); |
| 284 } |
| 285 |
| 286 void OnFrameGeneratorCapturerCreated( |
| 287 test::FrameGeneratorCapturer* frame_generator_capturer) override { |
| 288 frame_generator_capturer->SetFakeRotation(kVideoRotation_90); |
| 289 } |
| 290 |
| 291 void PerformTest() override { |
| 292 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet."; |
| 293 } |
| 294 } test; |
| 295 |
| 296 RunBaseTest(&test); |
| 297 } |
| 298 |
258 class FakeReceiveStatistics : public NullReceiveStatistics { | 299 class FakeReceiveStatistics : public NullReceiveStatistics { |
259 public: | 300 public: |
260 FakeReceiveStatistics(uint32_t send_ssrc, | 301 FakeReceiveStatistics(uint32_t send_ssrc, |
261 uint32_t last_sequence_number, | 302 uint32_t last_sequence_number, |
262 uint32_t cumulative_lost, | 303 uint32_t cumulative_lost, |
263 uint8_t fraction_lost) | 304 uint8_t fraction_lost) |
264 : lossy_stats_(new LossyStatistician(last_sequence_number, | 305 : lossy_stats_(new LossyStatistician(last_sequence_number, |
265 cumulative_lost, | 306 cumulative_lost, |
266 fraction_lost)) { | 307 fraction_lost)) { |
267 stats_map_[send_ssrc] = lossy_stats_.get(); | 308 stats_map_[send_ssrc] = lossy_stats_.get(); |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 handle1, width, height, 1, 1, kVideoRotation_0)); | 1690 handle1, width, height, 1, 1, kVideoRotation_0)); |
1650 input_frames.push_back(test::FakeNativeHandle::CreateFrame( | 1691 input_frames.push_back(test::FakeNativeHandle::CreateFrame( |
1651 handle2, width, height, 2, 2, kVideoRotation_0)); | 1692 handle2, width, height, 2, 2, kVideoRotation_0)); |
1652 input_frames.push_back(CreateVideoFrame(width, height, 3)); | 1693 input_frames.push_back(CreateVideoFrame(width, height, 3)); |
1653 input_frames.push_back(CreateVideoFrame(width, height, 4)); | 1694 input_frames.push_back(CreateVideoFrame(width, height, 4)); |
1654 input_frames.push_back(test::FakeNativeHandle::CreateFrame( | 1695 input_frames.push_back(test::FakeNativeHandle::CreateFrame( |
1655 handle3, width, height, 5, 5, kVideoRotation_0)); | 1696 handle3, width, height, 5, 5, kVideoRotation_0)); |
1656 | 1697 |
1657 video_send_stream_->Start(); | 1698 video_send_stream_->Start(); |
1658 test::FrameForwarder forwarder; | 1699 test::FrameForwarder forwarder; |
1659 video_send_stream_->SetSource(&forwarder); | 1700 video_send_stream_->SetSource( |
| 1701 &forwarder, VideoSendStream::DegradationPreference::kBalanced); |
1660 for (size_t i = 0; i < input_frames.size(); i++) { | 1702 for (size_t i = 0; i < input_frames.size(); i++) { |
1661 forwarder.IncomingCapturedFrame(input_frames[i]); | 1703 forwarder.IncomingCapturedFrame(input_frames[i]); |
1662 // Wait until the output frame is received before sending the next input | 1704 // Wait until the output frame is received before sending the next input |
1663 // frame. Or the previous input frame may be replaced without delivering. | 1705 // frame. Or the previous input frame may be replaced without delivering. |
1664 observer.WaitOutputFrame(); | 1706 observer.WaitOutputFrame(); |
1665 } | 1707 } |
1666 video_send_stream_->Stop(); | 1708 video_send_stream_->Stop(); |
1667 video_send_stream_->SetSource(nullptr); | 1709 video_send_stream_->SetSource( |
| 1710 nullptr, VideoSendStream::DegradationPreference::kBalanced); |
1668 | 1711 |
1669 // Test if the input and output frames are the same. render_time_ms and | 1712 // Test if the input and output frames are the same. render_time_ms and |
1670 // timestamp are not compared because capturer sets those values. | 1713 // timestamp are not compared because capturer sets those values. |
1671 ExpectEqualFramesVector(input_frames, observer.output_frames()); | 1714 ExpectEqualFramesVector(input_frames, observer.output_frames()); |
1672 | 1715 |
1673 DestroyStreams(); | 1716 DestroyStreams(); |
1674 } | 1717 } |
1675 | 1718 |
1676 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 1719 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, |
1677 const std::vector<VideoFrame>& frames2) { | 1720 const std::vector<VideoFrame>& frames2) { |
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 EXPECT_GT(vp9_header.num_ref_pics, 0u); | 2915 EXPECT_GT(vp9_header.num_ref_pics, 0u); |
2873 observation_complete_.Set(); | 2916 observation_complete_.Set(); |
2874 } | 2917 } |
2875 } | 2918 } |
2876 } test; | 2919 } test; |
2877 | 2920 |
2878 RunBaseTest(&test); | 2921 RunBaseTest(&test); |
2879 } | 2922 } |
2880 #endif // !defined(RTC_DISABLE_VP9) | 2923 #endif // !defined(RTC_DISABLE_VP9) |
2881 | 2924 |
| 2925 void VideoSendStreamTest::TestRequestSourceRotateVideo( |
| 2926 bool support_orientation_ext) { |
| 2927 CreateSenderCall(Call::Config(&event_log_)); |
| 2928 |
| 2929 test::NullTransport transport; |
| 2930 CreateSendConfig(1, 0, &transport); |
| 2931 video_send_config_.rtp.extensions.clear(); |
| 2932 if (support_orientation_ext) { |
| 2933 video_send_config_.rtp.extensions.push_back( |
| 2934 RtpExtension(RtpExtension::kVideoRotationUri, 1)); |
| 2935 } |
| 2936 |
| 2937 CreateVideoStreams(); |
| 2938 test::FrameForwarder forwarder; |
| 2939 video_send_stream_->SetSource( |
| 2940 &forwarder, VideoSendStream::DegradationPreference::kBalanced); |
| 2941 |
| 2942 EXPECT_TRUE(forwarder.sink_wants().rotation_applied != |
| 2943 support_orientation_ext); |
| 2944 |
| 2945 DestroyStreams(); |
| 2946 } |
| 2947 |
| 2948 TEST_F(VideoSendStreamTest, |
| 2949 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { |
| 2950 TestRequestSourceRotateVideo(false); |
| 2951 } |
| 2952 |
| 2953 TEST_F(VideoSendStreamTest, |
| 2954 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { |
| 2955 TestRequestSourceRotateVideo(true); |
| 2956 } |
| 2957 |
2882 } // namespace webrtc | 2958 } // namespace webrtc |
OLD | NEW |