Reland of Loosening the coupling between WebRTC and //third_party/protobuf (patchset #1 id:1 of https://codereview.webrtc.org/2786363002/ )
Reason for revert:
Trying to re-land after solving some related issues.
There are no changes compared to the original CL.
Original issue's description:
> Revert of Loosening the coupling between WebRTC and //third_party/protobuf (patchset #16 id:300001 of https://codereview.webrtc.org/2747863003/ )
>
> Reason for revert:
> I will try to reland next week because it is causing some problems.
>
> Original issue's description:
> > To accommodate some downstream WebRTC users we need to loosen
> > the coupling between our code and the //third_party/protobuf.
> >
> > This includes using typedefs to define strings instead of
> > assuming std::string.
> >
> > After this refactoring it will be possible to link with other
> > protobuf implementations than the current one.
> >
> > We moved the PRESUBMIT check to another CL [1]. The goal of this
> > presubmit is to avoid the direct usage of google::protobuf outside
> > of the webrtc/base/protobuf_utils.h header file.
> >
> > [1] - https://codereview.webrtc.org/2753823003/
> >
> > BUG=webrtc:7340
> > NOTRY=True
> >
> > Review-Url: https://codereview.webrtc.org/2747863003
> > Cr-Commit-Position: refs/heads/master@{#17466}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/16ab93b952f9e8268f2e663ffe49548e8043d5af
>
> TBR=kjellander@webrtc.org,henrik.lundin@webrtc.org,kwiberg@webrtc.org,michaelt@webrtc.org,peah@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7340
>
> Review-Url: https://codereview.webrtc.org/2786363002
> Cr-Commit-Position: refs/heads/master@{#17483}
> Committed: https://chromium.googlesource.com/external/webrtc/+/d00aad5eb2fa5a7b5aeda714f7702b50cd26ee28
TBR=kjellander@webrtc.org,henrik.lundin@webrtc.org,kwiberg@webrtc.org,michaelt@webrtc.org,peah@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7340
NOTRY=True
Review-Url: https://codereview.webrtc.org/2791963003
Cr-Commit-Position: refs/heads/master@{#17584}
diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn
index 5ae3164..6d14223 100644
--- a/webrtc/modules/audio_coding/BUILD.gn
+++ b/webrtc/modules/audio_coding/BUILD.gn
@@ -72,6 +72,7 @@
]
deps = [
"../..:webrtc_common",
+ "../../base:protobuf_utils",
"../../base:rtc_base_approved",
":audio_encoder_factory_interface",
] + audio_codec_deps
@@ -101,6 +102,7 @@
deps = [
"../../api/audio_codecs:audio_codecs_api",
"../..:webrtc_common",
+ "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../system_wrappers",
":audio_coding_module_typedefs",
@@ -109,6 +111,7 @@
":isac_fix_c",
":neteq_decoder_enum",
] + audio_codec_deps
+
defines = audio_codec_defines
}
@@ -856,6 +859,7 @@
":audio_network_adaptor",
"../..:webrtc_common",
"../../api/audio_codecs:audio_codecs_api",
+ "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../base:rtc_numerics",
"../../common_audio",
@@ -949,6 +953,7 @@
deps = [
"../..:webrtc_common",
+ "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../common_audio",
"../../logging:rtc_event_log_api",
@@ -1216,10 +1221,12 @@
":neteq_unittest_tools",
":webrtc_opus",
"../..:webrtc_common",
+ "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
"../../test:test_support",
]
+
if (!build_with_chromium && is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
@@ -1354,6 +1361,7 @@
":neteq",
":neteq_unittest_tools",
"../../api/audio_codecs:audio_codecs_api",
+ "../../base:protobuf_utils",
"../../common_audio",
"../../test:test_main",
"//testing/gtest",
@@ -2112,6 +2120,7 @@
"../..:webrtc_common",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
+ "../../base:protobuf_utils",
"../../base:rtc_base",
"../../base:rtc_base_approved",
"../../base:rtc_base_tests_utils",
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc
index b0d4aed..1e6aff1 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc
@@ -195,7 +195,7 @@
ControllerManagerImpl::Config::~Config() = default;
std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
- const std::string& config_string,
+ const ProtoString& config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h
index 155b749..0124cc2 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h
@@ -16,6 +16,7 @@
#include <vector>
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/protobuf_utils.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h"
namespace webrtc {
@@ -49,7 +50,7 @@
};
static std::unique_ptr<ControllerManager> Create(
- const std::string& config_string,
+ const ProtoString& config_string,
size_t num_encoder_channels,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
int min_encoder_bitrate_bps,
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
index 4a2a57b..6d1434a 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "webrtc/base/ignore_wundef.h"
+#include "webrtc/base/protobuf_utils.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h"
#include "webrtc/system_wrappers/include/clock.h"
@@ -273,7 +274,7 @@
constexpr int kMinBitrateBps = 6000;
ControllerManagerStates CreateControllerManager(
- const std::string& config_string) {
+ const ProtoString& config_string) {
ControllerManagerStates states;
states.simulated_clock.reset(new SimulatedClock(kClockInitialTime));
constexpr size_t kNumEncoderChannels = 2;
@@ -345,7 +346,7 @@
AddFrameLengthControllerConfig(&config);
AddBitrateControllerConfig(&config);
- std::string config_string;
+ ProtoString config_string;
config.SerializeToString(&config_string);
auto states = CreateControllerManager(config_string);
@@ -376,7 +377,7 @@
AddBitrateControllerConfig(&config);
- std::string config_string;
+ ProtoString config_string;
config.SerializeToString(&config_string);
auto states = CreateControllerManager(config_string);
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
index 2e4757a..8b485e4 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
@@ -12,6 +12,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/ignore_wundef.h"
+#include "webrtc/base/protobuf_utils.h"
#ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP
RTC_PUSH_IGNORING_WUNDEF()
@@ -34,7 +35,7 @@
void DumpEventToFile(const Event& event, FileWrapper* dump_file) {
RTC_CHECK(dump_file->is_open());
- std::string dump_data;
+ ProtoString dump_data;
event.SerializeToString(&dump_data);
int32_t size = event.ByteSize();
dump_file->Write(&size, sizeof(size));
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h b/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h
index 1661cd3..1a53d1e 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h
@@ -12,7 +12,6 @@
#define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP_WRITER_H_
#include <memory>
-#include <string>
#include "webrtc/base/constructormagic.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h"
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index aaf2647..6f6e39e 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -18,6 +18,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/numerics/exp_filter.h"
+#include "webrtc/base/protobuf_utils.h"
#include "webrtc/base/safe_conversions.h"
#include "webrtc/base/string_to_number.h"
#include "webrtc/base/timeutils.h"
@@ -370,7 +371,7 @@
audio_network_adaptor_creator_(
audio_network_adaptor_creator
? std::move(audio_network_adaptor_creator)
- : [this](const std::string& config_string,
+ : [this](const ProtoString& config_string,
RtcEventLog* event_log,
const Clock* clock) {
return DefaultAudioNetworkAdaptorCreator(config_string,
@@ -721,7 +722,7 @@
std::unique_ptr<AudioNetworkAdaptor>
AudioEncoderOpus::DefaultAudioNetworkAdaptorCreator(
- const std::string& config_string,
+ const ProtoString& config_string,
RtcEventLog* event_log,
const Clock* clock) const {
AudioNetworkAdaptorImpl::Config config;
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
index 3d3597b..e9672ed 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
@@ -19,6 +19,7 @@
#include "webrtc/api/audio_codecs/audio_format.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/optional.h"
+#include "webrtc/base/protobuf_utils.h"
#include "webrtc/common_audio/smoothing_filter.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
@@ -167,7 +168,7 @@
void ApplyAudioNetworkAdaptor();
std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator(
- const std::string& config_string,
+ const ProtoString& config_string,
RtcEventLog* event_log,
const Clock* clock) const;
diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
index c52f2d6..47073fb 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
@@ -25,6 +25,7 @@
#include "webrtc/base/ignore_wundef.h"
#include "webrtc/base/sha1digest.h"
#include "webrtc/base/stringencode.h"
+#include "webrtc/base/protobuf_utils.h"
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
@@ -194,7 +195,7 @@
neteq_unittest::NetEqNetworkStatistics stats;
Convert(stats_raw, &stats);
- std::string stats_string;
+ ProtoString stats_string;
ASSERT_TRUE(stats.SerializeToString(&stats_string));
AddMessage(output_fp_, digest_.get(), stats_string);
#else
@@ -207,7 +208,7 @@
neteq_unittest::RtcpStatistics stats;
Convert(stats_raw, &stats);
- std::string stats_string;
+ ProtoString stats_string;
ASSERT_TRUE(stats.SerializeToString(&stats_string));
AddMessage(output_fp_, digest_.get(), stats_string);
#else