| 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 | 10 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 | 14 |
| 15 #include "webrtc/video/loopback.h" | 15 #include "webrtc/video/loopback.h" |
| 16 | 16 |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
| 21 #include "webrtc/call.h" | 21 #include "webrtc/call.h" |
| 22 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 22 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 23 #include "webrtc/system_wrappers/interface/clock.h" | 26 #include "webrtc/system_wrappers/interface/clock.h" |
| 24 #include "webrtc/test/direct_transport.h" | |
| 25 #include "webrtc/test/encoder_settings.h" | 27 #include "webrtc/test/encoder_settings.h" |
| 26 #include "webrtc/test/fake_encoder.h" | 28 #include "webrtc/test/fake_encoder.h" |
| 29 #include "webrtc/test/layer_filtering_transport.h" |
| 27 #include "webrtc/test/run_loop.h" | 30 #include "webrtc/test/run_loop.h" |
| 28 #include "webrtc/test/testsupport/trace_to_stderr.h" | 31 #include "webrtc/test/testsupport/trace_to_stderr.h" |
| 29 #include "webrtc/test/video_capturer.h" | 32 #include "webrtc/test/video_capturer.h" |
| 30 #include "webrtc/test/video_renderer.h" | 33 #include "webrtc/test/video_renderer.h" |
| 31 #include "webrtc/typedefs.h" | 34 #include "webrtc/typedefs.h" |
| 32 | 35 |
| 33 namespace webrtc { | 36 namespace webrtc { |
| 34 namespace test { | 37 namespace test { |
| 35 | 38 |
| 36 static const int kAbsSendTimeExtensionId = 7; | 39 static const int kAbsSendTimeExtensionId = 7; |
| 37 | 40 |
| 38 static const uint32_t kSendSsrc = 0x654321; | 41 static const uint32_t kSendSsrc = 0x654321; |
| 39 static const uint32_t kSendRtxSsrc = 0x654322; | 42 static const uint32_t kSendRtxSsrc = 0x654322; |
| 40 static const uint32_t kReceiverLocalSsrc = 0x123456; | 43 static const uint32_t kReceiverLocalSsrc = 0x123456; |
| 41 | 44 |
| 42 static const uint8_t kRtxVideoPayloadType = 96; | 45 static const uint8_t kRtxVideoPayloadType = 96; |
| 43 static const uint8_t kVideoPayloadType = 124; | 46 static const uint8_t kVideoPayloadTypeVP8 = 124; |
| 47 static const uint8_t kVideoPayloadTypeVP9 = 125; |
| 44 | 48 |
| 45 Loopback::Loopback(const Config& config) | 49 Loopback::Loopback(const Config& config) |
| 46 : config_(config), clock_(Clock::GetRealTimeClock()) { | 50 : config_(config), clock_(Clock::GetRealTimeClock()) { |
| 47 } | 51 } |
| 48 | 52 |
| 49 Loopback::~Loopback() { | 53 Loopback::~Loopback() { |
| 50 } | 54 } |
| 51 | 55 |
| 52 void Loopback::Run() { | 56 void Loopback::Run() { |
| 53 rtc::scoped_ptr<test::TraceToStderr> trace_to_stderr_; | 57 rtc::scoped_ptr<test::TraceToStderr> trace_to_stderr_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 69 call_config.bitrate_config.max_bitrate_bps = | 73 call_config.bitrate_config.max_bitrate_bps = |
| 70 static_cast<int>(config_.max_bitrate_kbps) * 1000; | 74 static_cast<int>(config_.max_bitrate_kbps) * 1000; |
| 71 rtc::scoped_ptr<Call> call(Call::Create(call_config)); | 75 rtc::scoped_ptr<Call> call(Call::Create(call_config)); |
| 72 | 76 |
| 73 FakeNetworkPipe::Config pipe_config; | 77 FakeNetworkPipe::Config pipe_config; |
| 74 pipe_config.loss_percent = config_.loss_percent; | 78 pipe_config.loss_percent = config_.loss_percent; |
| 75 pipe_config.link_capacity_kbps = config_.link_capacity_kbps; | 79 pipe_config.link_capacity_kbps = config_.link_capacity_kbps; |
| 76 pipe_config.queue_length_packets = config_.queue_size; | 80 pipe_config.queue_length_packets = config_.queue_size; |
| 77 pipe_config.queue_delay_ms = config_.avg_propagation_delay_ms; | 81 pipe_config.queue_delay_ms = config_.avg_propagation_delay_ms; |
| 78 pipe_config.delay_standard_deviation_ms = config_.std_propagation_delay_ms; | 82 pipe_config.delay_standard_deviation_ms = config_.std_propagation_delay_ms; |
| 79 test::DirectTransport send_transport(pipe_config); | 83 LayerFilteringTransport send_transport( |
| 84 pipe_config, kVideoPayloadTypeVP8, kVideoPayloadTypeVP9, |
| 85 static_cast<uint8_t>(config_.tl_discard_threshold), |
| 86 static_cast<uint8_t>(config_.sl_discard_threshold)); |
| 87 |
| 80 // Loopback, call sends to itself. | 88 // Loopback, call sends to itself. |
| 81 send_transport.SetReceiver(call->Receiver()); | 89 send_transport.SetReceiver(call->Receiver()); |
| 82 | 90 |
| 83 VideoSendStream::Config send_config(&send_transport); | 91 VideoSendStream::Config send_config(&send_transport); |
| 84 send_config.rtp.ssrcs.push_back(kSendSsrc); | 92 send_config.rtp.ssrcs.push_back(kSendSsrc); |
| 85 send_config.rtp.rtx.ssrcs.push_back(kSendRtxSsrc); | 93 send_config.rtp.rtx.ssrcs.push_back(kSendRtxSsrc); |
| 86 send_config.rtp.rtx.payload_type = kRtxVideoPayloadType; | 94 send_config.rtp.rtx.payload_type = kRtxVideoPayloadType; |
| 87 send_config.rtp.nack.rtp_history_ms = 1000; | 95 send_config.rtp.nack.rtp_history_ms = 1000; |
| 88 send_config.rtp.extensions.push_back( | 96 send_config.rtp.extensions.push_back( |
| 89 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); | 97 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); |
| 90 | 98 |
| 91 send_config.local_renderer = local_preview.get(); | 99 send_config.local_renderer = local_preview.get(); |
| 92 rtc::scoped_ptr<VideoEncoder> encoder; | 100 rtc::scoped_ptr<VideoEncoder> encoder; |
| 93 if (config_.codec == "VP8") { | 101 if (config_.codec == "VP8") { |
| 94 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp8)); | 102 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp8)); |
| 95 } else if (config_.codec == "VP9") { | 103 } else if (config_.codec == "VP9") { |
| 96 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp9)); | 104 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp9)); |
| 97 } else { | 105 } else { |
| 98 // Codec not supported. | 106 // Codec not supported. |
| 99 RTC_NOTREACHED() << "Codec not supported!"; | 107 RTC_NOTREACHED() << "Codec not supported!"; |
| 100 return; | 108 return; |
| 101 } | 109 } |
| 110 const int payload_type = |
| 111 config_.codec == "VP8" ? kVideoPayloadTypeVP8 : kVideoPayloadTypeVP9; |
| 102 send_config.encoder_settings.encoder = encoder.get(); | 112 send_config.encoder_settings.encoder = encoder.get(); |
| 103 send_config.encoder_settings.payload_name = config_.codec; | 113 send_config.encoder_settings.payload_name = config_.codec; |
| 104 send_config.encoder_settings.payload_type = kVideoPayloadType; | 114 send_config.encoder_settings.payload_type = payload_type; |
| 105 | 115 |
| 106 VideoEncoderConfig encoder_config(CreateEncoderConfig()); | 116 VideoEncoderConfig encoder_config(CreateEncoderConfig()); |
| 107 | 117 |
| 108 VideoSendStream* send_stream = | 118 VideoSendStream* send_stream = |
| 109 call->CreateVideoSendStream(send_config, encoder_config); | 119 call->CreateVideoSendStream(send_config, encoder_config); |
| 110 | 120 |
| 111 rtc::scoped_ptr<test::VideoCapturer> capturer(CreateCapturer(send_stream)); | 121 rtc::scoped_ptr<test::VideoCapturer> capturer(CreateCapturer(send_stream)); |
| 112 | 122 |
| 113 VideoReceiveStream::Config receive_config(&send_transport); | 123 VideoReceiveStream::Config receive_config(&send_transport); |
| 114 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0]; | 124 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0]; |
| 115 receive_config.rtp.local_ssrc = kReceiverLocalSsrc; | 125 receive_config.rtp.local_ssrc = kReceiverLocalSsrc; |
| 116 receive_config.rtp.nack.rtp_history_ms = 1000; | 126 receive_config.rtp.nack.rtp_history_ms = 1000; |
| 117 receive_config.rtp.remb = true; | 127 receive_config.rtp.remb = true; |
| 118 receive_config.rtp.rtx[kVideoPayloadType].ssrc = kSendRtxSsrc; | 128 receive_config.rtp.rtx[payload_type].ssrc = kSendRtxSsrc; |
| 119 receive_config.rtp.rtx[kVideoPayloadType].payload_type = kRtxVideoPayloadType; | 129 receive_config.rtp.rtx[payload_type].payload_type = kRtxVideoPayloadType; |
| 120 receive_config.rtp.extensions.push_back( | 130 receive_config.rtp.extensions.push_back( |
| 121 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); | 131 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); |
| 122 receive_config.renderer = loopback_video.get(); | 132 receive_config.renderer = loopback_video.get(); |
| 123 VideoReceiveStream::Decoder decoder = | 133 VideoReceiveStream::Decoder decoder = |
| 124 test::CreateMatchingDecoder(send_config.encoder_settings); | 134 test::CreateMatchingDecoder(send_config.encoder_settings); |
| 125 receive_config.decoders.push_back(decoder); | 135 receive_config.decoders.push_back(decoder); |
| 126 | 136 |
| 127 VideoReceiveStream* receive_stream = | 137 VideoReceiveStream* receive_stream = |
| 128 call->CreateVideoReceiveStream(receive_config); | 138 call->CreateVideoReceiveStream(receive_config); |
| 129 | 139 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return encoder_config; | 174 return encoder_config; |
| 165 } | 175 } |
| 166 | 176 |
| 167 test::VideoCapturer* Loopback::CreateCapturer(VideoSendStream* send_stream) { | 177 test::VideoCapturer* Loopback::CreateCapturer(VideoSendStream* send_stream) { |
| 168 return test::VideoCapturer::Create(send_stream->Input(), config_.width, | 178 return test::VideoCapturer::Create(send_stream->Input(), config_.width, |
| 169 config_.height, config_.fps, clock_); | 179 config_.height, config_.fps, clock_); |
| 170 } | 180 } |
| 171 | 181 |
| 172 } // namespace test | 182 } // namespace test |
| 173 } // namespace webrtc | 183 } // namespace webrtc |
| OLD | NEW |