blob: 94f5fdae66cf183611265cc42b50a4b82a33e936 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org07b45a52012-02-02 08:37:48 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
pbos@webrtc.orgf5d4cb12013-05-17 13:44:48 +000011#include "webrtc/video_engine/vie_encoder.h"
mflodman@webrtc.org84d17832011-12-01 17:02:23 +000012
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000013#include <assert.h>
14
stefan@webrtc.orgc3cc3752013-06-04 09:36:56 +000015#include <algorithm>
niklase@google.com470e71d2011-07-07 08:21:25 +000016
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +000017#include "webrtc/base/checks.h"
Peter Boström415d2cd2015-10-26 11:35:17 +010018#include "webrtc/base/logging.h"
tommie4f96502015-10-20 23:00:48 -070019#include "webrtc/base/trace_event.h"
mflodman0e7e2592015-11-12 21:02:42 -080020#include "webrtc/call/bitrate_allocator.h"
kjellander6f8ce062015-11-16 13:52:24 -080021#include "webrtc/common_video/include/video_image.h"
pbos@webrtc.orgf5d4cb12013-05-17 13:44:48 +000022#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
pbos@webrtc.org273a4142014-12-01 15:23:21 +000023#include "webrtc/frame_callback.h"
Peter Boström8e4e8b02015-09-15 15:08:03 +020024#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
Henrik Kjellander0b9e29c2015-11-16 11:12:24 +010025#include "webrtc/modules/pacing/paced_sender.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010026#include "webrtc/modules/utility/include/process_thread.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010027#include "webrtc/modules/video_coding/include/video_codec_interface.h"
28#include "webrtc/modules/video_coding/include/video_coding.h"
29#include "webrtc/modules/video_coding/include/video_coding_defines.h"
30#include "webrtc/modules/video_coding/encoded_frame.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010031#include "webrtc/system_wrappers/include/clock.h"
32#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
33#include "webrtc/system_wrappers/include/metrics.h"
34#include "webrtc/system_wrappers/include/tick_util.h"
pbos@webrtc.org273a4142014-12-01 15:23:21 +000035#include "webrtc/video/send_statistics_proxy.h"
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +000036#include "webrtc/video_engine/payload_router.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000037
niklase@google.com470e71d2011-07-07 08:21:25 +000038namespace webrtc {
39
pwestin@webrtc.org52b4e882013-05-02 19:02:17 +000040// Margin on when we pause the encoder when the pacing buffer overflows relative
41// to the configured buffer delay.
42static const float kEncoderPausePacerMargin = 2.0f;
43
pwestin@webrtc.org91563e42013-04-25 22:20:08 +000044// Don't stop the encoder unless the delay is above this configured value.
45static const int kMinPacingDelayMs = 200;
46
stefan@webrtc.org3e005052013-10-18 15:05:29 +000047static const float kStopPaddingThresholdMs = 2000;
48
mflodmanc4a1c372015-11-06 04:33:51 -080049static const int kMinKeyFrameRequestIntervalMs = 300;
50
stefan@webrtc.orgb2c8a952013-09-06 13:58:01 +000051std::vector<uint32_t> AllocateStreamBitrates(
52 uint32_t total_bitrate,
53 const SimulcastStream* stream_configs,
54 size_t number_of_streams) {
55 if (number_of_streams == 0) {
56 std::vector<uint32_t> stream_bitrates(1, 0);
57 stream_bitrates[0] = total_bitrate;
58 return stream_bitrates;
59 }
60 std::vector<uint32_t> stream_bitrates(number_of_streams, 0);
61 uint32_t bitrate_remainder = total_bitrate;
62 for (size_t i = 0; i < stream_bitrates.size() && bitrate_remainder > 0; ++i) {
63 if (stream_configs[i].maxBitrate * 1000 > bitrate_remainder) {
64 stream_bitrates[i] = bitrate_remainder;
65 } else {
66 stream_bitrates[i] = stream_configs[i].maxBitrate * 1000;
67 }
68 bitrate_remainder -= stream_bitrates[i];
69 }
70 return stream_bitrates;
71}
72
stefan@webrtc.org439be292012-02-16 14:45:37 +000073class QMVideoSettingsCallback : public VCMQMSettingsCallback {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +000074 public:
marpan@webrtc.orgefd01fd2012-04-18 15:56:34 +000075 explicit QMVideoSettingsCallback(VideoProcessingModule* vpm);
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000076
stefan@webrtc.org439be292012-02-16 14:45:37 +000077 ~QMVideoSettingsCallback();
niklase@google.com470e71d2011-07-07 08:21:25 +000078
mflodman@webrtc.org84d17832011-12-01 17:02:23 +000079 // Update VPM with QM (quality modes: frame size & frame rate) settings.
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000080 int32_t SetVideoQMSettings(const uint32_t frame_rate,
81 const uint32_t width,
82 const uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000083
jackychen6e2ce6e2015-07-13 16:26:33 -070084 // Update target frame rate.
85 void SetTargetFramerate(int frame_rate);
86
mflodman@webrtc.org84d17832011-12-01 17:02:23 +000087 private:
88 VideoProcessingModule* vpm_;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +000089};
niklase@google.com470e71d2011-07-07 08:21:25 +000090
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000091class ViEBitrateObserver : public BitrateObserver {
92 public:
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +000093 explicit ViEBitrateObserver(ViEEncoder* owner)
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000094 : owner_(owner) {
95 }
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000096 virtual ~ViEBitrateObserver() {}
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +000097 // Implements BitrateObserver.
stefan@webrtc.orgedeea912014-12-08 19:46:23 +000098 virtual void OnNetworkChanged(uint32_t bitrate_bps,
99 uint8_t fraction_lost,
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000100 int64_t rtt) {
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +0000101 owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt);
102 }
103 private:
104 ViEEncoder* owner_;
105};
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
mflodman0dbf0092015-10-19 08:12:12 -0700107ViEEncoder::ViEEncoder(uint32_t number_of_cores,
Peter Boström7083e112015-09-22 16:28:51 +0200108 ProcessThread* module_process_thread,
109 SendStatisticsProxy* stats_proxy,
110 I420FrameCallback* pre_encode_callback,
Stefan Holmere5904162015-03-26 11:11:06 +0100111 PacedSender* pacer,
Peter Boström8e4e8b02015-09-15 15:08:03 +0200112 BitrateAllocator* bitrate_allocator)
mflodman0dbf0092015-10-19 08:12:12 -0700113 : number_of_cores_(number_of_cores),
Peter Boströmf4aa4c22015-09-18 12:24:25 +0200114 vpm_(VideoProcessingModule::Create()),
mflodmanfcf54bd2015-04-14 21:28:08 +0200115 qm_callback_(new QMVideoSettingsCallback(vpm_.get())),
116 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
117 this,
118 qm_callback_.get())),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000119 send_payload_router_(NULL),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000120 data_cs_(CriticalSectionWrapper::CreateCriticalSection()),
Peter Boström7083e112015-09-22 16:28:51 +0200121 stats_proxy_(stats_proxy),
122 pre_encode_callback_(pre_encode_callback),
Stefan Holmere5904162015-03-26 11:11:06 +0100123 pacer_(pacer),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000124 bitrate_allocator_(bitrate_allocator),
Noah Richards099323e2015-04-15 09:14:12 -0700125 time_of_last_frame_activity_ms_(0),
Peter Boströmd153a372015-11-10 15:27:12 +0000126 encoder_config_(),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000127 min_transmit_bitrate_kbps_(0),
pbos@webrtc.org143451d2015-03-18 14:40:03 +0000128 last_observed_bitrate_bps_(0),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000129 target_delay_ms_(0),
130 network_is_transmitting_(true),
131 encoder_paused_(false),
132 encoder_paused_and_dropped_frame_(false),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000133 module_process_thread_(module_process_thread),
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000134 has_received_sli_(false),
135 picture_id_sli_(0),
136 has_received_rpsi_(false),
137 picture_id_rpsi_(0),
asaperssondec5ebf2015-10-05 02:36:17 -0700138 video_suspended_(false) {
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +0000139 bitrate_observer_.reset(new ViEBitrateObserver(this));
wu@webrtc.org5d8c1022012-04-10 16:54:05 +0000140}
141
142bool ViEEncoder::Init() {
mflodmanfcf54bd2015-04-14 21:28:08 +0200143 vpm_->EnableTemporalDecimation(true);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000144
145 // Enable/disable content analysis: off by default for now.
mflodmanfcf54bd2015-04-14 21:28:08 +0200146 vpm_->EnableContentAnalysis(false);
niklase@google.com470e71d2011-07-07 08:21:25 +0000147
mflodmanfcf54bd2015-04-14 21:28:08 +0200148 if (vcm_->RegisterTransportCallback(this) != 0) {
wu@webrtc.org5d8c1022012-04-10 16:54:05 +0000149 return false;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000150 }
mflodmanfcf54bd2015-04-14 21:28:08 +0200151 if (vcm_->RegisterSendStatisticsCallback(this) != 0) {
wu@webrtc.org5d8c1022012-04-10 16:54:05 +0000152 return false;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000153 }
wu@webrtc.org5d8c1022012-04-10 16:54:05 +0000154 return true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000155}
156
mflodman@webrtc.org96abda02015-02-25 13:50:10 +0000157void ViEEncoder::StartThreadsAndSetSharedMembers(
Peter Boström26b08602015-06-04 15:18:17 +0200158 rtc::scoped_refptr<PayloadRouter> send_payload_router,
mflodman@webrtc.org96abda02015-02-25 13:50:10 +0000159 VCMProtectionCallback* vcm_protection_callback) {
henrikg91d6ede2015-09-17 00:24:34 -0700160 RTC_DCHECK(send_payload_router_ == NULL);
mflodman@webrtc.org96abda02015-02-25 13:50:10 +0000161
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +0000162 send_payload_router_ = send_payload_router;
mflodmanfcf54bd2015-04-14 21:28:08 +0200163 vcm_->RegisterProtectionCallback(vcm_protection_callback);
Peter Boström7083e112015-09-22 16:28:51 +0200164 module_process_thread_->RegisterModule(vcm_.get());
mflodman@webrtc.org290cb562015-02-17 10:15:06 +0000165}
166
mflodman@webrtc.org96abda02015-02-25 13:50:10 +0000167void ViEEncoder::StopThreadsAndRemoveSharedMembers() {
mflodmanfcf54bd2015-04-14 21:28:08 +0200168 if (bitrate_allocator_)
169 bitrate_allocator_->RemoveBitrateObserver(bitrate_observer_.get());
Peter Boström7083e112015-09-22 16:28:51 +0200170 module_process_thread_->DeRegisterModule(vcm_.get());
171 module_process_thread_->DeRegisterModule(vpm_.get());
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +0000172}
173
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000174ViEEncoder::~ViEEncoder() {
asapersson@webrtc.org96dc6852014-11-03 14:40:38 +0000175}
176
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000177void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) {
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000178 {
179 CriticalSectionScoped cs(data_cs_.get());
180 network_is_transmitting_ = is_transmitting;
181 }
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000182}
183
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000184void ViEEncoder::Pause() {
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +0000185 CriticalSectionScoped cs(data_cs_.get());
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000186 encoder_paused_ = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000187}
188
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000189void ViEEncoder::Restart() {
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +0000190 CriticalSectionScoped cs(data_cs_.get());
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000191 encoder_paused_ = false;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000192}
193
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000194uint8_t ViEEncoder::NumberOfCodecs() {
mflodmanfcf54bd2015-04-14 21:28:08 +0200195 return vcm_->NumberOfCodecs();
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000196}
197
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000198int32_t ViEEncoder::GetCodec(uint8_t list_index, VideoCodec* video_codec) {
mflodmanfcf54bd2015-04-14 21:28:08 +0200199 if (vcm_->Codec(list_index, video_codec) != 0) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000200 return -1;
201 }
202 return 0;
203}
204
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000205int32_t ViEEncoder::RegisterExternalEncoder(webrtc::VideoEncoder* encoder,
206 uint8_t pl_type,
207 bool internal_source) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000208 if (encoder == NULL)
209 return -1;
210
mflodmanfcf54bd2015-04-14 21:28:08 +0200211 if (vcm_->RegisterExternalEncoder(encoder, pl_type, internal_source) !=
mflodman@webrtc.org5574dac2014-04-07 10:56:31 +0000212 VCM_OK) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000213 return -1;
214 }
215 return 0;
216}
217
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000218int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) {
mflodmanfcf54bd2015-04-14 21:28:08 +0200219 if (vcm_->RegisterExternalEncoder(NULL, pl_type) != VCM_OK) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000220 return -1;
221 }
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000222 return 0;
223}
224
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000225int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) {
henrikg91d6ede2015-09-17 00:24:34 -0700226 RTC_DCHECK(send_payload_router_ != NULL);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000227 // Setting target width and height for VPM.
mflodmanfcf54bd2015-04-14 21:28:08 +0200228 if (vpm_->SetTargetResolution(video_codec.width, video_codec.height,
229 video_codec.maxFramerate) != VPM_OK) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000230 return -1;
231 }
232
Peter Boströmd153a372015-11-10 15:27:12 +0000233 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged
234 // that makes use of the number of simulcast streams configured).
stefan@webrtc.org9075d512014-02-14 09:45:58 +0000235 {
236 CriticalSectionScoped cs(data_cs_.get());
Peter Boströmd153a372015-11-10 15:27:12 +0000237 encoder_config_ = video_codec;
stefan@webrtc.org9075d512014-02-14 09:45:58 +0000238 }
Stefan Holmere5904162015-03-26 11:11:06 +0100239
240 // Add a bitrate observer to the allocator and update the start, max and
241 // min bitrates of the bitrate controller as needed.
Peter Boström8e4e8b02015-09-15 15:08:03 +0200242 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver(
243 bitrate_observer_.get(), video_codec.minBitrate * 1000,
244 video_codec.maxBitrate * 1000);
Stefan Holmere5904162015-03-26 11:11:06 +0100245
246 webrtc::VideoCodec modified_video_codec = video_codec;
247 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000;
248
mflodman@webrtc.orga4ef2ce2015-02-12 09:54:18 +0000249 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength();
mflodmanfcf54bd2015-04-14 21:28:08 +0200250 if (vcm_->RegisterSendCodec(&modified_video_codec, number_of_cores_,
Peter Boströmae37abb2015-06-18 19:00:34 +0200251 static_cast<uint32_t>(max_data_payload_length)) !=
252 VCM_OK) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000253 return -1;
254 }
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000255 return 0;
256}
257
stefana4a8d4a2015-07-15 04:39:22 -0700258int ViEEncoder::GetPaddingNeededBps() const {
Noah Richards099323e2015-04-15 09:14:12 -0700259 int64_t time_of_last_frame_activity_ms;
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000260 int min_transmit_bitrate_bps;
stefana4a8d4a2015-07-15 04:39:22 -0700261 int bitrate_bps;
Peter Boströmd153a372015-11-10 15:27:12 +0000262 VideoCodec send_codec;
henrik.lundin@webrtc.org331d4402013-11-21 14:05:40 +0000263 {
264 CriticalSectionScoped cs(data_cs_.get());
Peter Boströmd153a372015-11-10 15:27:12 +0000265 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 ||
266 video_suspended_ || min_transmit_bitrate_kbps_ > 0;
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000267 if (!send_padding)
268 return 0;
Noah Richards099323e2015-04-15 09:14:12 -0700269 time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_;
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000270 min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_;
stefana4a8d4a2015-07-15 04:39:22 -0700271 bitrate_bps = last_observed_bitrate_bps_;
Peter Boströmd153a372015-11-10 15:27:12 +0000272 send_codec = encoder_config_;
henrik.lundin@webrtc.org331d4402013-11-21 14:05:40 +0000273 }
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000274
mflodmanfcf54bd2015-04-14 21:28:08 +0200275 bool video_is_suspended = vcm_->VideoSuspended();
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000276
277 // Find the max amount of padding we can allow ourselves to send at this
278 // point, based on which streams are currently active and what our current
279 // available bandwidth is.
280 int pad_up_to_bitrate_bps = 0;
281 if (send_codec.numberOfSimulcastStreams == 0) {
282 pad_up_to_bitrate_bps = send_codec.minBitrate * 1000;
283 } else {
stefana4a8d4a2015-07-15 04:39:22 -0700284 SimulcastStream* stream_configs = send_codec.simulcastStream;
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000285 pad_up_to_bitrate_bps =
286 stream_configs[send_codec.numberOfSimulcastStreams - 1].minBitrate *
287 1000;
288 for (int i = 0; i < send_codec.numberOfSimulcastStreams - 1; ++i) {
289 pad_up_to_bitrate_bps += stream_configs[i].targetBitrate * 1000;
290 }
stefan@webrtc.org508a84b2013-06-17 12:53:37 +0000291 }
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000292
293 // Disable padding if only sending one stream and video isn't suspended and
294 // min-transmit bitrate isn't used (applied later).
295 if (!video_is_suspended && send_codec.numberOfSimulcastStreams <= 1)
296 pad_up_to_bitrate_bps = 0;
297
298 // The amount of padding should decay to zero if no frames are being
Noah Richards099323e2015-04-15 09:14:12 -0700299 // captured/encoded unless a min-transmit bitrate is used.
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000300 int64_t now_ms = TickTime::MillisecondTimestamp();
Noah Richards099323e2015-04-15 09:14:12 -0700301 if (now_ms - time_of_last_frame_activity_ms > kStopPaddingThresholdMs)
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000302 pad_up_to_bitrate_bps = 0;
303
304 // Pad up to min bitrate.
305 if (pad_up_to_bitrate_bps < min_transmit_bitrate_bps)
306 pad_up_to_bitrate_bps = min_transmit_bitrate_bps;
307
308 // Padding may never exceed bitrate estimate.
309 if (pad_up_to_bitrate_bps > bitrate_bps)
310 pad_up_to_bitrate_bps = bitrate_bps;
311
312 return pad_up_to_bitrate_bps;
stefan@webrtc.org508a84b2013-06-17 12:53:37 +0000313}
314
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000315bool ViEEncoder::EncoderPaused() const {
pwestin@webrtc.org91563e42013-04-25 22:20:08 +0000316 // Pause video if paused by caller or as long as the network is down or the
317 // pacer queue has grown too large in buffered mode.
318 if (encoder_paused_) {
319 return true;
320 }
321 if (target_delay_ms_ > 0) {
322 // Buffered mode.
323 // TODO(pwestin): Workaround until nack is configured as a time and not
324 // number of packets.
Stefan Holmere5904162015-03-26 11:11:06 +0100325 return pacer_->QueueInMs() >=
326 std::max(
327 static_cast<int>(target_delay_ms_ * kEncoderPausePacerMargin),
328 kMinPacingDelayMs);
pwestin@webrtc.org91563e42013-04-25 22:20:08 +0000329 }
Stefan Holmere5904162015-03-26 11:11:06 +0100330 if (pacer_->ExpectedQueueTimeMs() > PacedSender::kDefaultMaxQueueLengthMs) {
sprang@webrtc.orgdcebf2d2014-11-04 16:27:16 +0000331 // Too much data in pacer queue, drop frame.
332 return true;
333 }
pwestin@webrtc.org91563e42013-04-25 22:20:08 +0000334 return !network_is_transmitting_;
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000335}
336
sprang@webrtc.orgdcebf2d2014-11-04 16:27:16 +0000337void ViEEncoder::TraceFrameDropStart() {
338 // Start trace event only on the first frame after encoder is paused.
339 if (!encoder_paused_and_dropped_frame_) {
340 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this);
341 }
342 encoder_paused_and_dropped_frame_ = true;
343 return;
344}
345
346void ViEEncoder::TraceFrameDropEnd() {
347 // End trace event on first frame after encoder resumes, if frame was dropped.
348 if (encoder_paused_and_dropped_frame_) {
349 TRACE_EVENT_ASYNC_END0("webrtc", "EncoderPaused", this);
350 }
351 encoder_paused_and_dropped_frame_ = false;
352}
353
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700354void ViEEncoder::DeliverFrame(VideoFrame video_frame) {
henrikg91d6ede2015-09-17 00:24:34 -0700355 RTC_DCHECK(send_payload_router_ != NULL);
mflodman@webrtc.org47d657b2015-02-19 10:29:32 +0000356 if (!send_payload_router_->active()) {
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +0000357 // We've paused or we have no channels attached, don't waste resources on
358 // encoding.
wuchengli@chromium.orgac4b87c2014-03-19 03:44:20 +0000359 return;
360 }
Peter Boströmd153a372015-11-10 15:27:12 +0000361 VideoCodecType codec_type;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000362 {
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +0000363 CriticalSectionScoped cs(data_cs_.get());
Noah Richards099323e2015-04-15 09:14:12 -0700364 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
pwestin@webrtc.org52b4e882013-05-02 19:02:17 +0000365 if (EncoderPaused()) {
sprang@webrtc.orgdcebf2d2014-11-04 16:27:16 +0000366 TraceFrameDropStart();
pwestin@webrtc.org52b4e882013-05-02 19:02:17 +0000367 return;
368 }
sprang@webrtc.orgdcebf2d2014-11-04 16:27:16 +0000369 TraceFrameDropEnd();
Peter Boströmd153a372015-11-10 15:27:12 +0000370 codec_type = encoder_config_.codecType;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000371 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000372
Magnus Jedvert26679d62015-04-07 14:07:41 +0200373 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(),
hclam@chromium.org1a7b9b92013-07-08 21:31:18 +0000374 "Encode");
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700375 VideoFrame* decimated_frame = NULL;
wuchengli@chromium.orgf425b552014-06-20 12:04:05 +0000376 // TODO(wuchengli): support texture frames.
Magnus Jedvert26679d62015-04-07 14:07:41 +0200377 if (video_frame.native_handle() == NULL) {
wuchengli@chromium.orgf425b552014-06-20 12:04:05 +0000378 // Pass frame via preprocessor.
mflodmanfcf54bd2015-04-14 21:28:08 +0200379 const int ret = vpm_->PreprocessFrame(video_frame, &decimated_frame);
wuchengli@chromium.orgf425b552014-06-20 12:04:05 +0000380 if (ret == 1) {
381 // Drop this frame.
382 return;
383 }
384 if (ret != VPM_OK) {
385 return;
386 }
pwestin@webrtc.org2f476ed2012-10-30 16:21:52 +0000387 }
pbos@webrtc.orgfe1ef932013-10-21 10:34:43 +0000388
Magnus Jedvert26679d62015-04-07 14:07:41 +0200389 // If we haven't resampled the frame and we have a FrameCallback, we need to
390 // make a deep copy of |video_frame|.
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700391 VideoFrame copied_frame;
Peter Boström7083e112015-09-22 16:28:51 +0200392 if (pre_encode_callback_) {
393 // If the frame was not resampled or scaled => use copy of original.
394 if (decimated_frame == NULL) {
395 copied_frame.CopyFrame(video_frame);
396 decimated_frame = &copied_frame;
Magnus Jedvert26679d62015-04-07 14:07:41 +0200397 }
Peter Boström7083e112015-09-22 16:28:51 +0200398 pre_encode_callback_->FrameCallback(decimated_frame);
pbos@webrtc.orgfe1ef932013-10-21 10:34:43 +0000399 }
400
Magnus Jedvert26679d62015-04-07 14:07:41 +0200401 // If the frame was not resampled, scaled, or touched by FrameCallback => use
402 // original. The frame is const from here.
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700403 const VideoFrame* output_frame =
Magnus Jedvert26679d62015-04-07 14:07:41 +0200404 (decimated_frame != NULL) ? decimated_frame : &video_frame;
405
niklase@google.com470e71d2011-07-07 08:21:25 +0000406#ifdef VIDEOCODEC_VP8
Peter Boströmd153a372015-11-10 15:27:12 +0000407 if (codec_type == webrtc::kVideoCodecVP8) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000408 webrtc::CodecSpecificInfo codec_specific_info;
409 codec_specific_info.codecType = webrtc::kVideoCodecVP8;
stefan@webrtc.org7af12be2014-07-09 14:46:31 +0000410 {
411 CriticalSectionScoped cs(data_cs_.get());
412 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
413 has_received_rpsi_;
414 codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
415 has_received_sli_;
416 codec_specific_info.codecSpecific.VP8.pictureIdRPSI =
417 picture_id_rpsi_;
418 codec_specific_info.codecSpecific.VP8.pictureIdSLI =
419 picture_id_sli_;
420 has_received_sli_ = false;
421 has_received_rpsi_ = false;
422 }
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000423
mflodmanfcf54bd2015-04-14 21:28:08 +0200424 vcm_->AddVideoFrame(*output_frame, vpm_->ContentMetrics(),
425 &codec_specific_info);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000426 return;
427 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000428#endif
mflodmanfcf54bd2015-04-14 21:28:08 +0200429 vcm_->AddVideoFrame(*output_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +0000430}
niklase@google.com470e71d2011-07-07 08:21:25 +0000431
pwestin@webrtc.orgce330352012-04-12 06:59:14 +0000432int ViEEncoder::SendKeyFrame() {
mflodmanfcf54bd2015-04-14 21:28:08 +0200433 return vcm_->IntraFrameRequest(0);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000434}
435
pbos@webrtc.org143451d2015-03-18 14:40:03 +0000436uint32_t ViEEncoder::LastObservedBitrateBps() const {
437 CriticalSectionScoped cs(data_cs_.get());
438 return last_observed_bitrate_bps_;
439}
440
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000441int ViEEncoder::CodecTargetBitrate(uint32_t* bitrate) const {
mflodmanfcf54bd2015-04-14 21:28:08 +0200442 if (vcm_->Bitrate(bitrate) != 0)
stefan@webrtc.org439be292012-02-16 14:45:37 +0000443 return -1;
444 return 0;
stefan@webrtc.org07b45a52012-02-02 08:37:48 +0000445}
446
Peter Boströmd153a372015-11-10 15:27:12 +0000447void ViEEncoder::SetProtectionMethod(bool nack, bool fec) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000448 // Set Video Protection for VCM.
pbosba8c15b2015-07-14 09:36:34 -0700449 VCMVideoProtection protection_mode;
Peter Boströmd153a372015-11-10 15:27:12 +0000450 if (fec) {
pbosba8c15b2015-07-14 09:36:34 -0700451 protection_mode =
Peter Boströmd153a372015-11-10 15:27:12 +0000452 nack ? webrtc::kProtectionNackFEC : kProtectionFEC;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000453 } else {
Peter Boströmd153a372015-11-10 15:27:12 +0000454 protection_mode = nack ? kProtectionNack : kProtectionNone;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000455 }
pbosba8c15b2015-07-14 09:36:34 -0700456 vcm_->SetVideoProtection(protection_mode, true);
niklase@google.com470e71d2011-07-07 08:21:25 +0000457}
458
mikhal@webrtc.orgef9f76a2013-02-15 23:22:18 +0000459void ViEEncoder::SetSenderBufferingMode(int target_delay_ms) {
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000460 {
461 CriticalSectionScoped cs(data_cs_.get());
462 target_delay_ms_ = target_delay_ms;
463 }
mikhal@webrtc.org3d305c62013-02-10 18:42:55 +0000464 if (target_delay_ms > 0) {
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +0000465 // Disable external frame-droppers.
mflodmanfcf54bd2015-04-14 21:28:08 +0200466 vcm_->EnableFrameDropper(false);
467 vpm_->EnableTemporalDecimation(false);
mikhal@webrtc.org3d305c62013-02-10 18:42:55 +0000468 } else {
mikhal@webrtc.orgef9f76a2013-02-15 23:22:18 +0000469 // Real-time mode - enable frame droppers.
mflodmanfcf54bd2015-04-14 21:28:08 +0200470 vpm_->EnableTemporalDecimation(true);
471 vcm_->EnableFrameDropper(true);
mikhal@webrtc.org3d305c62013-02-10 18:42:55 +0000472 }
473}
474
pbos@webrtc.org891d4832015-02-26 13:15:22 +0000475void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) {
Peter Boström7083e112015-09-22 16:28:51 +0200476 if (stats_proxy_)
477 stats_proxy_->OnSetRates(bitrate_bps, framerate);
pbos@webrtc.org891d4832015-02-26 13:15:22 +0000478}
479
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000480int32_t ViEEncoder::SendData(
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000481 const uint8_t payload_type,
pbos@webrtc.org273a4142014-12-01 15:23:21 +0000482 const EncodedImage& encoded_image,
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000483 const webrtc::RTPFragmentationHeader& fragmentation_header,
484 const RTPVideoHeader* rtp_video_hdr) {
henrikg91d6ede2015-09-17 00:24:34 -0700485 RTC_DCHECK(send_payload_router_ != NULL);
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +0000486
pbos@webrtc.org891d4832015-02-26 13:15:22 +0000487 {
Noah Richards099323e2015-04-15 09:14:12 -0700488 CriticalSectionScoped cs(data_cs_.get());
489 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
490 }
491
Peter Boström7083e112015-09-22 16:28:51 +0200492 if (stats_proxy_ != NULL)
493 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr);
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +0000494
495 return send_payload_router_->RoutePayload(
pbos22993e12015-10-19 02:39:06 -0700496 encoded_image._frameType, payload_type, encoded_image._timeStamp,
497 encoded_image.capture_time_ms_, encoded_image._buffer,
498 encoded_image._length, &fragmentation_header, rtp_video_hdr)
499 ? 0
500 : -1;
niklase@google.com470e71d2011-07-07 08:21:25 +0000501}
502
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000503int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
504 const uint32_t frame_rate) {
Peter Boström7083e112015-09-22 16:28:51 +0200505 if (stats_proxy_)
506 stats_proxy_->OnOutgoingRate(frame_rate, bit_rate);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000507 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000508}
509
andrew@webrtc.org96636862012-09-20 23:33:17 +0000510void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/,
511 uint8_t picture_id) {
stefan@webrtc.org7af12be2014-07-09 14:46:31 +0000512 CriticalSectionScoped cs(data_cs_.get());
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000513 picture_id_sli_ = picture_id;
514 has_received_sli_ = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000515}
516
andrew@webrtc.org96636862012-09-20 23:33:17 +0000517void ViEEncoder::OnReceivedRPSI(uint32_t /*ssrc*/,
518 uint64_t picture_id) {
stefan@webrtc.org7af12be2014-07-09 14:46:31 +0000519 CriticalSectionScoped cs(data_cs_.get());
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000520 picture_id_rpsi_ = picture_id;
521 has_received_rpsi_ = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000522}
523
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000524void ViEEncoder::OnReceivedIntraFrameRequest(uint32_t ssrc) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000525 // Key frame request from remote side, signal to VCM.
justinlin@chromium.org7bfb3a32013-05-13 22:59:00 +0000526 TRACE_EVENT0("webrtc", "OnKeyFrameRequest");
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000527
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000528 int idx = 0;
529 {
530 CriticalSectionScoped cs(data_cs_.get());
Peter Boström5cb9ce42015-05-05 15:16:30 +0200531 auto stream_it = ssrc_streams_.find(ssrc);
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000532 if (stream_it == ssrc_streams_.end()) {
mflodman@webrtc.orgd73527c2012-12-20 09:26:17 +0000533 LOG_F(LS_WARNING) << "ssrc not found: " << ssrc << ", map size "
534 << ssrc_streams_.size();
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000535 return;
536 }
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000537 std::map<unsigned int, int64_t>::iterator time_it =
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000538 time_last_intra_request_ms_.find(ssrc);
539 if (time_it == time_last_intra_request_ms_.end()) {
540 time_last_intra_request_ms_[ssrc] = 0;
541 }
542
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000543 int64_t now = TickTime::MillisecondTimestamp();
mflodmanc4a1c372015-11-06 04:33:51 -0800544 if (time_last_intra_request_ms_[ssrc] + kMinKeyFrameRequestIntervalMs
545 > now) {
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000546 return;
547 }
548 time_last_intra_request_ms_[ssrc] = now;
549 idx = stream_it->second;
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000550 }
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000551 // Release the critsect before triggering key frame.
mflodmanfcf54bd2015-04-14 21:28:08 +0200552 vcm_->IntraFrameRequest(idx);
niklase@google.com470e71d2011-07-07 08:21:25 +0000553}
554
mflodman@webrtc.orgaca26292012-10-05 16:17:41 +0000555void ViEEncoder::OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) {
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000556 CriticalSectionScoped cs(data_cs_.get());
557 std::map<unsigned int, int>::iterator it = ssrc_streams_.find(old_ssrc);
558 if (it == ssrc_streams_.end()) {
559 return;
560 }
561
562 ssrc_streams_[new_ssrc] = it->second;
563 ssrc_streams_.erase(it);
564
565 std::map<unsigned int, int64_t>::iterator time_it =
566 time_last_intra_request_ms_.find(old_ssrc);
567 int64_t last_intra_request_ms = 0;
568 if (time_it != time_last_intra_request_ms_.end()) {
569 last_intra_request_ms = time_it->second;
570 time_last_intra_request_ms_.erase(time_it);
571 }
572 time_last_intra_request_ms_[new_ssrc] = last_intra_request_ms;
573}
574
Peter Boströmd153a372015-11-10 15:27:12 +0000575void ViEEncoder::SetSsrcs(const std::vector<uint32_t>& ssrcs) {
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000576 CriticalSectionScoped cs(data_cs_.get());
577 ssrc_streams_.clear();
578 time_last_intra_request_ms_.clear();
579 int idx = 0;
Peter Boström5cb9ce42015-05-05 15:16:30 +0200580 for (uint32_t ssrc : ssrcs) {
581 ssrc_streams_[ssrc] = idx++;
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000582 }
mflodman@webrtc.orgaca26292012-10-05 16:17:41 +0000583}
584
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000585void ViEEncoder::SetMinTransmitBitrate(int min_transmit_bitrate_kbps) {
586 assert(min_transmit_bitrate_kbps >= 0);
587 CriticalSectionScoped crit(data_cs_.get());
588 min_transmit_bitrate_kbps_ = min_transmit_bitrate_kbps;
589}
590
pwestin@webrtc.org49888ce2012-04-27 05:25:53 +0000591// Called from ViEBitrateObserver.
stefan@webrtc.orgedeea912014-12-08 19:46:23 +0000592void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps,
593 uint8_t fraction_lost,
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000594 int64_t round_trip_time_ms) {
mflodman@webrtc.org5574dac2014-04-07 10:56:31 +0000595 LOG(LS_VERBOSE) << "OnNetworkChanged, bitrate" << bitrate_bps
mflodman8602a3d2015-05-20 15:54:42 -0700596 << " packet loss " << static_cast<int>(fraction_lost)
mflodman@webrtc.org5574dac2014-04-07 10:56:31 +0000597 << " rtt " << round_trip_time_ms;
henrikg91d6ede2015-09-17 00:24:34 -0700598 RTC_DCHECK(send_payload_router_ != NULL);
mflodmanfcf54bd2015-04-14 21:28:08 +0200599 vcm_->SetChannelParameters(bitrate_bps, fraction_lost, round_trip_time_ms);
600 bool video_is_suspended = vcm_->VideoSuspended();
Peter Boströmd153a372015-11-10 15:27:12 +0000601 bool video_suspension_changed;
stefan@webrtc.org508a84b2013-06-17 12:53:37 +0000602 VideoCodec send_codec;
Peter Boströmd153a372015-11-10 15:27:12 +0000603 uint32_t first_ssrc;
604 {
605 CriticalSectionScoped cs(data_cs_.get());
606 last_observed_bitrate_bps_ = bitrate_bps;
607 video_suspension_changed = video_suspended_ != video_is_suspended;
608 video_suspended_ = video_is_suspended;
609 send_codec = encoder_config_;
610 first_ssrc = ssrc_streams_.begin()->first;
stefan@webrtc.org508a84b2013-06-17 12:53:37 +0000611 }
Peter Boströmd153a372015-11-10 15:27:12 +0000612
stefan@webrtc.orgb2c8a952013-09-06 13:58:01 +0000613 SimulcastStream* stream_configs = send_codec.simulcastStream;
614 // Allocate the bandwidth between the streams.
615 std::vector<uint32_t> stream_bitrates = AllocateStreamBitrates(
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000616 bitrate_bps, stream_configs, send_codec.numberOfSimulcastStreams);
617 send_payload_router_->SetTargetSendBitrates(stream_bitrates);
pbos@webrtc.org709e2972014-03-19 10:59:52 +0000618
Peter Boströmd153a372015-11-10 15:27:12 +0000619 if (!video_suspension_changed)
620 return;
Peter Boström7083e112015-09-22 16:28:51 +0200621 // Video suspend-state changed, inform codec observer.
Peter Boströmd153a372015-11-10 15:27:12 +0000622 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended
623 << " for ssrc " << first_ssrc;
Peter Boström7083e112015-09-22 16:28:51 +0200624 if (stats_proxy_)
625 stats_proxy_->OnSuspendChange(video_is_suspended);
niklase@google.com470e71d2011-07-07 08:21:25 +0000626}
627
henrik.lundin@webrtc.orgce8e0932013-11-18 12:18:43 +0000628void ViEEncoder::SuspendBelowMinBitrate() {
mflodmanfcf54bd2015-04-14 21:28:08 +0200629 vcm_->SuspendBelowMinBitrate();
stefan@webrtc.org792f1a12015-03-04 12:24:26 +0000630 bitrate_allocator_->EnforceMinBitrate(false);
henrik.lundin@webrtc.org7ea4f242013-10-02 13:34:26 +0000631}
632
sprang@webrtc.org40709352013-11-26 11:41:59 +0000633void ViEEncoder::RegisterPostEncodeImageCallback(
634 EncodedImageCallback* post_encode_callback) {
mflodmanfcf54bd2015-04-14 21:28:08 +0200635 vcm_->RegisterPostEncodeImageCallback(post_encode_callback);
sprang@webrtc.org40709352013-11-26 11:41:59 +0000636}
637
marpan@webrtc.orgefd01fd2012-04-18 15:56:34 +0000638QMVideoSettingsCallback::QMVideoSettingsCallback(VideoProcessingModule* vpm)
639 : vpm_(vpm) {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000640}
niklase@google.com470e71d2011-07-07 08:21:25 +0000641
stefan@webrtc.org439be292012-02-16 14:45:37 +0000642QMVideoSettingsCallback::~QMVideoSettingsCallback() {
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000643}
644
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000645int32_t QMVideoSettingsCallback::SetVideoQMSettings(
646 const uint32_t frame_rate,
647 const uint32_t width,
648 const uint32_t height) {
marpan@webrtc.orgcf706c22012-03-27 21:04:13 +0000649 return vpm_->SetTargetResolution(width, height, frame_rate);
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000650}
651
jackychen6e2ce6e2015-07-13 16:26:33 -0700652void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
653 vpm_->SetTargetFramerate(frame_rate);
654}
655
mflodman@webrtc.org84d17832011-12-01 17:02:23 +0000656} // namespace webrtc