OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/modules/video_coding/generic_encoder.h" | 11 #include "webrtc/modules/video_coding/generic_encoder.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/api/video/i420_buffer.h" | 15 #include "webrtc/api/video/i420_buffer.h" |
16 #include "webrtc/modules/pacing/alr_detector.h" | |
sprang_webrtc
2017/07/26 14:13:43
Don't add dependency between modules. If we need t
ilnik
2017/07/26 14:49:48
We also need |AlrDetector::ParseAlrSettingsFromFie
| |
16 #include "webrtc/modules/video_coding/encoded_frame.h" | 17 #include "webrtc/modules/video_coding/encoded_frame.h" |
17 #include "webrtc/modules/video_coding/media_optimization.h" | 18 #include "webrtc/modules/video_coding/media_optimization.h" |
18 #include "webrtc/rtc_base/checks.h" | 19 #include "webrtc/rtc_base/checks.h" |
19 #include "webrtc/rtc_base/logging.h" | 20 #include "webrtc/rtc_base/logging.h" |
20 #include "webrtc/rtc_base/optional.h" | 21 #include "webrtc/rtc_base/optional.h" |
21 #include "webrtc/rtc_base/timeutils.h" | 22 #include "webrtc/rtc_base/timeutils.h" |
22 #include "webrtc/rtc_base/trace_event.h" | 23 #include "webrtc/rtc_base/trace_event.h" |
24 #include "webrtc/system_wrappers/include/field_trial.h" | |
23 | 25 |
24 namespace webrtc { | 26 namespace webrtc { |
25 | 27 |
26 VCMGenericEncoder::VCMGenericEncoder( | 28 VCMGenericEncoder::VCMGenericEncoder( |
27 VideoEncoder* encoder, | 29 VideoEncoder* encoder, |
28 VCMEncodedFrameCallback* encoded_frame_callback, | 30 VCMEncodedFrameCallback* encoded_frame_callback, |
29 bool internal_source) | 31 bool internal_source) |
30 : encoder_(encoder), | 32 : encoder_(encoder), |
31 vcm_encoded_frame_callback_(encoded_frame_callback), | 33 vcm_encoded_frame_callback_(encoded_frame_callback), |
32 internal_source_(internal_source), | 34 internal_source_(internal_source), |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 | 289 |
288 // If encode start is not available that means that encoder uses internal | 290 // If encode start is not available that means that encoder uses internal |
289 // source. In that case capture timestamp may be from a different clock with a | 291 // source. In that case capture timestamp may be from a different clock with a |
290 // drift relative to rtc::TimeMillis(). We can't use it for Timing frames, | 292 // drift relative to rtc::TimeMillis(). We can't use it for Timing frames, |
291 // because to being sent in the network capture time required to be less than | 293 // because to being sent in the network capture time required to be less than |
292 // all the other timestamps. | 294 // all the other timestamps. |
293 if (is_timing_frame && encode_start_ms) { | 295 if (is_timing_frame && encode_start_ms) { |
294 encoded_image.SetEncodeTime(*encode_start_ms, rtc::TimeMillis()); | 296 encoded_image.SetEncodeTime(*encode_start_ms, rtc::TimeMillis()); |
295 } | 297 } |
296 | 298 |
299 // Piggyback ALR experiment group id and simulcast id into the content type. | |
300 uint8_t experiment_id = 0; | |
301 rtc::Optional<AlrDetector::AlrExperimentSettings> experiment_settings = | |
302 AlrDetector::ParseAlrSettingsFromFieldTrial(); | |
303 if (experiment_settings) { | |
304 // 0 would mean no experiment, therefore adding 1. It will be subtracted at | |
305 // the receive side before reporting fake field trial. | |
306 experiment_id = experiment_settings->group_id + 1; | |
307 } | |
308 | |
309 // TODO(ilnik): This will force content type extension to be present even | |
310 // for realtime video. At the expense of miniscule overhead we will get | |
311 // sliced receive statistics. | |
312 encoded_image.content_type_.SetExperimentId(experiment_id); | |
313 // We number simulcast streams from 1 on the network. | |
314 encoded_image.content_type_.SetSimulcastId( | |
315 static_cast<uint8_t>(simulcast_svc_idx + 1)); | |
316 | |
297 Result result = post_encode_callback_->OnEncodedImage( | 317 Result result = post_encode_callback_->OnEncodedImage( |
298 encoded_image, codec_specific, fragmentation_header); | 318 encoded_image, codec_specific, fragmentation_header); |
299 if (result.error != Result::OK) | 319 if (result.error != Result::OK) |
300 return result; | 320 return result; |
301 | 321 |
302 if (media_opt_) { | 322 if (media_opt_) { |
303 media_opt_->UpdateWithEncodedData(encoded_image); | 323 media_opt_->UpdateWithEncodedData(encoded_image); |
304 if (internal_source_) { | 324 if (internal_source_) { |
305 // Signal to encoder to drop next frame. | 325 // Signal to encoder to drop next frame. |
306 result.drop_next_frame = media_opt_->DropFrame(); | 326 result.drop_next_frame = media_opt_->DropFrame(); |
307 } | 327 } |
308 } | 328 } |
309 return result; | 329 return result; |
310 } | 330 } |
311 | 331 |
312 } // namespace webrtc | 332 } // namespace webrtc |
OLD | NEW |