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

Side by Side Diff: webrtc/test/fake_encoder.cc

Issue 2791273002: Update screen simulcast config and fix periodic encoder param update (Closed)
Patch Set: Created 3 years, 8 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 "webrtc/test/fake_encoder.h" 11 #include "webrtc/test/fake_encoder.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 #include <memory> 16 #include <memory>
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
20 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 20 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
21 #include "webrtc/system_wrappers/include/sleep.h" 21 #include "webrtc/system_wrappers/include/sleep.h"
22 #include "webrtc/test/gtest.h" 22 #include "webrtc/test/gtest.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 namespace test { 25 namespace test {
26 26
27 FakeEncoder::FakeEncoder(Clock* clock) 27 FakeEncoder::FakeEncoder(Clock* clock)
28 : clock_(clock), 28 : clock_(clock),
29 callback_(nullptr), 29 callback_(nullptr),
30 configured_input_framerate_(-1),
30 max_target_bitrate_kbps_(-1), 31 max_target_bitrate_kbps_(-1),
31 last_encode_time_ms_(0) { 32 last_encode_time_ms_(0) {
32 // Generate some arbitrary not-all-zero data 33 // Generate some arbitrary not-all-zero data
33 for (size_t i = 0; i < sizeof(encoded_buffer_); ++i) { 34 for (size_t i = 0; i < sizeof(encoded_buffer_); ++i) {
34 encoded_buffer_[i] = static_cast<uint8_t>(i); 35 encoded_buffer_[i] = static_cast<uint8_t>(i);
35 } 36 }
36 } 37 }
37 38
38 void FakeEncoder::SetMaxBitrate(int max_kbps) { 39 void FakeEncoder::SetMaxBitrate(int max_kbps) {
39 RTC_DCHECK_GE(max_kbps, -1); // max_kbps == -1 disables it. 40 RTC_DCHECK_GE(max_kbps, -1); // max_kbps == -1 disables it.
40 rtc::CritScope cs(&crit_sect_); 41 rtc::CritScope cs(&crit_sect_);
41 max_target_bitrate_kbps_ = max_kbps; 42 max_target_bitrate_kbps_ = max_kbps;
42 } 43 }
43 44
44 int32_t FakeEncoder::InitEncode(const VideoCodec* config, 45 int32_t FakeEncoder::InitEncode(const VideoCodec* config,
45 int32_t number_of_cores, 46 int32_t number_of_cores,
46 size_t max_payload_size) { 47 size_t max_payload_size) {
47 rtc::CritScope cs(&crit_sect_); 48 rtc::CritScope cs(&crit_sect_);
48 config_ = *config; 49 config_ = *config;
49 target_bitrate_.SetBitrate(0, 0, config_.startBitrate * 1000); 50 target_bitrate_.SetBitrate(0, 0, config_.startBitrate * 1000);
51 configured_input_framerate_ = config_.maxFramerate;
50 return 0; 52 return 0;
51 } 53 }
52 54
53 int32_t FakeEncoder::Encode(const VideoFrame& input_image, 55 int32_t FakeEncoder::Encode(const VideoFrame& input_image,
54 const CodecSpecificInfo* codec_specific_info, 56 const CodecSpecificInfo* codec_specific_info,
55 const std::vector<FrameType>* frame_types) { 57 const std::vector<FrameType>* frame_types) {
56 unsigned char max_framerate; 58 unsigned char max_framerate;
57 unsigned char num_simulcast_streams; 59 unsigned char num_simulcast_streams;
58 SimulcastStream simulcast_streams[kMaxSimulcastStreams]; 60 SimulcastStream simulcast_streams[kMaxSimulcastStreams];
59 EncodedImageCallback* callback; 61 EncodedImageCallback* callback;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 int32_t FakeEncoder::Release() { return 0; } 165 int32_t FakeEncoder::Release() { return 0; }
164 166
165 int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int64_t rtt) { 167 int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int64_t rtt) {
166 return 0; 168 return 0;
167 } 169 }
168 170
169 int32_t FakeEncoder::SetRateAllocation(const BitrateAllocation& rate_allocation, 171 int32_t FakeEncoder::SetRateAllocation(const BitrateAllocation& rate_allocation,
170 uint32_t framerate) { 172 uint32_t framerate) {
171 rtc::CritScope cs(&crit_sect_); 173 rtc::CritScope cs(&crit_sect_);
172 target_bitrate_ = rate_allocation; 174 target_bitrate_ = rate_allocation;
175 configured_input_framerate_ = framerate;
173 return 0; 176 return 0;
174 } 177 }
175 178
176 const char* FakeEncoder::kImplementationName = "fake_encoder"; 179 const char* FakeEncoder::kImplementationName = "fake_encoder";
177 const char* FakeEncoder::ImplementationName() const { 180 const char* FakeEncoder::ImplementationName() const {
178 return kImplementationName; 181 return kImplementationName;
179 } 182 }
180 183
184 int FakeEncoder::GetConfiguredInputFramerate() {
185 rtc::CritScope cs(&crit_sect_);
186 return configured_input_framerate_;
187 }
188
181 FakeH264Encoder::FakeH264Encoder(Clock* clock) 189 FakeH264Encoder::FakeH264Encoder(Clock* clock)
182 : FakeEncoder(clock), callback_(nullptr), idr_counter_(0) { 190 : FakeEncoder(clock), callback_(nullptr), idr_counter_(0) {
183 FakeEncoder::RegisterEncodeCompleteCallback(this); 191 FakeEncoder::RegisterEncodeCompleteCallback(this);
184 } 192 }
185 193
186 int32_t FakeH264Encoder::RegisterEncodeCompleteCallback( 194 int32_t FakeH264Encoder::RegisterEncodeCompleteCallback(
187 EncodedImageCallback* callback) { 195 EncodedImageCallback* callback) {
188 rtc::CritScope cs(&local_crit_sect_); 196 rtc::CritScope cs(&local_crit_sect_);
189 callback_ = callback; 197 callback_ = callback;
190 return 0; 198 return 0;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); 358 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
351 359
352 queue1_.reset(); 360 queue1_.reset();
353 queue2_.reset(); 361 queue2_.reset();
354 362
355 return FakeH264Encoder::Release(); 363 return FakeH264Encoder::Release();
356 } 364 }
357 365
358 } // namespace test 366 } // namespace test
359 } // namespace webrtc 367 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698