| 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 12 matching lines...) Expand all  Loading... | 
| 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 
| 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 
| 25 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 25 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 
| 26 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 26 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 
| 27 #include "webrtc/system_wrappers/interface/logging.h" | 27 #include "webrtc/system_wrappers/interface/logging.h" | 
| 28 #include "webrtc/system_wrappers/interface/ref_count.h" | 28 #include "webrtc/system_wrappers/interface/ref_count.h" | 
| 29 #include "webrtc/system_wrappers/interface/sleep.h" | 29 #include "webrtc/system_wrappers/interface/sleep.h" | 
| 30 #include "webrtc/system_wrappers/interface/thread_wrapper.h" | 30 #include "webrtc/system_wrappers/interface/thread_wrapper.h" | 
| 31 #include "webrtc/test/call_test.h" | 31 #include "webrtc/test/call_test.h" | 
| 32 #include "webrtc/test/configurable_frame_size_encoder.h" | 32 #include "webrtc/test/configurable_frame_size_encoder.h" | 
|  | 33 #include "webrtc/test/fake_texture_frame.h" | 
| 33 #include "webrtc/test/null_transport.h" | 34 #include "webrtc/test/null_transport.h" | 
| 34 #include "webrtc/test/testsupport/perf_test.h" | 35 #include "webrtc/test/testsupport/perf_test.h" | 
| 35 #include "webrtc/video/send_statistics_proxy.h" | 36 #include "webrtc/video/send_statistics_proxy.h" | 
| 36 #include "webrtc/video/transport_adapter.h" | 37 #include "webrtc/video/transport_adapter.h" | 
| 37 #include "webrtc/video_frame.h" | 38 #include "webrtc/video_frame.h" | 
| 38 #include "webrtc/video_send_stream.h" | 39 #include "webrtc/video_send_stream.h" | 
| 39 | 40 | 
| 40 namespace webrtc { | 41 namespace webrtc { | 
| 41 | 42 | 
| 42 enum VideoFormat { kGeneric, kVP8, }; | 43 enum VideoFormat { kGeneric, kVP8, }; | 
| 43 | 44 | 
| 44 void ExpectEqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); | 45 void ExpectEqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); | 
| 45 void ExpectEqualTextureFrames(const VideoFrame& frame1, | 46 void ExpectEqualTextureFrames(const VideoFrame& frame1, | 
| 46                               const VideoFrame& frame2); | 47                               const VideoFrame& frame2); | 
| 47 void ExpectEqualBufferFrames(const VideoFrame& frame1, | 48 void ExpectEqualBufferFrames(const VideoFrame& frame1, | 
| 48                              const VideoFrame& frame2); | 49                              const VideoFrame& frame2); | 
| 49 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 50 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 
| 50                              const std::vector<VideoFrame>& frames2); | 51                              const std::vector<VideoFrame>& frames2); | 
| 51 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); | 52 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); | 
| 52 | 53 | 
| 53 class FakeNativeHandle { |  | 
| 54  public: |  | 
| 55   FakeNativeHandle() {} |  | 
| 56   ~FakeNativeHandle() {} |  | 
| 57 }; |  | 
| 58 |  | 
| 59 void DeleteNativeHandle(FakeNativeHandle* handle) { |  | 
| 60   delete handle; |  | 
| 61 } |  | 
| 62 |  | 
| 63 class VideoSendStreamTest : public test::CallTest { | 54 class VideoSendStreamTest : public test::CallTest { | 
| 64  protected: | 55  protected: | 
| 65   void TestNackRetransmission(uint32_t retransmit_ssrc, | 56   void TestNackRetransmission(uint32_t retransmit_ssrc, | 
| 66                               uint8_t retransmit_payload_type); | 57                               uint8_t retransmit_payload_type); | 
| 67   void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 58   void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 
| 68 }; | 59 }; | 
| 69 | 60 | 
| 70 TEST_F(VideoSendStreamTest, CanStartStartedStream) { | 61 TEST_F(VideoSendStreamTest, CanStartStartedStream) { | 
| 71   test::NullTransport transport; | 62   test::NullTransport transport; | 
| 72   Call::Config call_config(&transport); | 63   Call::Config call_config(&transport); | 
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1077   CreateSendConfig(1); | 1068   CreateSendConfig(1); | 
| 1078   FrameObserver observer; | 1069   FrameObserver observer; | 
| 1079   send_config_.pre_encode_callback = &observer; | 1070   send_config_.pre_encode_callback = &observer; | 
| 1080   CreateStreams(); | 1071   CreateStreams(); | 
| 1081 | 1072 | 
| 1082   // Prepare five input frames. Send ordinary VideoFrame and texture frames | 1073   // Prepare five input frames. Send ordinary VideoFrame and texture frames | 
| 1083   // alternatively. | 1074   // alternatively. | 
| 1084   std::vector<VideoFrame> input_frames; | 1075   std::vector<VideoFrame> input_frames; | 
| 1085   int width = static_cast<int>(encoder_config_.streams[0].width); | 1076   int width = static_cast<int>(encoder_config_.streams[0].width); | 
| 1086   int height = static_cast<int>(encoder_config_.streams[0].height); | 1077   int height = static_cast<int>(encoder_config_.streams[0].height); | 
| 1087   FakeNativeHandle* handle1 = new FakeNativeHandle(); | 1078   test::FakeNativeHandle* handle1 = new test::FakeNativeHandle(); | 
| 1088   FakeNativeHandle* handle2 = new FakeNativeHandle(); | 1079   test::FakeNativeHandle* handle2 = new test::FakeNativeHandle(); | 
| 1089   FakeNativeHandle* handle3 = new FakeNativeHandle(); | 1080   test::FakeNativeHandle* handle3 = new test::FakeNativeHandle(); | 
| 1090   input_frames.push_back(VideoFrame(handle1, width, height, 1, 1, | 1081   input_frames.push_back(test::CreateFakeNativeHandleFrame( | 
| 1091                                     kVideoRotation_0, | 1082       handle1, width, height, 1, 1, kVideoRotation_0)); | 
| 1092                                     rtc::Bind(&DeleteNativeHandle, handle1))); | 1083   input_frames.push_back(test::CreateFakeNativeHandleFrame( | 
| 1093   input_frames.push_back(VideoFrame(handle2, width, height, 2, 2, | 1084       handle2, width, height, 2, 2, kVideoRotation_0)); | 
| 1094                                     kVideoRotation_0, |  | 
| 1095                                     rtc::Bind(&DeleteNativeHandle, handle2))); |  | 
| 1096   input_frames.push_back(CreateVideoFrame(width, height, 3)); | 1085   input_frames.push_back(CreateVideoFrame(width, height, 3)); | 
| 1097   input_frames.push_back(CreateVideoFrame(width, height, 4)); | 1086   input_frames.push_back(CreateVideoFrame(width, height, 4)); | 
| 1098   input_frames.push_back(VideoFrame(handle3, width, height, 5, 5, | 1087   input_frames.push_back(test::CreateFakeNativeHandleFrame( | 
| 1099                                     kVideoRotation_0, | 1088       handle3, width, height, 5, 5, kVideoRotation_0)); | 
| 1100                                     rtc::Bind(&DeleteNativeHandle, handle3))); |  | 
| 1101 | 1089 | 
| 1102   send_stream_->Start(); | 1090   send_stream_->Start(); | 
| 1103   for (size_t i = 0; i < input_frames.size(); i++) { | 1091   for (size_t i = 0; i < input_frames.size(); i++) { | 
| 1104     send_stream_->Input()->IncomingCapturedFrame(input_frames[i]); | 1092     send_stream_->Input()->IncomingCapturedFrame(input_frames[i]); | 
| 1105     // Do not send the next frame too fast, so the frame dropper won't drop it. | 1093     // Do not send the next frame too fast, so the frame dropper won't drop it. | 
| 1106     if (i < input_frames.size() - 1) | 1094     if (i < input_frames.size() - 1) | 
| 1107       SleepMs(1000 / encoder_config_.streams[0].max_framerate); | 1095       SleepMs(1000 / encoder_config_.streams[0].max_framerate); | 
| 1108     // Wait until the output frame is received before sending the next input | 1096     // Wait until the output frame is received before sending the next input | 
| 1109     // frame. Or the previous input frame may be replaced without delivering. | 1097     // frame. Or the previous input frame may be replaced without delivering. | 
| 1110     observer.WaitOutputFrame(); | 1098     observer.WaitOutputFrame(); | 
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1759         const std::vector<VideoReceiveStream*>& receive_streams) override { | 1747         const std::vector<VideoReceiveStream*>& receive_streams) override { | 
| 1760       send_stream_ = send_stream; | 1748       send_stream_ = send_stream; | 
| 1761     } | 1749     } | 
| 1762 | 1750 | 
| 1763     VideoSendStream* send_stream_; | 1751     VideoSendStream* send_stream_; | 
| 1764   } test; | 1752   } test; | 
| 1765 | 1753 | 
| 1766   RunBaseTest(&test); | 1754   RunBaseTest(&test); | 
| 1767 } | 1755 } | 
| 1768 }  // namespace webrtc | 1756 }  // namespace webrtc | 
| OLD | NEW | 
|---|