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}
diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn
index 84545dd..36f5575 100644
--- a/webrtc/modules/audio_processing/BUILD.gn
+++ b/webrtc/modules/audio_processing/BUILD.gn
@@ -232,7 +232,6 @@
"../..:webrtc_common",
"../../audio/utility:audio_frame_operations",
"../../base:gtest_prod",
- "../../base:protobuf_utils",
"../audio_coding:isac",
]
public_deps = [
@@ -525,7 +524,6 @@
":audioproc_test_utils",
"../..:webrtc_common",
"../../base:gtest_prod",
- "../../base:protobuf_utils",
"../../base:rtc_base",
"../../base:rtc_base_approved",
"../../common_audio:common_audio",
@@ -658,10 +656,8 @@
deps = [
":audio_processing",
":audioproc_test_utils",
- "../../base:protobuf_utils",
"//testing/gtest",
]
-
if (rtc_enable_intelligibility_enhancer) {
defines = [ "WEBRTC_INTELLIGIBILITY_ENHANCER=1" ]
} else {
@@ -682,7 +678,6 @@
":audioproc_protobuf_utils",
":audioproc_test_utils",
"../..:webrtc_common",
- "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../common_audio",
"../../system_wrappers:system_wrappers_default",
@@ -707,7 +702,6 @@
":audioproc_debug_proto",
":audioproc_protobuf_utils",
":audioproc_test_utils",
- "../../base:protobuf_utils",
"../../base:rtc_base_approved",
"../../common_audio:common_audio",
"../../system_wrappers",
@@ -823,7 +817,6 @@
deps = [
":audioproc_debug_proto",
"../..:webrtc_common",
- "../../base:protobuf_utils",
"../../base:rtc_base_approved",
]
}
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 56da282..1f73c59 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -1879,11 +1879,11 @@
audioproc::Init* msg = debug_dump_.capture.event_msg->mutable_init();
msg->set_sample_rate(formats_.api_format.input_stream().sample_rate_hz());
- msg->set_num_input_channels(static_cast<int32_t>(
+ msg->set_num_input_channels(static_cast<google::protobuf::int32>(
formats_.api_format.input_stream().num_channels()));
- msg->set_num_output_channels(static_cast<int32_t>(
+ msg->set_num_output_channels(static_cast<google::protobuf::int32>(
formats_.api_format.output_stream().num_channels()));
- msg->set_num_reverse_channels(static_cast<int32_t>(
+ msg->set_num_reverse_channels(static_cast<google::protobuf::int32>(
formats_.api_format.reverse_input_stream().num_channels()));
msg->set_reverse_sample_rate(
formats_.api_format.reverse_input_stream().sample_rate_hz());
@@ -1953,7 +1953,7 @@
}
config.set_experiments_description(experiments_description);
- ProtoString serialized_config = config.SerializeAsString();
+ std::string serialized_config = config.SerializeAsString();
if (!forced &&
debug_dump_.capture.last_serialized_config == serialized_config) {
return kNoError;
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h
index 2b6e6f6..01b640f 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.h
+++ b/webrtc/modules/audio_processing/audio_processing_impl.h
@@ -13,13 +13,13 @@
#include <list>
#include <memory>
+#include <string>
#include <vector>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/function_view.h"
#include "webrtc/base/gtest_prod_util.h"
#include "webrtc/base/ignore_wundef.h"
-#include "webrtc/base/protobuf_utils.h"
#include "webrtc/base/swap_queue.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
@@ -29,7 +29,7 @@
#include "webrtc/system_wrappers/include/file_wrapper.h"
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
-// *.pb.h files are generated at build-time by the protobuf compiler.
+// Files generated at build-time by the protobuf compiler.
RTC_PUSH_IGNORING_WUNDEF()
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
@@ -200,10 +200,10 @@
ApmDebugDumpThreadState();
~ApmDebugDumpThreadState();
std::unique_ptr<audioproc::Event> event_msg; // Protobuf message.
- ProtoString event_str; // Memory for protobuf serialization.
+ std::string event_str; // Memory for protobuf serialization.
// Serialized string of last saved APM configuration.
- ProtoString last_serialized_config;
+ std::string last_serialized_config;
};
struct ApmDebugDumpState {
diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc
index 814eea9..b52acce 100644
--- a/webrtc/modules/audio_processing/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc
@@ -20,7 +20,6 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/gtest_prod_util.h"
#include "webrtc/base/ignore_wundef.h"
-#include "webrtc/base/protobuf_utils.h"
#include "webrtc/common_audio/include/audio_util.h"
#include "webrtc/common_audio/resampler/include/push_resampler.h"
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
@@ -59,7 +58,7 @@
// file. This is the typical case. When the file should be updated, it can
// be set to true with the command-line switch --write_ref_data.
bool write_ref_data = false;
-const int32_t kChannels[] = {1, 2};
+const google::protobuf::int32 kChannels[] = {1, 2};
const int kSampleRates[] = {8000, 16000, 32000, 48000};
#if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE)
@@ -231,7 +230,7 @@
#endif
void OpenFileAndWriteMessage(const std::string filename,
- const MessageLite& msg) {
+ const ::google::protobuf::MessageLite& msg) {
FILE* file = fopen(filename.c_str(), "wb");
ASSERT_TRUE(file != NULL);
@@ -300,7 +299,8 @@
remove(kv.second.c_str());
}
-void OpenFileAndReadMessage(std::string filename, MessageLite* msg) {
+void OpenFileAndReadMessage(std::string filename,
+ ::google::protobuf::MessageLite* msg) {
FILE* file = fopen(filename.c_str(), "rb");
ASSERT_TRUE(file != NULL);
ReadMessageFromFile(file, msg);
diff --git a/webrtc/modules/audio_processing/test/protobuf_utils.cc b/webrtc/modules/audio_processing/test/protobuf_utils.cc
index cb8adf9..c18a13e 100644
--- a/webrtc/modules/audio_processing/test/protobuf_utils.cc
+++ b/webrtc/modules/audio_processing/test/protobuf_utils.cc
@@ -30,7 +30,7 @@
}
// Returns true on success, false on error or end-of-file.
-bool ReadMessageFromFile(FILE* file, MessageLite* msg) {
+bool ReadMessageFromFile(FILE* file, ::google::protobuf::MessageLite* msg) {
std::unique_ptr<uint8_t[]> bytes;
size_t size = ReadMessageBytesFromFile(file, &bytes);
if (!size)
diff --git a/webrtc/modules/audio_processing/test/protobuf_utils.h b/webrtc/modules/audio_processing/test/protobuf_utils.h
index 8941338..e132c94 100644
--- a/webrtc/modules/audio_processing/test/protobuf_utils.h
+++ b/webrtc/modules/audio_processing/test/protobuf_utils.h
@@ -14,7 +14,6 @@
#include <memory>
#include "webrtc/base/ignore_wundef.h"
-#include "webrtc/base/protobuf_utils.h"
RTC_PUSH_IGNORING_WUNDEF()
#include "webrtc/modules/audio_processing/debug.pb.h"
@@ -27,7 +26,7 @@
size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes);
// Returns true on success, false on error or end-of-file.
-bool ReadMessageFromFile(FILE* file, MessageLite* msg);
+bool ReadMessageFromFile(FILE* file, ::google::protobuf::MessageLite* msg);
} // namespace webrtc