Enables PeerConnectionFactory using external fec controller
Bug: webrtc:8799
Change-Id: Ieb2cf6163b9a83844ab9ed4822b4a7f1db4c24b8
Reviewed-on: https://webrtc-review.googlesource.com/43961
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22038}
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index a45fd34..067710c 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -49,6 +49,7 @@
]
deps = [
":module_api_public",
+ ":module_fec_api",
"..:webrtc_common",
"../:typedefs",
"../api:audio_frame_api",
@@ -62,6 +63,13 @@
]
}
+rtc_source_set("module_fec_api") {
+ visibility = [ "*" ]
+ sources = [
+ "include/module_fec_types.h",
+ ]
+}
+
if (rtc_include_tests) {
modules_tests_resources = [
"../resources/audio_coding/testfile32kHz.pcm",
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index 0842370..1290075 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -25,6 +25,7 @@
#include "api/video/video_rotation.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/include/module_common_types_public.h"
+#include "modules/include/module_fec_types.h"
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
@@ -265,22 +266,6 @@
uint16_t JBabsMax;
};
-// Types for the FEC packet masks. The type |kFecMaskRandom| is based on a
-// random loss model. The type |kFecMaskBursty| is based on a bursty/consecutive
-// loss model. The packet masks are defined in
-// modules/rtp_rtcp/fec_private_tables_random(bursty).h
-enum FecMaskType {
- kFecMaskRandom,
- kFecMaskBursty,
-};
-
-// Struct containing forward error correction settings.
-struct FecProtectionParams {
- int fec_rate;
- int max_fec_frames;
- FecMaskType fec_mask_type;
-};
-
// Interface used by the CallStats class to distribute call statistics.
// Callbacks will be triggered as soon as the class has been registered to a
// CallStats object using RegisterStatsObserver.
diff --git a/modules/include/module_fec_types.h b/modules/include/module_fec_types.h
new file mode 100644
index 0000000..25d6bc5
--- /dev/null
+++ b/modules/include/module_fec_types.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef MODULES_INCLUDE_MODULE_FEC_TYPES_H_
+#define MODULES_INCLUDE_MODULE_FEC_TYPES_H_
+
+namespace webrtc {
+
+// Types for the FEC packet masks. The type |kFecMaskRandom| is based on a
+// random loss model. The type |kFecMaskBursty| is based on a bursty/consecutive
+// loss model. The packet masks are defined in
+// modules/rtp_rtcp/fec_private_tables_random(bursty).h
+enum FecMaskType {
+ kFecMaskRandom,
+ kFecMaskBursty,
+};
+
+// Struct containing forward error correction settings.
+struct FecProtectionParams {
+ int fec_rate;
+ int max_fec_frames;
+ FecMaskType fec_mask_type;
+};
+
+} // namespace webrtc
+
+#endif // MODULES_INCLUDE_MODULE_FEC_TYPES_H_
diff --git a/modules/video_coding/fec_controller_default.cc b/modules/video_coding/fec_controller_default.cc
index 9d26aac..84e8a7b 100644
--- a/modules/video_coding/fec_controller_default.cc
+++ b/modules/video_coding/fec_controller_default.cc
@@ -145,11 +145,12 @@
loss_prot_logic_->SetMethod(method);
}
void FecControllerDefault::UpdateWithEncodedData(
- const EncodedImage& encoded_image) {
- const size_t encoded_length = encoded_image._length;
+ const size_t encoded_image_length,
+ const FrameType encoded_image_frametype) {
+ const size_t encoded_length = encoded_image_length;
CritScope lock(&crit_sect_);
if (encoded_length > 0) {
- const bool delta_frame = encoded_image._frameType != kVideoFrameKey;
+ const bool delta_frame = encoded_image_frametype != kVideoFrameKey;
if (max_payload_size_ > 0 && encoded_length > 0) {
const float min_packets_per_frame =
encoded_length / static_cast<float>(max_payload_size_);
diff --git a/modules/video_coding/fec_controller_default.h b/modules/video_coding/fec_controller_default.h
index a7f445f..776977a 100644
--- a/modules/video_coding/fec_controller_default.h
+++ b/modules/video_coding/fec_controller_default.h
@@ -39,7 +39,8 @@
uint8_t fraction_lost,
std::vector<bool> loss_mask_vector,
int64_t round_trip_time_ms) override;
- void UpdateWithEncodedData(const EncodedImage& encoded_image) override;
+ void UpdateWithEncodedData(const size_t encoded_image_length,
+ const FrameType encoded_image_frametype) override;
bool UseLossVectorMask() override { return false; }
private:
diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc
index bb5f75e..d1816e0 100644
--- a/modules/video_coding/generic_encoder.cc
+++ b/modules/video_coding/generic_encoder.cc
@@ -412,7 +412,8 @@
return result;
if (media_opt_) {
- media_opt_->UpdateWithEncodedData(image_copy);
+ media_opt_->UpdateWithEncodedData(image_copy._length,
+ image_copy._frameType);
if (internal_source_) {
// Signal to encoder to drop next frame.
result.drop_next_frame = media_opt_->DropFrame();
diff --git a/modules/video_coding/media_optimization.cc b/modules/video_coding/media_optimization.cc
index 51c5bcb..ea70f3f 100644
--- a/modules/video_coding/media_optimization.cc
+++ b/modules/video_coding/media_optimization.cc
@@ -90,11 +90,12 @@
}
void MediaOptimization::UpdateWithEncodedData(
- const EncodedImage& encoded_image) {
- size_t encoded_length = encoded_image._length;
+ const size_t encoded_image_length,
+ const FrameType encoded_image_frametype) {
+ size_t encoded_length = encoded_image_length;
rtc::CritScope lock(&crit_sect_);
if (encoded_length > 0) {
- const bool delta_frame = encoded_image._frameType != kVideoFrameKey;
+ const bool delta_frame = encoded_image_frametype != kVideoFrameKey;
frame_dropper_->Fill(encoded_length, delta_frame);
}
}
diff --git a/modules/video_coding/media_optimization.h b/modules/video_coding/media_optimization.h
index 5fa0254..411f86c 100644
--- a/modules/video_coding/media_optimization.h
+++ b/modules/video_coding/media_optimization.h
@@ -51,7 +51,8 @@
// Informs Media Optimization of encoded output.
// TODO(perkj): Deprecate SetEncodingData once its not used for stats in
// VideoStreamEncoder.
- void UpdateWithEncodedData(const EncodedImage& encoded_image);
+ void UpdateWithEncodedData(const size_t encoded_image_length,
+ const FrameType encoded_image_frametype);
// InputFrameRate 0 = no frame rate estimate available.
uint32_t InputFrameRate();