Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: webrtc/video/loopback.cc

Issue 1287643002: Enabling spatial layers in VP9Impl. Filter layers in the loopback test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing unit tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_;
54 if (config_.logs) 58 if (config_.logs)
55 trace_to_stderr_.reset(new test::TraceToStderr); 59 trace_to_stderr_.reset(new test::TraceToStderr);
56 60
57 rtc::scoped_ptr<test::VideoRenderer> local_preview( 61 rtc::scoped_ptr<test::VideoRenderer> local_preview(
58 test::VideoRenderer::Create("Local Preview", config_.width, 62 test::VideoRenderer::Create("Local Preview", config_.width,
59 config_.height)); 63 config_.height));
60 rtc::scoped_ptr<test::VideoRenderer> loopback_video( 64 rtc::scoped_ptr<test::VideoRenderer> loopback_video(
61 test::VideoRenderer::Create("Loopback Video", config_.width, 65 test::VideoRenderer::Create("Loopback Video", config_.width,
62 config_.height)); 66 config_.height));
63 67
64 FakeNetworkPipe::Config pipe_config; 68 FakeNetworkPipe::Config pipe_config;
65 pipe_config.loss_percent = config_.loss_percent; 69 pipe_config.loss_percent = config_.loss_percent;
66 pipe_config.link_capacity_kbps = config_.link_capacity_kbps; 70 pipe_config.link_capacity_kbps = config_.link_capacity_kbps;
67 pipe_config.queue_length_packets = config_.queue_size; 71 pipe_config.queue_length_packets = config_.queue_size;
68 pipe_config.queue_delay_ms = config_.avg_propagation_delay_ms; 72 pipe_config.queue_delay_ms = config_.avg_propagation_delay_ms;
69 pipe_config.delay_standard_deviation_ms = config_.std_propagation_delay_ms; 73 pipe_config.delay_standard_deviation_ms = config_.std_propagation_delay_ms;
70 test::DirectTransport transport(pipe_config); 74 LayerFilteringTransport transport(
75 pipe_config, kVideoPayloadTypeVP8, kVideoPayloadTypeVP9,
76 static_cast<uint8_t>(config_.tl_discard_threshold),
77 static_cast<uint8_t>(config_.sl_discard_threshold));
71 Call::Config call_config(&transport); 78 Call::Config call_config(&transport);
72 79
73 call_config.bitrate_config.min_bitrate_bps = 80 call_config.bitrate_config.min_bitrate_bps =
74 static_cast<int>(config_.min_bitrate_kbps) * 1000; 81 static_cast<int>(config_.min_bitrate_kbps) * 1000;
75 call_config.bitrate_config.start_bitrate_bps = 82 call_config.bitrate_config.start_bitrate_bps =
76 static_cast<int>(config_.start_bitrate_kbps) * 1000; 83 static_cast<int>(config_.start_bitrate_kbps) * 1000;
77 call_config.bitrate_config.max_bitrate_bps = 84 call_config.bitrate_config.max_bitrate_bps =
78 static_cast<int>(config_.max_bitrate_kbps) * 1000; 85 static_cast<int>(config_.max_bitrate_kbps) * 1000;
79 rtc::scoped_ptr<Call> call(Call::Create(call_config)); 86 rtc::scoped_ptr<Call> call(Call::Create(call_config));
80 87
(...skipping 12 matching lines...) Expand all
93 rtc::scoped_ptr<VideoEncoder> encoder; 100 rtc::scoped_ptr<VideoEncoder> encoder;
94 if (config_.codec == "VP8") { 101 if (config_.codec == "VP8") {
95 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp8)); 102 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp8));
96 } else if (config_.codec == "VP9") { 103 } else if (config_.codec == "VP9") {
97 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp9)); 104 encoder.reset(VideoEncoder::Create(VideoEncoder::kVp9));
98 } else { 105 } else {
99 // Codec not supported. 106 // Codec not supported.
100 RTC_NOTREACHED() << "Codec not supported!"; 107 RTC_NOTREACHED() << "Codec not supported!";
101 return; 108 return;
102 } 109 }
110 const int payload_type =
111 config_.codec == "VP8" ? kVideoPayloadTypeVP8 : kVideoPayloadTypeVP9;
103 send_config.encoder_settings.encoder = encoder.get(); 112 send_config.encoder_settings.encoder = encoder.get();
104 send_config.encoder_settings.payload_name = config_.codec; 113 send_config.encoder_settings.payload_name = config_.codec;
105 send_config.encoder_settings.payload_type = kVideoPayloadType; 114 send_config.encoder_settings.payload_type = payload_type;
106 115
107 VideoEncoderConfig encoder_config(CreateEncoderConfig()); 116 VideoEncoderConfig encoder_config(CreateEncoderConfig());
108 117
109 VideoSendStream* send_stream = 118 VideoSendStream* send_stream =
110 call->CreateVideoSendStream(send_config, encoder_config); 119 call->CreateVideoSendStream(send_config, encoder_config);
111 120
112 rtc::scoped_ptr<test::VideoCapturer> capturer(CreateCapturer(send_stream)); 121 rtc::scoped_ptr<test::VideoCapturer> capturer(CreateCapturer(send_stream));
113 122
114 VideoReceiveStream::Config receive_config; 123 VideoReceiveStream::Config receive_config;
115 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0]; 124 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0];
116 receive_config.rtp.local_ssrc = kReceiverLocalSsrc; 125 receive_config.rtp.local_ssrc = kReceiverLocalSsrc;
117 receive_config.rtp.nack.rtp_history_ms = 1000; 126 receive_config.rtp.nack.rtp_history_ms = 1000;
118 receive_config.rtp.remb = true; 127 receive_config.rtp.remb = true;
119 receive_config.rtp.rtx[kVideoPayloadType].ssrc = kSendRtxSsrc; 128 receive_config.rtp.rtx[payload_type].ssrc = kSendRtxSsrc;
120 receive_config.rtp.rtx[kVideoPayloadType].payload_type = kRtxVideoPayloadType; 129 receive_config.rtp.rtx[payload_type].payload_type = kRtxVideoPayloadType;
121 receive_config.rtp.extensions.push_back( 130 receive_config.rtp.extensions.push_back(
122 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); 131 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId));
123 receive_config.renderer = loopback_video.get(); 132 receive_config.renderer = loopback_video.get();
124 VideoReceiveStream::Decoder decoder = 133 VideoReceiveStream::Decoder decoder =
125 test::CreateMatchingDecoder(send_config.encoder_settings); 134 test::CreateMatchingDecoder(send_config.encoder_settings);
126 receive_config.decoders.push_back(decoder); 135 receive_config.decoders.push_back(decoder);
127 136
128 VideoReceiveStream* receive_stream = 137 VideoReceiveStream* receive_stream =
129 call->CreateVideoReceiveStream(receive_config); 138 call->CreateVideoReceiveStream(receive_config);
130 139
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return encoder_config; 174 return encoder_config;
166 } 175 }
167 176
168 test::VideoCapturer* Loopback::CreateCapturer(VideoSendStream* send_stream) { 177 test::VideoCapturer* Loopback::CreateCapturer(VideoSendStream* send_stream) {
169 return test::VideoCapturer::Create(send_stream->Input(), config_.width, 178 return test::VideoCapturer::Create(send_stream->Input(), config_.width,
170 config_.height, config_.fps, clock_); 179 config_.height, config_.fps, clock_);
171 } 180 }
172 181
173 } // namespace test 182 } // namespace test
174 } // namespace webrtc 183 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698