Add default conversational speech file to the .rodata section.
This allow to remove the testonly from the rtc_event_log_visualizer
binary and the implicit dependency on the path of the default
conversational speech file.
The binary size of event_log_visualizer passes from 2.1 MB to 4.0 MB.
Bug: b/237526033
Change-Id: I71cf647f039f26f30c792c49c752cff5c5b329a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267663
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37453}
diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc
index d83e200..0870f8f 100644
--- a/rtc_tools/rtc_event_log_visualizer/main.cc
+++ b/rtc_tools/rtc_event_log_visualizer/main.cc
@@ -11,6 +11,8 @@
#include <stdio.h>
#include <string.h>
+#include <cstdio>
+#include <fstream>
#include <iostream>
#include <map>
#include <memory>
@@ -33,9 +35,9 @@
#include "rtc_tools/rtc_event_log_visualizer/alerts.h"
#include "rtc_tools/rtc_event_log_visualizer/analyze_audio.h"
#include "rtc_tools/rtc_event_log_visualizer/analyzer.h"
+#include "rtc_tools/rtc_event_log_visualizer/conversational_speech_en.h"
#include "rtc_tools/rtc_event_log_visualizer/plot_base.h"
#include "system_wrappers/include/field_trial.h"
-#include "test/testsupport/file_utils.h"
ABSL_FLAG(std::string,
plot,
@@ -464,11 +466,18 @@
});
std::string wav_path;
+ bool has_generated_wav_file = false;
if (!absl::GetFlag(FLAGS_wav_filename).empty()) {
wav_path = absl::GetFlag(FLAGS_wav_filename);
} else {
- wav_path = webrtc::test::ResourcePath(
- "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
+ // TODO(bugs.webrtc.org/14248): Remove the need to generate a file
+ // and read the file directly from memory.
+ wav_path = std::tmpnam(nullptr);
+ std::ofstream out_wav_file(wav_path);
+ out_wav_file.write(
+ reinterpret_cast<char*>(&webrtc::conversational_speech_en_wav[0]),
+ webrtc::conversational_speech_en_wav_len);
+ has_generated_wav_file = true;
}
absl::optional<webrtc::NetEqStatsGetterMap> neteq_stats;
@@ -622,5 +631,11 @@
triage_alerts.Print(stderr);
}
+ // TODO(bugs.webrtc.org/14248): Remove the need to generate a file
+ // and read the file directly from memory.
+ if (has_generated_wav_file) {
+ RTC_CHECK_EQ(std::remove(wav_path.c_str()), 0)
+ << "Failed to remove " << wav_path;
+ }
return 0;
}