Adopt absl::string_view in rtc_base/ (straightforward cases)
Bug: webrtc:13579 Change-Id: I240db6285abb22652242bc0b2ebe9844ec4a45f0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258723 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Ali Tofigh <alito@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36561}
This commit is contained in:
parent
a62136ac74
commit
2ab914c6ab
@ -206,7 +206,7 @@ int32_t FileAudioDevice::StartPlayout() {
|
|||||||
|
|
||||||
// PLAYOUT
|
// PLAYOUT
|
||||||
if (!_outputFilename.empty()) {
|
if (!_outputFilename.empty()) {
|
||||||
_outputFile = FileWrapper::OpenWriteOnly(_outputFilename.c_str());
|
_outputFile = FileWrapper::OpenWriteOnly(_outputFilename);
|
||||||
if (!_outputFile.is_open()) {
|
if (!_outputFile.is_open()) {
|
||||||
RTC_LOG(LS_ERROR) << "Failed to open playout file: " << _outputFilename;
|
RTC_LOG(LS_ERROR) << "Failed to open playout file: " << _outputFilename;
|
||||||
_playing = false;
|
_playing = false;
|
||||||
@ -266,7 +266,7 @@ int32_t FileAudioDevice::StartRecording() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_inputFilename.empty()) {
|
if (!_inputFilename.empty()) {
|
||||||
_inputFile = FileWrapper::OpenReadOnly(_inputFilename.c_str());
|
_inputFile = FileWrapper::OpenReadOnly(_inputFilename);
|
||||||
if (!_inputFile.is_open()) {
|
if (!_inputFile.is_open()) {
|
||||||
RTC_LOG(LS_ERROR) << "Failed to open audio input file: "
|
RTC_LOG(LS_ERROR) << "Failed to open audio input file: "
|
||||||
<< _inputFilename;
|
<< _inputFilename;
|
||||||
|
|||||||
@ -255,8 +255,8 @@ std::unique_ptr<AecDump> AecDumpFactory::Create(webrtc::FileWrapper file,
|
|||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue) {
|
rtc::TaskQueue* worker_queue) {
|
||||||
return Create(FileWrapper::OpenWriteOnly(file_name.c_str()),
|
return Create(FileWrapper::OpenWriteOnly(file_name), max_log_size_bytes,
|
||||||
max_log_size_bytes, worker_queue);
|
worker_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(FILE* handle,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(FILE* handle,
|
||||||
|
|||||||
@ -1600,7 +1600,7 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
|||||||
|
|
||||||
const std::string filename =
|
const std::string filename =
|
||||||
test::TempFilename(test::OutputPath(), "debug_aec");
|
test::TempFilename(test::OutputPath(), "debug_aec");
|
||||||
FileWrapper f = FileWrapper::OpenWriteOnly(filename.c_str());
|
FileWrapper f = FileWrapper::OpenWriteOnly(filename);
|
||||||
ASSERT_TRUE(f.is_open());
|
ASSERT_TRUE(f.is_open());
|
||||||
|
|
||||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||||
|
|||||||
@ -25,7 +25,7 @@ namespace test {
|
|||||||
std::vector<WavBasedSimulator::SimulationEventType>
|
std::vector<WavBasedSimulator::SimulationEventType>
|
||||||
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
||||||
std::vector<WavBasedSimulator::SimulationEventType> call_chain;
|
std::vector<WavBasedSimulator::SimulationEventType> call_chain;
|
||||||
FileWrapper file_wrapper = FileWrapper::OpenReadOnly(filename.c_str());
|
FileWrapper file_wrapper = FileWrapper::OpenReadOnly(filename);
|
||||||
|
|
||||||
RTC_CHECK(file_wrapper.is_open())
|
RTC_CHECK(file_wrapper.is_open())
|
||||||
<< "Could not open the custom call order file, reverting "
|
<< "Could not open the custom call order file, reverting "
|
||||||
|
|||||||
@ -159,7 +159,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ConvertDoubleToByteArray) {
|
|||||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
||||||
std::string test_filename = kTestFileName;
|
std::string test_filename = kTestFileName;
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
FileWrapper file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileName.c_str();
|
<< kTestFileName.c_str();
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
|||||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
||||||
std::string test_filename = kTestFileName;
|
std::string test_filename = kTestFileName;
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
FileWrapper file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileName.c_str();
|
<< kTestFileName.c_str();
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
|||||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
||||||
std::string test_filename = kTestFileName;
|
std::string test_filename = kTestFileName;
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
FileWrapper file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileName.c_str();
|
<< kTestFileName.c_str();
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
|||||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
||||||
std::string test_filename = kTestFileNamef;
|
std::string test_filename = kTestFileNamef;
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
FileWrapper file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileNamef.c_str();
|
<< kTestFileNamef.c_str();
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
|||||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
|
TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
|
||||||
std::string test_filename = kTestFileName;
|
std::string test_filename = kTestFileName;
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
FileWrapper file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileName.c_str();
|
<< kTestFileName.c_str();
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
|
|||||||
std::string kOutFileName =
|
std::string kOutFileName =
|
||||||
CreateTempFilename(test::OutputPath(), "utils_test");
|
CreateTempFilename(test::OutputPath(), "utils_test");
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
|
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
|
|||||||
|
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
|
file = FileWrapper::OpenReadOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
|
|||||||
std::string kOutFileName =
|
std::string kOutFileName =
|
||||||
CreateTempFilename(test::OutputPath(), "utils_test");
|
CreateTempFilename(test::OutputPath(), "utils_test");
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
|
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
|
|||||||
|
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
|
file = FileWrapper::OpenReadOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
|
|||||||
std::string kOutFileName =
|
std::string kOutFileName =
|
||||||
CreateTempFilename(test::OutputPath(), "utils_test");
|
CreateTempFilename(test::OutputPath(), "utils_test");
|
||||||
|
|
||||||
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
|
FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
|
|||||||
|
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
|
file = FileWrapper::OpenReadOnly(kOutFileName);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kOutFileName.c_str();
|
<< kOutFileName.c_str();
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) {
|
|||||||
EXPECT_EQ(0u, WriteInt16BufferToFile(&file, 1, int16_buffer.get()));
|
EXPECT_EQ(0u, WriteInt16BufferToFile(&file, 1, int16_buffer.get()));
|
||||||
EXPECT_EQ(0u, WriteDoubleBufferToFile(&file, 1, double_buffer.get()));
|
EXPECT_EQ(0u, WriteDoubleBufferToFile(&file, 1, double_buffer.get()));
|
||||||
|
|
||||||
file = FileWrapper::OpenReadOnly(test_filename.c_str());
|
file = FileWrapper::OpenReadOnly(test_filename);
|
||||||
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
|
||||||
<< kTestFileName.c_str();
|
<< kTestFileName.c_str();
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) {
|
|||||||
<< (sample_rate_hz / 1000) << "kHz";
|
<< (sample_rate_hz / 1000) << "kHz";
|
||||||
|
|
||||||
FileWrapper detect_file = FileWrapper::OpenReadOnly(
|
FileWrapper detect_file = FileWrapper::OpenReadOnly(
|
||||||
test::ResourcePath(detect_file_name.str(), "dat").c_str());
|
test::ResourcePath(detect_file_name.str(), "dat"));
|
||||||
|
|
||||||
bool file_opened = detect_file.is_open();
|
bool file_opened = detect_file.is_open();
|
||||||
ASSERT_TRUE(file_opened) << "File could not be opened.\n"
|
ASSERT_TRUE(file_opened) << "File could not be opened.\n"
|
||||||
@ -60,7 +60,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) {
|
|||||||
<< (sample_rate_hz / 1000) << "kHz";
|
<< (sample_rate_hz / 1000) << "kHz";
|
||||||
|
|
||||||
FileWrapper audio_file = FileWrapper::OpenReadOnly(
|
FileWrapper audio_file = FileWrapper::OpenReadOnly(
|
||||||
test::ResourcePath(audio_file_name.str(), "pcm").c_str());
|
test::ResourcePath(audio_file_name.str(), "pcm"));
|
||||||
|
|
||||||
// Create detector.
|
// Create detector.
|
||||||
TransientDetector detector(sample_rate_hz);
|
TransientDetector detector(sample_rate_hz);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) {
|
|||||||
rtc::StringBuilder matlab_stream;
|
rtc::StringBuilder matlab_stream;
|
||||||
matlab_stream << "audio_processing/transient/wpd" << i;
|
matlab_stream << "audio_processing/transient/wpd" << i;
|
||||||
std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat");
|
std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat");
|
||||||
matlab_files_data[i] = FileWrapper::OpenReadOnly(matlab_string.c_str());
|
matlab_files_data[i] = FileWrapper::OpenReadOnly(matlab_string);
|
||||||
|
|
||||||
bool file_opened = matlab_files_data[i].is_open();
|
bool file_opened = matlab_files_data[i].is_open();
|
||||||
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << matlab_string;
|
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << matlab_string;
|
||||||
@ -98,7 +98,7 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) {
|
|||||||
out_stream << test::OutputPath() << "wpd_" << i << ".out";
|
out_stream << test::OutputPath() << "wpd_" << i << ".out";
|
||||||
std::string out_string = out_stream.str();
|
std::string out_string = out_stream.str();
|
||||||
|
|
||||||
out_files_data[i] = FileWrapper::OpenWriteOnly(out_string.c_str());
|
out_files_data[i] = FileWrapper::OpenWriteOnly(out_string);
|
||||||
|
|
||||||
file_opened = out_files_data[i].is_open();
|
file_opened = out_files_data[i].is_open();
|
||||||
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string;
|
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string;
|
||||||
@ -108,7 +108,7 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) {
|
|||||||
std::string test_file_name = test::ResourcePath(
|
std::string test_file_name = test::ResourcePath(
|
||||||
"audio_processing/transient/ajm-macbook-1-spke16m", "pcm");
|
"audio_processing/transient/ajm-macbook-1-spke16m", "pcm");
|
||||||
|
|
||||||
FileWrapper test_file = FileWrapper::OpenReadOnly(test_file_name.c_str());
|
FileWrapper test_file = FileWrapper::OpenReadOnly(test_file_name);
|
||||||
|
|
||||||
bool file_opened = test_file.is_open();
|
bool file_opened = test_file.is_open();
|
||||||
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name;
|
ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name;
|
||||||
|
|||||||
@ -703,6 +703,7 @@ rtc_library("net_helpers") {
|
|||||||
":win32",
|
":win32",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("async_resolver_interface") {
|
rtc_library("async_resolver_interface") {
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/ref_counted_base.h"
|
#include "api/ref_counted_base.h"
|
||||||
#include "rtc_base/synchronization/mutex.h"
|
#include "rtc_base/synchronization/mutex.h"
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
@ -66,7 +67,7 @@ void PostTaskToGlobalQueue(std::unique_ptr<webrtc::QueuedTask> task) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ResolveHostname(const std::string& hostname,
|
int ResolveHostname(absl::string_view hostname,
|
||||||
int family,
|
int family,
|
||||||
std::vector<IPAddress>* addresses) {
|
std::vector<IPAddress>* addresses) {
|
||||||
#ifdef __native_client__
|
#ifdef __native_client__
|
||||||
@ -99,7 +100,8 @@ int ResolveHostname(const std::string& hostname,
|
|||||||
// https://android.googlesource.com/platform/bionic/+/
|
// https://android.googlesource.com/platform/bionic/+/
|
||||||
// 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657
|
// 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657
|
||||||
hints.ai_flags = AI_ADDRCONFIG;
|
hints.ai_flags = AI_ADDRCONFIG;
|
||||||
int ret = getaddrinfo(hostname.c_str(), nullptr, &hints, &result);
|
int ret =
|
||||||
|
getaddrinfo(std::string(hostname).c_str(), nullptr, &hints, &result);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -151,8 +153,7 @@ void AsyncResolver::Start(const SocketAddress& addr) {
|
|||||||
[this, addr, caller_task_queue = webrtc::TaskQueueBase::Current(),
|
[this, addr, caller_task_queue = webrtc::TaskQueueBase::Current(),
|
||||||
state = state_] {
|
state = state_] {
|
||||||
std::vector<IPAddress> addresses;
|
std::vector<IPAddress> addresses;
|
||||||
int error =
|
int error = ResolveHostname(addr.hostname(), addr.family(), &addresses);
|
||||||
ResolveHostname(addr.hostname().c_str(), addr.family(), &addresses);
|
|
||||||
webrtc::MutexLock lock(&state->mutex);
|
webrtc::MutexLock lock(&state->mutex);
|
||||||
if (state->status == State::Status::kLive) {
|
if (state->status == State::Status::kLive) {
|
||||||
caller_task_queue->PostTask(webrtc::ToQueuedTask(
|
caller_task_queue->PostTask(webrtc::ToQueuedTask(
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "rtc_base/atomic_ops.h"
|
#include "rtc_base/atomic_ops.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
@ -367,11 +368,11 @@ void StartInternalCaptureToFile(FILE* file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartInternalCapture(const char* filename) {
|
bool StartInternalCapture(absl::string_view filename) {
|
||||||
if (!g_event_logger)
|
if (!g_event_logger)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FILE* file = fopen(filename, "w");
|
FILE* file = fopen(std::string(filename).c_str(), "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
RTC_LOG(LS_ERROR) << "Failed to open trace file '" << filename
|
RTC_LOG(LS_ERROR) << "Failed to open trace file '" << filename
|
||||||
<< "' for writing.";
|
<< "' for writing.";
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -73,7 +74,7 @@ namespace rtc {
|
|||||||
namespace tracing {
|
namespace tracing {
|
||||||
// Set up internal event tracer.
|
// Set up internal event tracer.
|
||||||
RTC_EXPORT void SetupInternalTracer();
|
RTC_EXPORT void SetupInternalTracer();
|
||||||
RTC_EXPORT bool StartInternalCapture(const char* filename);
|
RTC_EXPORT bool StartInternalCapture(absl::string_view filename);
|
||||||
RTC_EXPORT void StartInternalCaptureToFile(FILE* file);
|
RTC_EXPORT void StartInternalCaptureToFile(FILE* file);
|
||||||
RTC_EXPORT void StopInternalCapture();
|
RTC_EXPORT void StopInternalCapture();
|
||||||
// Make sure we run this, this will tear down the internal tracing.
|
// Make sure we run this, this will tear down the internal tracing.
|
||||||
|
|||||||
@ -19,7 +19,10 @@ rtc_library("alr_experiment") {
|
|||||||
"../../api:field_trials_view",
|
"../../api:field_trials_view",
|
||||||
"../../api/transport:field_trial_based_config",
|
"../../api/transport:field_trial_based_config",
|
||||||
]
|
]
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
absl_deps = [
|
||||||
|
"//third_party/abseil-cpp/absl/strings:strings",
|
||||||
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("field_trial_parser") {
|
rtc_library("field_trial_parser") {
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/transport/field_trial_based_config.h"
|
#include "api/transport/field_trial_based_config.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ bool AlrExperimentSettings::MaxOneFieldTrialEnabled(
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<AlrExperimentSettings>
|
absl::optional<AlrExperimentSettings>
|
||||||
AlrExperimentSettings::CreateFromFieldTrial(const char* experiment_name) {
|
AlrExperimentSettings::CreateFromFieldTrial(absl::string_view experiment_name) {
|
||||||
return AlrExperimentSettings::CreateFromFieldTrial(FieldTrialBasedConfig(),
|
return AlrExperimentSettings::CreateFromFieldTrial(FieldTrialBasedConfig(),
|
||||||
experiment_name);
|
experiment_name);
|
||||||
}
|
}
|
||||||
@ -47,7 +48,7 @@ AlrExperimentSettings::CreateFromFieldTrial(const char* experiment_name) {
|
|||||||
absl::optional<AlrExperimentSettings>
|
absl::optional<AlrExperimentSettings>
|
||||||
AlrExperimentSettings::CreateFromFieldTrial(
|
AlrExperimentSettings::CreateFromFieldTrial(
|
||||||
const FieldTrialsView& key_value_config,
|
const FieldTrialsView& key_value_config,
|
||||||
const char* experiment_name) {
|
absl::string_view experiment_name) {
|
||||||
absl::optional<AlrExperimentSettings> ret;
|
absl::optional<AlrExperimentSettings> ret;
|
||||||
std::string group_name = key_value_config.Lookup(experiment_name);
|
std::string group_name = key_value_config.Lookup(experiment_name);
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
|
|
||||||
@ -32,10 +33,10 @@ struct AlrExperimentSettings {
|
|||||||
static const char kScreenshareProbingBweExperimentName[];
|
static const char kScreenshareProbingBweExperimentName[];
|
||||||
static const char kStrictPacingAndProbingExperimentName[];
|
static const char kStrictPacingAndProbingExperimentName[];
|
||||||
static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
|
static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
|
||||||
const char* experiment_name);
|
absl::string_view experiment_name);
|
||||||
static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
|
static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
|
||||||
const FieldTrialsView& key_value_config,
|
const FieldTrialsView& key_value_config,
|
||||||
const char* experiment_name);
|
absl::string_view experiment_name);
|
||||||
static bool MaxOneFieldTrialEnabled();
|
static bool MaxOneFieldTrialEnabled();
|
||||||
static bool MaxOneFieldTrialEnabled(const FieldTrialsView& key_value_config);
|
static bool MaxOneFieldTrialEnabled(const FieldTrialsView& key_value_config);
|
||||||
|
|
||||||
|
|||||||
@ -79,28 +79,28 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test {
|
|||||||
|
|
||||||
// Checks that the stream reads in the expected contents and then returns an
|
// Checks that the stream reads in the expected contents and then returns an
|
||||||
// end of stream result.
|
// end of stream result.
|
||||||
void VerifyStreamRead(const char* expected_contents,
|
void VerifyStreamRead(absl::string_view expected_contents,
|
||||||
const size_t expected_length,
|
|
||||||
absl::string_view dir_path,
|
absl::string_view dir_path,
|
||||||
const char* file_prefix) {
|
absl::string_view file_prefix) {
|
||||||
|
size_t expected_length = expected_contents.size();
|
||||||
FileRotatingStreamReader reader(dir_path, file_prefix);
|
FileRotatingStreamReader reader(dir_path, file_prefix);
|
||||||
EXPECT_EQ(reader.GetSize(), expected_length);
|
EXPECT_EQ(reader.GetSize(), expected_length);
|
||||||
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
|
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
|
||||||
memset(buffer.get(), 0, expected_length);
|
memset(buffer.get(), 0, expected_length);
|
||||||
EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
|
EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
|
||||||
EXPECT_EQ(0, memcmp(expected_contents, buffer.get(), expected_length));
|
EXPECT_EQ(0,
|
||||||
|
memcmp(expected_contents.data(), buffer.get(), expected_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerifyFileContents(const char* expected_contents,
|
void VerifyFileContents(absl::string_view expected_contents,
|
||||||
const size_t expected_length,
|
|
||||||
absl::string_view file_path) {
|
absl::string_view file_path) {
|
||||||
|
size_t expected_length = expected_contents.size();
|
||||||
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length + 1]);
|
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length + 1]);
|
||||||
webrtc::FileWrapper f =
|
webrtc::FileWrapper f = webrtc::FileWrapper::OpenReadOnly(file_path);
|
||||||
webrtc::FileWrapper::OpenReadOnly(std::string(file_path));
|
|
||||||
ASSERT_TRUE(f.is_open());
|
ASSERT_TRUE(f.is_open());
|
||||||
size_t size_read = f.Read(buffer.get(), expected_length + 1);
|
size_t size_read = f.Read(buffer.get(), expected_length + 1);
|
||||||
EXPECT_EQ(size_read, expected_length);
|
EXPECT_EQ(size_read, expected_length);
|
||||||
EXPECT_EQ(0, memcmp(expected_contents, buffer.get(),
|
EXPECT_EQ(0, memcmp(expected_contents.data(), buffer.get(),
|
||||||
std::min(expected_length, size_read)));
|
std::min(expected_length, size_read)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +151,7 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteAndRead) {
|
|||||||
WriteAndFlush(message.c_str(), message.size());
|
WriteAndFlush(message.c_str(), message.size());
|
||||||
// Since the max log size is 2, we will be causing rotation. Read from the
|
// Since the max log size is 2, we will be causing rotation. Read from the
|
||||||
// next file.
|
// next file.
|
||||||
VerifyFileContents(message.c_str(), message.size(),
|
VerifyFileContents(message, stream_->GetFilePath(1));
|
||||||
stream_->GetFilePath(1));
|
|
||||||
}
|
}
|
||||||
// Check that exactly three files exist.
|
// Check that exactly three files exist.
|
||||||
for (size_t i = 0; i < arraysize(messages); ++i) {
|
for (size_t i = 0; i < arraysize(messages); ++i) {
|
||||||
@ -167,8 +166,7 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteAndRead) {
|
|||||||
|
|
||||||
// Reopen for read.
|
// Reopen for read.
|
||||||
std::string expected_contents("bbccd");
|
std::string expected_contents("bbccd");
|
||||||
VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
|
VerifyStreamRead(expected_contents, dir_path_, kFilePrefix);
|
||||||
dir_path_, kFilePrefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that a write operation (with dir name without delimiter) followed by a
|
// Tests that a write operation (with dir name without delimiter) followed by a
|
||||||
@ -191,7 +189,7 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteWithoutDelimiterAndRead) {
|
|||||||
|
|
||||||
// Reopen for read.
|
// Reopen for read.
|
||||||
std::string expected_contents("bbccd");
|
std::string expected_contents("bbccd");
|
||||||
VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
|
VerifyStreamRead(expected_contents,
|
||||||
dir_path_ + std::string(webrtc::test::kPathDelimiter),
|
dir_path_ + std::string(webrtc::test::kPathDelimiter),
|
||||||
kFilePrefix);
|
kFilePrefix);
|
||||||
}
|
}
|
||||||
@ -215,8 +213,8 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteAndReadWithoutDelimiter) {
|
|||||||
|
|
||||||
// Reopen for read.
|
// Reopen for read.
|
||||||
std::string expected_contents("bbccd");
|
std::string expected_contents("bbccd");
|
||||||
VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
|
VerifyStreamRead(expected_contents, dir_path_.substr(0, dir_path_.size() - 1),
|
||||||
dir_path_.substr(0, dir_path_.size() - 1), kFilePrefix);
|
kFilePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that writing data greater than the total capacity of the files
|
// Tests that writing data greater than the total capacity of the files
|
||||||
@ -230,11 +228,9 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteOverflowAndRead) {
|
|||||||
std::string message("foobarbaz");
|
std::string message("foobarbaz");
|
||||||
WriteAndFlush(message.c_str(), message.size());
|
WriteAndFlush(message.c_str(), message.size());
|
||||||
std::string expected_file_contents("z");
|
std::string expected_file_contents("z");
|
||||||
VerifyFileContents(expected_file_contents.c_str(),
|
VerifyFileContents(expected_file_contents, stream_->GetFilePath(0));
|
||||||
expected_file_contents.size(), stream_->GetFilePath(0));
|
|
||||||
std::string expected_stream_contents("arbaz");
|
std::string expected_stream_contents("arbaz");
|
||||||
VerifyStreamRead(expected_stream_contents.c_str(),
|
VerifyStreamRead(expected_stream_contents, dir_path_, kFilePrefix);
|
||||||
expected_stream_contents.size(), dir_path_, kFilePrefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the returned file paths have the right folder and prefix.
|
// Tests that the returned file paths have the right folder and prefix.
|
||||||
@ -286,15 +282,16 @@ class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test {
|
|||||||
|
|
||||||
// Checks that the stream reads in the expected contents and then returns an
|
// Checks that the stream reads in the expected contents and then returns an
|
||||||
// end of stream result.
|
// end of stream result.
|
||||||
void VerifyStreamRead(const char* expected_contents,
|
void VerifyStreamRead(absl::string_view expected_contents,
|
||||||
const size_t expected_length,
|
|
||||||
absl::string_view dir_path) {
|
absl::string_view dir_path) {
|
||||||
|
size_t expected_length = expected_contents.size();
|
||||||
CallSessionFileRotatingStreamReader reader(dir_path);
|
CallSessionFileRotatingStreamReader reader(dir_path);
|
||||||
EXPECT_EQ(reader.GetSize(), expected_length);
|
EXPECT_EQ(reader.GetSize(), expected_length);
|
||||||
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
|
std::unique_ptr<uint8_t[]> buffer(new uint8_t[expected_length]);
|
||||||
memset(buffer.get(), 0, expected_length);
|
memset(buffer.get(), 0, expected_length);
|
||||||
EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
|
EXPECT_EQ(expected_length, reader.ReadAll(buffer.get(), expected_length));
|
||||||
EXPECT_EQ(0, memcmp(expected_contents, buffer.get(), expected_length));
|
EXPECT_EQ(0,
|
||||||
|
memcmp(expected_contents.data(), buffer.get(), expected_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CallSessionFileRotatingStream> stream_;
|
std::unique_ptr<CallSessionFileRotatingStream> stream_;
|
||||||
@ -310,8 +307,7 @@ TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadSmallest) {
|
|||||||
std::string message("abcde");
|
std::string message("abcde");
|
||||||
WriteAndFlush(message.c_str(), message.size());
|
WriteAndFlush(message.c_str(), message.size());
|
||||||
std::string expected_contents("abe");
|
std::string expected_contents("abe");
|
||||||
VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
|
VerifyStreamRead(expected_contents, dir_path_);
|
||||||
dir_path_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that writing and reading to a stream with capacity lesser than 4MB
|
// Tests that writing and reading to a stream with capacity lesser than 4MB
|
||||||
@ -323,8 +319,7 @@ TEST_F(MAYBE_CallSessionFileRotatingStreamTest, WriteAndReadSmall) {
|
|||||||
std::string message("123456789");
|
std::string message("123456789");
|
||||||
WriteAndFlush(message.c_str(), message.size());
|
WriteAndFlush(message.c_str(), message.size());
|
||||||
std::string expected_contents("1234789");
|
std::string expected_contents("1234789");
|
||||||
VerifyStreamRead(expected_contents.c_str(), expected_contents.size(),
|
VerifyStreamRead(expected_contents, dir_path_);
|
||||||
dir_path_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that writing and reading to a stream with capacity greater than 4MB
|
// Tests that writing and reading to a stream with capacity greater than 4MB
|
||||||
|
|||||||
@ -120,14 +120,14 @@ const ConstantToLabel SECURITY_ERRORS[] = {
|
|||||||
typedef std::pair<std::string, std::string> HttpAttribute;
|
typedef std::pair<std::string, std::string> HttpAttribute;
|
||||||
typedef std::vector<HttpAttribute> HttpAttributeList;
|
typedef std::vector<HttpAttribute> HttpAttributeList;
|
||||||
|
|
||||||
inline bool IsEndOfAttributeName(size_t pos, size_t len, const char* data) {
|
inline bool IsEndOfAttributeName(size_t pos, absl::string_view data) {
|
||||||
if (pos >= len)
|
if (pos >= data.size())
|
||||||
return true;
|
return true;
|
||||||
if (isspace(static_cast<unsigned char>(data[pos])))
|
if (isspace(static_cast<unsigned char>(data[pos])))
|
||||||
return true;
|
return true;
|
||||||
// The reason for this complexity is that some attributes may contain trailing
|
// The reason for this complexity is that some attributes may contain trailing
|
||||||
// equal signs (like base64 tokens in Negotiate auth headers)
|
// equal signs (like base64 tokens in Negotiate auth headers)
|
||||||
if ((pos + 1 < len) && (data[pos] == '=') &&
|
if ((pos + 1 < data.size()) && (data[pos] == '=') &&
|
||||||
!isspace(static_cast<unsigned char>(data[pos + 1])) &&
|
!isspace(static_cast<unsigned char>(data[pos + 1])) &&
|
||||||
(data[pos + 1] != '=')) {
|
(data[pos + 1] != '=')) {
|
||||||
return true;
|
return true;
|
||||||
@ -135,10 +135,10 @@ inline bool IsEndOfAttributeName(size_t pos, size_t len, const char* data) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpParseAttributes(const char* data,
|
void HttpParseAttributes(absl::string_view data,
|
||||||
size_t len,
|
|
||||||
HttpAttributeList& attributes) {
|
HttpAttributeList& attributes) {
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
const size_t len = data.size();
|
||||||
while (true) {
|
while (true) {
|
||||||
// Skip leading whitespace
|
// Skip leading whitespace
|
||||||
while ((pos < len) && isspace(static_cast<unsigned char>(data[pos]))) {
|
while ((pos < len) && isspace(static_cast<unsigned char>(data[pos]))) {
|
||||||
@ -151,12 +151,12 @@ void HttpParseAttributes(const char* data,
|
|||||||
|
|
||||||
// Find end of attribute name
|
// Find end of attribute name
|
||||||
size_t start = pos;
|
size_t start = pos;
|
||||||
while (!IsEndOfAttributeName(pos, len, data)) {
|
while (!IsEndOfAttributeName(pos, data)) {
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpAttribute attribute;
|
HttpAttribute attribute;
|
||||||
attribute.first.assign(data + start, data + pos);
|
attribute.first.assign(data.data() + start, data.data() + pos);
|
||||||
|
|
||||||
// Attribute has value?
|
// Attribute has value?
|
||||||
if ((pos < len) && (data[pos] == '=')) {
|
if ((pos < len) && (data[pos] == '=')) {
|
||||||
@ -250,8 +250,7 @@ struct NegotiateAuthContext : public HttpAuthContext {
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
HttpAuthResult HttpAuthenticate(const char* challenge,
|
HttpAuthResult HttpAuthenticate(absl::string_view challenge,
|
||||||
size_t len,
|
|
||||||
const SocketAddress& server,
|
const SocketAddress& server,
|
||||||
absl::string_view method,
|
absl::string_view method,
|
||||||
absl::string_view uri,
|
absl::string_view uri,
|
||||||
@ -261,7 +260,7 @@ HttpAuthResult HttpAuthenticate(const char* challenge,
|
|||||||
std::string& response,
|
std::string& response,
|
||||||
std::string& auth_method) {
|
std::string& auth_method) {
|
||||||
HttpAttributeList args;
|
HttpAttributeList args;
|
||||||
HttpParseAttributes(challenge, len, args);
|
HttpParseAttributes(challenge, args);
|
||||||
HttpHasNthAttribute(args, 0, &auth_method, nullptr);
|
HttpHasNthAttribute(args, 0, &auth_method, nullptr);
|
||||||
|
|
||||||
if (context && (context->auth_method != auth_method))
|
if (context && (context->auth_method != auth_method))
|
||||||
|
|||||||
@ -36,8 +36,7 @@ enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR };
|
|||||||
// Start by passing a null pointer, then pass the same pointer each additional
|
// Start by passing a null pointer, then pass the same pointer each additional
|
||||||
// call. When the authentication attempt is finished, delete the context.
|
// call. When the authentication attempt is finished, delete the context.
|
||||||
// TODO(bugs.webrtc.org/8905): Change "response" to "ZeroOnFreeBuffer".
|
// TODO(bugs.webrtc.org/8905): Change "response" to "ZeroOnFreeBuffer".
|
||||||
HttpAuthResult HttpAuthenticate(const char* challenge,
|
HttpAuthResult HttpAuthenticate(absl::string_view challenge,
|
||||||
size_t len,
|
|
||||||
const SocketAddress& server,
|
const SocketAddress& server,
|
||||||
absl::string_view method,
|
absl::string_view method,
|
||||||
absl::string_view uri,
|
absl::string_view uri,
|
||||||
|
|||||||
@ -283,10 +283,9 @@ bool IPFromString(absl::string_view str, IPAddress* out) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
in_addr addr;
|
in_addr addr;
|
||||||
const std::string str_copy = std::string(str);
|
if (rtc::inet_pton(AF_INET, str, &addr) == 0) {
|
||||||
if (rtc::inet_pton(AF_INET, str_copy.c_str(), &addr) == 0) {
|
|
||||||
in6_addr addr6;
|
in6_addr addr6;
|
||||||
if (rtc::inet_pton(AF_INET6, str_copy.c_str(), &addr6) == 0) {
|
if (rtc::inet_pton(AF_INET6, str, &addr6) == 0) {
|
||||||
*out = IPAddress();
|
*out = IPAddress();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path,
|
FileRotatingLogSink::FileRotatingLogSink(absl::string_view log_dir_path,
|
||||||
const std::string& log_prefix,
|
absl::string_view log_prefix,
|
||||||
size_t max_log_size,
|
size_t max_log_size,
|
||||||
size_t num_log_files)
|
size_t num_log_files)
|
||||||
: FileRotatingLogSink(new FileRotatingStream(log_dir_path,
|
: FileRotatingLogSink(new FileRotatingStream(log_dir_path,
|
||||||
@ -69,7 +69,7 @@ bool FileRotatingLogSink::DisableBuffering() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink(
|
CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink(
|
||||||
const std::string& log_dir_path,
|
absl::string_view log_dir_path,
|
||||||
size_t max_total_log_size)
|
size_t max_total_log_size)
|
||||||
: FileRotatingLogSink(
|
: FileRotatingLogSink(
|
||||||
new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) {
|
new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) {
|
||||||
|
|||||||
@ -28,8 +28,8 @@ class FileRotatingLogSink : public LogSink {
|
|||||||
public:
|
public:
|
||||||
// `num_log_files` must be greater than 1 and `max_log_size` must be greater
|
// `num_log_files` must be greater than 1 and `max_log_size` must be greater
|
||||||
// than 0.
|
// than 0.
|
||||||
FileRotatingLogSink(const std::string& log_dir_path,
|
FileRotatingLogSink(absl::string_view log_dir_path,
|
||||||
const std::string& log_prefix,
|
absl::string_view log_prefix,
|
||||||
size_t max_log_size,
|
size_t max_log_size,
|
||||||
size_t num_log_files);
|
size_t num_log_files);
|
||||||
~FileRotatingLogSink() override;
|
~FileRotatingLogSink() override;
|
||||||
@ -62,7 +62,7 @@ class FileRotatingLogSink : public LogSink {
|
|||||||
// Init() must be called before adding this sink.
|
// Init() must be called before adding this sink.
|
||||||
class CallSessionFileRotatingLogSink : public FileRotatingLogSink {
|
class CallSessionFileRotatingLogSink : public FileRotatingLogSink {
|
||||||
public:
|
public:
|
||||||
CallSessionFileRotatingLogSink(const std::string& log_dir_path,
|
CallSessionFileRotatingLogSink(absl::string_view log_dir_path,
|
||||||
size_t max_total_log_size);
|
size_t max_total_log_size);
|
||||||
~CallSessionFileRotatingLogSink() override;
|
~CallSessionFileRotatingLogSink() override;
|
||||||
|
|
||||||
|
|||||||
@ -188,7 +188,7 @@ LogMessage::LogMessage(const char* file,
|
|||||||
LogMessage::LogMessage(const char* file,
|
LogMessage::LogMessage(const char* file,
|
||||||
int line,
|
int line,
|
||||||
LoggingSeverity sev,
|
LoggingSeverity sev,
|
||||||
const std::string& tag)
|
absl::string_view tag)
|
||||||
: LogMessage(file, line, sev) {
|
: LogMessage(file, line, sev) {
|
||||||
print_stream_ << tag << ": ";
|
print_stream_ << tag << ": ";
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ void LogMessage::RemoveLogToStream(LogSink* stream) {
|
|||||||
UpdateMinLogSeverity();
|
UpdateMinLogSeverity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogMessage::ConfigureLogging(const char* params) {
|
void LogMessage::ConfigureLogging(absl::string_view params) {
|
||||||
LoggingSeverity current_level = LS_VERBOSE;
|
LoggingSeverity current_level = LS_VERBOSE;
|
||||||
LoggingSeverity debug_level = GetLogToDebug();
|
LoggingSeverity debug_level = GetLogToDebug();
|
||||||
|
|
||||||
@ -355,13 +355,14 @@ void LogMessage::UpdateMinLogSeverity()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WEBRTC_ANDROID)
|
#if defined(WEBRTC_ANDROID)
|
||||||
void LogMessage::OutputToDebug(const std::string& str,
|
void LogMessage::OutputToDebug(absl::string_view str,
|
||||||
LoggingSeverity severity,
|
LoggingSeverity severity,
|
||||||
const char* tag) {
|
const char* tag) {
|
||||||
#else
|
#else
|
||||||
void LogMessage::OutputToDebug(const std::string& str,
|
void LogMessage::OutputToDebug(absl::string_view str,
|
||||||
LoggingSeverity severity) {
|
LoggingSeverity severity) {
|
||||||
#endif
|
#endif
|
||||||
|
std::string str_str = std::string(str);
|
||||||
bool log_to_stderr = log_to_stderr_;
|
bool log_to_stderr = log_to_stderr_;
|
||||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && defined(NDEBUG)
|
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && defined(NDEBUG)
|
||||||
// On the Mac, all stderr output goes to the Console log and causes clutter.
|
// On the Mac, all stderr output goes to the Console log and causes clutter.
|
||||||
@ -386,7 +387,7 @@ void LogMessage::OutputToDebug(const std::string& str,
|
|||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
// Always log to the debugger.
|
// Always log to the debugger.
|
||||||
// Perhaps stderr should be controlled by a preference, as on Mac?
|
// Perhaps stderr should be controlled by a preference, as on Mac?
|
||||||
OutputDebugStringA(str.c_str());
|
OutputDebugStringA(str_str.c_str());
|
||||||
if (log_to_stderr) {
|
if (log_to_stderr) {
|
||||||
// This handles dynamically allocated consoles, too.
|
// This handles dynamically allocated consoles, too.
|
||||||
if (HANDLE error_handle = ::GetStdHandle(STD_ERROR_HANDLE)) {
|
if (HANDLE error_handle = ::GetStdHandle(STD_ERROR_HANDLE)) {
|
||||||
@ -426,14 +427,14 @@ void LogMessage::OutputToDebug(const std::string& str,
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
const int max_lines = size / kMaxLogLineSize + 1;
|
const int max_lines = size / kMaxLogLineSize + 1;
|
||||||
if (max_lines == 1) {
|
if (max_lines == 1) {
|
||||||
__android_log_print(prio, tag, "%.*s", size, str.c_str());
|
__android_log_print(prio, tag, "%.*s", size, str_str.c_str());
|
||||||
} else {
|
} else {
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
const int len = std::min(size, kMaxLogLineSize);
|
const int len = std::min(size, kMaxLogLineSize);
|
||||||
// Use the size of the string in the format (str may have \0 in the
|
// Use the size of the string in the format (str may have \0 in the
|
||||||
// middle).
|
// middle).
|
||||||
__android_log_print(prio, tag, "[%d/%d] %.*s", line + 1, max_lines, len,
|
__android_log_print(prio, tag, "[%d/%d] %.*s", line + 1, max_lines, len,
|
||||||
str.c_str() + idx);
|
str_str.c_str() + idx);
|
||||||
idx += len;
|
idx += len;
|
||||||
size -= len;
|
size -= len;
|
||||||
++line;
|
++line;
|
||||||
@ -441,7 +442,7 @@ void LogMessage::OutputToDebug(const std::string& str,
|
|||||||
}
|
}
|
||||||
#endif // WEBRTC_ANDROID
|
#endif // WEBRTC_ANDROID
|
||||||
if (log_to_stderr) {
|
if (log_to_stderr) {
|
||||||
fprintf(stderr, "%s", str.c_str());
|
fprintf(stderr, "%s", str_str.c_str());
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -439,7 +439,7 @@ class LogMessage {
|
|||||||
LogMessage(const char* file,
|
LogMessage(const char* file,
|
||||||
int line,
|
int line,
|
||||||
LoggingSeverity sev,
|
LoggingSeverity sev,
|
||||||
const std::string& tag);
|
absl::string_view tag);
|
||||||
~LogMessage();
|
~LogMessage();
|
||||||
|
|
||||||
LogMessage(const LogMessage&) = delete;
|
LogMessage(const LogMessage&) = delete;
|
||||||
@ -485,7 +485,7 @@ class LogMessage {
|
|||||||
static int GetMinLogSeverity();
|
static int GetMinLogSeverity();
|
||||||
// Parses the provided parameter stream to configure the options above.
|
// Parses the provided parameter stream to configure the options above.
|
||||||
// Useful for configuring logging from the command line.
|
// Useful for configuring logging from the command line.
|
||||||
static void ConfigureLogging(const char* params);
|
static void ConfigureLogging(absl::string_view params);
|
||||||
// Checks the current global debug severity and if the `streams_` collection
|
// Checks the current global debug severity and if the `streams_` collection
|
||||||
// is empty. If `severity` is smaller than the global severity and if the
|
// is empty. If `severity` is smaller than the global severity and if the
|
||||||
// `streams_` collection is empty, the LogMessage will be considered a noop
|
// `streams_` collection is empty, the LogMessage will be considered a noop
|
||||||
@ -516,7 +516,7 @@ class LogMessage {
|
|||||||
LogMessage(const char* file,
|
LogMessage(const char* file,
|
||||||
int line,
|
int line,
|
||||||
LoggingSeverity sev,
|
LoggingSeverity sev,
|
||||||
const std::string& tag) {}
|
absl::string_view tag) {}
|
||||||
~LogMessage() = default;
|
~LogMessage() = default;
|
||||||
|
|
||||||
inline void AddTag(const char* tag) {}
|
inline void AddTag(const char* tag) {}
|
||||||
@ -534,7 +534,7 @@ class LogMessage {
|
|||||||
inline static void RemoveLogToStream(LogSink* stream) {}
|
inline static void RemoveLogToStream(LogSink* stream) {}
|
||||||
inline static int GetLogToStream(LogSink* stream = nullptr) { return 0; }
|
inline static int GetLogToStream(LogSink* stream = nullptr) { return 0; }
|
||||||
inline static int GetMinLogSeverity() { return 0; }
|
inline static int GetMinLogSeverity() { return 0; }
|
||||||
inline static void ConfigureLogging(const char* params) {}
|
inline static void ConfigureLogging(absl::string_view params) {}
|
||||||
static constexpr bool IsNoop(LoggingSeverity severity) { return true; }
|
static constexpr bool IsNoop(LoggingSeverity severity) { return true; }
|
||||||
template <LoggingSeverity S>
|
template <LoggingSeverity S>
|
||||||
static constexpr bool IsNoop() {
|
static constexpr bool IsNoop() {
|
||||||
@ -551,11 +551,11 @@ class LogMessage {
|
|||||||
|
|
||||||
// These write out the actual log messages.
|
// These write out the actual log messages.
|
||||||
#if defined(WEBRTC_ANDROID)
|
#if defined(WEBRTC_ANDROID)
|
||||||
static void OutputToDebug(const std::string& msg,
|
static void OutputToDebug(absl::string_view msg,
|
||||||
LoggingSeverity severity,
|
LoggingSeverity severity,
|
||||||
const char* tag);
|
const char* tag);
|
||||||
#else
|
#else
|
||||||
static void OutputToDebug(const std::string& msg, LoggingSeverity severity);
|
static void OutputToDebug(absl::string_view msg, LoggingSeverity severity);
|
||||||
#endif // defined(WEBRTC_ANDROID)
|
#endif // defined(WEBRTC_ANDROID)
|
||||||
|
|
||||||
// Called from the dtor (or from a test) to append optional extra error
|
// Called from the dtor (or from a test) to append optional extra error
|
||||||
@ -592,11 +592,11 @@ class LogMessage {
|
|||||||
// Next methods do nothing; no one will call these functions.
|
// Next methods do nothing; no one will call these functions.
|
||||||
inline static void UpdateMinLogSeverity() {}
|
inline static void UpdateMinLogSeverity() {}
|
||||||
#if defined(WEBRTC_ANDROID)
|
#if defined(WEBRTC_ANDROID)
|
||||||
inline static void OutputToDebug(const std::string& msg,
|
inline static void OutputToDebug(absl::string_view msg,
|
||||||
LoggingSeverity severity,
|
LoggingSeverity severity,
|
||||||
const char* tag) {}
|
const char* tag) {}
|
||||||
#else
|
#else
|
||||||
inline static void OutputToDebug(const std::string& msg,
|
inline static void OutputToDebug(absl::string_view msg,
|
||||||
LoggingSeverity severity) {}
|
LoggingSeverity severity) {}
|
||||||
#endif // defined(WEBRTC_ANDROID)
|
#endif // defined(WEBRTC_ANDROID)
|
||||||
inline void FinishPrintStream() {}
|
inline void FinishPrintStream() {}
|
||||||
|
|||||||
@ -11,6 +11,9 @@
|
|||||||
#include "rtc_base/net_helpers.h"
|
#include "rtc_base/net_helpers.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
#include <ws2spi.h>
|
#include <ws2spi.h>
|
||||||
@ -37,11 +40,12 @@ const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int inet_pton(int af, const char* src, void* dst) {
|
int inet_pton(int af, absl::string_view src, void* dst) {
|
||||||
|
std::string src_str = std::string(src);
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
return win32_inet_pton(af, src, dst);
|
return win32_inet_pton(af, src_str.c_str(), dst);
|
||||||
#else
|
#else
|
||||||
return ::inet_pton(af, src, dst);
|
return ::inet_pton(af, src_str.c_str(), dst);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,12 +19,14 @@
|
|||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win32.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
// rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid
|
// rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid
|
||||||
// the windows-native versions of these.
|
// the windows-native versions of these.
|
||||||
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
||||||
int inet_pton(int af, const char* src, void* dst);
|
int inet_pton(int af, absl::string_view src, void* dst);
|
||||||
|
|
||||||
bool HasIPv4Enabled();
|
bool HasIPv4Enabled();
|
||||||
bool HasIPv6Enabled();
|
bool HasIPv6Enabled();
|
||||||
|
|||||||
@ -216,7 +216,7 @@ bool MatchTypeNameWithIndexPattern(absl::string_view network_name,
|
|||||||
// result of the downstream network filtering, see e.g.
|
// result of the downstream network filtering, see e.g.
|
||||||
// BasicPortAllocatorSession::GetNetworks when
|
// BasicPortAllocatorSession::GetNetworks when
|
||||||
// PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is turned on.
|
// PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is turned on.
|
||||||
AdapterType GetAdapterTypeFromName(const char* network_name) {
|
AdapterType GetAdapterTypeFromName(absl::string_view network_name) {
|
||||||
if (MatchTypeNameWithIndexPattern(network_name, "lo")) {
|
if (MatchTypeNameWithIndexPattern(network_name, "lo")) {
|
||||||
// Note that we have a more robust way to determine if a network interface
|
// Note that we have a more robust way to determine if a network interface
|
||||||
// is a loopback interface by checking the flag IFF_LOOPBACK in ifa_flags of
|
// is a loopback interface by checking the flag IFF_LOOPBACK in ifa_flags of
|
||||||
|
|||||||
@ -63,7 +63,7 @@ std::string MakeNetworkKey(absl::string_view name,
|
|||||||
// Utility function that attempts to determine an adapter type by an interface
|
// Utility function that attempts to determine an adapter type by an interface
|
||||||
// name (e.g., "wlan0"). Can be used by NetworkManager subclasses when other
|
// name (e.g., "wlan0"). Can be used by NetworkManager subclasses when other
|
||||||
// mechanisms fail to determine the type.
|
// mechanisms fail to determine the type.
|
||||||
RTC_EXPORT AdapterType GetAdapterTypeFromName(const char* network_name);
|
RTC_EXPORT AdapterType GetAdapterTypeFromName(absl::string_view network_name);
|
||||||
|
|
||||||
class DefaultLocalAddressProvider {
|
class DefaultLocalAddressProvider {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -252,11 +252,11 @@ void OpenSSLAdapter::SetRole(SSLRole role) {
|
|||||||
role_ = role;
|
role_ = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenSSLAdapter::StartSSL(const char* hostname) {
|
int OpenSSLAdapter::StartSSL(absl::string_view hostname) {
|
||||||
if (state_ != SSL_NONE)
|
if (state_ != SSL_NONE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ssl_host_name_ = hostname;
|
ssl_host_name_.assign(hostname.data(), hostname.size());
|
||||||
|
|
||||||
if (GetSocket()->GetState() != Socket::CS_CONNECTED) {
|
if (GetSocket()->GetState() != Socket::CS_CONNECTED) {
|
||||||
state_ = SSL_WAIT;
|
state_ = SSL_WAIT;
|
||||||
@ -422,7 +422,7 @@ int OpenSSLAdapter::ContinueSSL() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenSSLAdapter::Error(const char* context, int err, bool signal) {
|
void OpenSSLAdapter::Error(absl::string_view context, int err, bool signal) {
|
||||||
RTC_LOG(LS_WARNING) << "OpenSSLAdapter::Error(" << context << ", " << err
|
RTC_LOG(LS_WARNING) << "OpenSSLAdapter::Error(" << context << ", " << err
|
||||||
<< ")";
|
<< ")";
|
||||||
state_ = SSL_ERROR;
|
state_ = SSL_ERROR;
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class OpenSSLAdapter final : public SSLAdapter,
|
|||||||
void SetCertVerifier(SSLCertificateVerifier* ssl_cert_verifier) override;
|
void SetCertVerifier(SSLCertificateVerifier* ssl_cert_verifier) override;
|
||||||
void SetIdentity(std::unique_ptr<SSLIdentity> identity) override;
|
void SetIdentity(std::unique_ptr<SSLIdentity> identity) override;
|
||||||
void SetRole(SSLRole role) override;
|
void SetRole(SSLRole role) override;
|
||||||
int StartSSL(const char* hostname) override;
|
int StartSSL(absl::string_view hostname) override;
|
||||||
int Send(const void* pv, size_t cb) override;
|
int Send(const void* pv, size_t cb) override;
|
||||||
int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override;
|
int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override;
|
||||||
int Recv(void* pv, size_t cb, int64_t* timestamp) override;
|
int Recv(void* pv, size_t cb, int64_t* timestamp) override;
|
||||||
@ -110,7 +110,7 @@ class OpenSSLAdapter final : public SSLAdapter,
|
|||||||
|
|
||||||
int BeginSSL();
|
int BeginSSL();
|
||||||
int ContinueSSL();
|
int ContinueSSL();
|
||||||
void Error(const char* context, int err, bool signal = true);
|
void Error(absl::string_view context, int err, bool signal = true);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
// Return value and arguments have the same meanings as for Send; `error` is
|
// Return value and arguments have the same meanings as for Send; `error` is
|
||||||
|
|||||||
@ -956,7 +956,7 @@ int OpenSSLStreamAdapter::ContinueSSL() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenSSLStreamAdapter::Error(const char* context,
|
void OpenSSLStreamAdapter::Error(absl::string_view context,
|
||||||
int err,
|
int err,
|
||||||
uint8_t alert,
|
uint8_t alert,
|
||||||
bool signal) {
|
bool signal) {
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter {
|
|||||||
// `alert` indicates an alert description (one of the SSL_AD constants) to
|
// `alert` indicates an alert description (one of the SSL_AD constants) to
|
||||||
// send to the remote endpoint when closing the association. If 0, a normal
|
// send to the remote endpoint when closing the association. If 0, a normal
|
||||||
// shutdown will be performed.
|
// shutdown will be performed.
|
||||||
void Error(const char* context, int err, uint8_t alert, bool signal);
|
void Error(absl::string_view context, int err, uint8_t alert, bool signal);
|
||||||
void Cleanup(uint8_t alert);
|
void Cleanup(uint8_t alert);
|
||||||
|
|
||||||
// Flush the input buffers by reading left bytes (for DTLS)
|
// Flush the input buffers by reading left bytes (for DTLS)
|
||||||
|
|||||||
@ -411,8 +411,9 @@ void AsyncHttpsProxySocket::ProcessLine(char* data, size_t len) {
|
|||||||
} else if ((state_ == PS_AUTHENTICATE) &&
|
} else if ((state_ == PS_AUTHENTICATE) &&
|
||||||
absl::StartsWithIgnoreCase(data, "Proxy-Authenticate:")) {
|
absl::StartsWithIgnoreCase(data, "Proxy-Authenticate:")) {
|
||||||
std::string response, auth_method;
|
std::string response, auth_method;
|
||||||
switch (HttpAuthenticate(data + 19, len - 19, proxy_, "CONNECT", "/", user_,
|
switch (HttpAuthenticate(absl::string_view(data + 19, len - 19), proxy_,
|
||||||
pass_, context_, response, auth_method)) {
|
"CONNECT", "/", user_, pass_, context_, response,
|
||||||
|
auth_method)) {
|
||||||
case HAR_IGNORE:
|
case HAR_IGNORE:
|
||||||
RTC_LOG(LS_VERBOSE) << "Ignoring Proxy-Authenticate: " << auth_method;
|
RTC_LOG(LS_VERBOSE) << "Ignoring Proxy-Authenticate: " << auth_method;
|
||||||
if (!unknown_mechanisms_.empty())
|
if (!unknown_mechanisms_.empty())
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "rtc_base/async_socket.h"
|
#include "rtc_base/async_socket.h"
|
||||||
#include "rtc_base/ssl_certificate.h"
|
#include "rtc_base/ssl_certificate.h"
|
||||||
#include "rtc_base/ssl_identity.h"
|
#include "rtc_base/ssl_identity.h"
|
||||||
@ -89,7 +90,7 @@ class SSLAdapter : public AsyncSocketAdapter {
|
|||||||
// StartSSL returns 0 if successful.
|
// StartSSL returns 0 if successful.
|
||||||
// If StartSSL is called while the socket is closed or connecting, the SSL
|
// If StartSSL is called while the socket is closed or connecting, the SSL
|
||||||
// negotiation will begin as soon as the socket connects.
|
// negotiation will begin as soon as the socket connects.
|
||||||
virtual int StartSSL(const char* hostname) = 0;
|
virtual int StartSSL(absl::string_view hostname) = 0;
|
||||||
|
|
||||||
// When an SSLAdapterFactory is used, an SSLAdapter may be used to resume
|
// When an SSLAdapterFactory is used, an SSLAdapter may be used to resume
|
||||||
// a previous SSL session, which results in an abbreviated handshake.
|
// a previous SSL session, which results in an abbreviated handshake.
|
||||||
|
|||||||
@ -110,7 +110,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> {
|
|||||||
RTC_LOG(LS_INFO) << "Starting " << GetSSLProtocolName(ssl_mode_)
|
RTC_LOG(LS_INFO) << "Starting " << GetSSLProtocolName(ssl_mode_)
|
||||||
<< " handshake with " << hostname;
|
<< " handshake with " << hostname;
|
||||||
|
|
||||||
if (ssl_adapter_->StartSSL(std::string(hostname).c_str()) != 0) {
|
if (ssl_adapter_->StartSSL(hostname) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -685,7 +685,7 @@ class SSLStreamAdapterTestBase : public ::testing::Test,
|
|||||||
return server_ssl_->GetSslVersion();
|
return server_ssl_->GetSslVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExportKeyingMaterial(const char* label,
|
bool ExportKeyingMaterial(absl::string_view label,
|
||||||
const unsigned char* context,
|
const unsigned char* context,
|
||||||
size_t context_len,
|
size_t context_len,
|
||||||
bool use_context,
|
bool use_context,
|
||||||
|
|||||||
@ -30,6 +30,7 @@ rtc_library("file_wrapper") {
|
|||||||
"..:criticalsection",
|
"..:criticalsection",
|
||||||
"..:safe_conversions",
|
"..:safe_conversions",
|
||||||
]
|
]
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtc_include_tests) {
|
if (rtc_include_tests) {
|
||||||
|
|||||||
@ -9,10 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rtc_base/system/file_wrapper.h"
|
#include "rtc_base/system/file_wrapper.h"
|
||||||
#include "rtc_base/numerics/safe_conversions.h"
|
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "rtc_base/numerics/safe_conversions.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#else
|
#else
|
||||||
@ -23,14 +25,17 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
FILE* FileOpen(const char* file_name_utf8, bool read_only, int* error) {
|
FILE* FileOpen(absl::string_view file_name_utf8, bool read_only, int* error) {
|
||||||
|
RTC_CHECK_EQ(file_name_utf8.find_first_of('\0'), absl::string_view::npos)
|
||||||
|
<< "Invalid filename, containing NUL character";
|
||||||
|
std::string file_name = std::string(file_name_utf8);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
int len = MultiByteToWideChar(CP_UTF8, 0, file_name_utf8, -1, nullptr, 0);
|
int len = MultiByteToWideChar(CP_UTF8, 0, file_name.c_str(), -1, nullptr, 0);
|
||||||
std::wstring wstr(len, 0);
|
std::wstring wstr(len, 0);
|
||||||
MultiByteToWideChar(CP_UTF8, 0, file_name_utf8, -1, &wstr[0], len);
|
MultiByteToWideChar(CP_UTF8, 0, file_name.c_str(), -1, &wstr[0], len);
|
||||||
FILE* file = _wfopen(wstr.c_str(), read_only ? L"rb" : L"wb");
|
FILE* file = _wfopen(wstr.c_str(), read_only ? L"rb" : L"wb");
|
||||||
#else
|
#else
|
||||||
FILE* file = fopen(file_name_utf8, read_only ? "rb" : "wb");
|
FILE* file = fopen(file_name.c_str(), read_only ? "rb" : "wb");
|
||||||
#endif
|
#endif
|
||||||
if (!file && error) {
|
if (!file && error) {
|
||||||
*error = errno;
|
*error = errno;
|
||||||
@ -38,36 +43,19 @@ FILE* FileOpen(const char* file_name_utf8, bool read_only, int* error) {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetCstrCheckNoEmbeddedNul(const std::string& s) {
|
|
||||||
const char* p = s.c_str();
|
|
||||||
RTC_CHECK_EQ(strlen(p), s.size())
|
|
||||||
<< "Invalid filename, containing NUL character";
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
FileWrapper FileWrapper::OpenReadOnly(const char* file_name_utf8) {
|
FileWrapper FileWrapper::OpenReadOnly(absl::string_view file_name_utf8) {
|
||||||
return FileWrapper(FileOpen(file_name_utf8, true, nullptr));
|
return FileWrapper(FileOpen(file_name_utf8, true, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
FileWrapper FileWrapper::OpenReadOnly(const std::string& file_name_utf8) {
|
FileWrapper FileWrapper::OpenWriteOnly(absl::string_view file_name_utf8,
|
||||||
return OpenReadOnly(GetCstrCheckNoEmbeddedNul(file_name_utf8));
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
FileWrapper FileWrapper::OpenWriteOnly(const char* file_name_utf8,
|
|
||||||
int* error /*=nullptr*/) {
|
int* error /*=nullptr*/) {
|
||||||
return FileWrapper(FileOpen(file_name_utf8, false, error));
|
return FileWrapper(FileOpen(file_name_utf8, false, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
FileWrapper FileWrapper::OpenWriteOnly(const std::string& file_name_utf8,
|
|
||||||
int* error /*=nullptr*/) {
|
|
||||||
return OpenWriteOnly(GetCstrCheckNoEmbeddedNul(file_name_utf8), error);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileWrapper::FileWrapper(FileWrapper&& other) {
|
FileWrapper::FileWrapper(FileWrapper&& other) {
|
||||||
operator=(std::move(other));
|
operator=(std::move(other));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
|
||||||
// Implementation that can read (exclusive) or write from/to a file.
|
// Implementation that can read (exclusive) or write from/to a file.
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -34,11 +36,8 @@ class FileWrapper final {
|
|||||||
// returned object to check if the open operation was successful. On failure,
|
// returned object to check if the open operation was successful. On failure,
|
||||||
// and if `error` is non-null, the system errno value is stored at |*error|.
|
// and if `error` is non-null, the system errno value is stored at |*error|.
|
||||||
// The file is closed by the destructor.
|
// The file is closed by the destructor.
|
||||||
static FileWrapper OpenReadOnly(const char* file_name_utf8);
|
static FileWrapper OpenReadOnly(absl::string_view file_name_utf8);
|
||||||
static FileWrapper OpenReadOnly(const std::string& file_name_utf8);
|
static FileWrapper OpenWriteOnly(absl::string_view file_name_utf8,
|
||||||
static FileWrapper OpenWriteOnly(const char* file_name_utf8,
|
|
||||||
int* error = nullptr);
|
|
||||||
static FileWrapper OpenWriteOnly(const std::string& file_name_utf8,
|
|
||||||
int* error = nullptr);
|
int* error = nullptr);
|
||||||
|
|
||||||
FileWrapper() = default;
|
FileWrapper() = default;
|
||||||
|
|||||||
@ -201,7 +201,7 @@ class TestMainImpl : public TestMain {
|
|||||||
const bool capture_events = !trace_event_path.empty();
|
const bool capture_events = !trace_event_path.empty();
|
||||||
if (capture_events) {
|
if (capture_events) {
|
||||||
rtc::tracing::SetupInternalTracer();
|
rtc::tracing::SetupInternalTracer();
|
||||||
rtc::tracing::StartInternalCapture(trace_event_path.c_str());
|
rtc::tracing::StartInternalCapture(trace_event_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<std::vector<std::string>> metrics_to_plot =
|
absl::optional<std::vector<std::string>> metrics_to_plot =
|
||||||
|
|||||||
@ -356,7 +356,7 @@ TEST_F(RtpVideoStreamReceiver2Test, CacheColorSpaceFromLastPacketOfKeyframe) {
|
|||||||
|
|
||||||
TEST_F(RtpVideoStreamReceiver2Test, GenericKeyFrame) {
|
TEST_F(RtpVideoStreamReceiver2Test, GenericKeyFrame) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
@ -376,7 +376,7 @@ TEST_F(RtpVideoStreamReceiver2Test, PacketInfoIsPropagatedIntoVideoFrames) {
|
|||||||
extension_map.Register<AbsoluteCaptureTimeExtension>(kId0);
|
extension_map.Register<AbsoluteCaptureTimeExtension>(kId0);
|
||||||
RtpPacketReceived rtp_packet(&extension_map);
|
RtpPacketReceived rtp_packet(&extension_map);
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
rtp_packet.SetTimestamp(1);
|
rtp_packet.SetTimestamp(1);
|
||||||
rtp_packet.SetSsrc(kSsrc);
|
rtp_packet.SetSsrc(kSsrc);
|
||||||
@ -407,7 +407,7 @@ TEST_F(RtpVideoStreamReceiver2Test,
|
|||||||
RtpPacketReceived rtp_packet(&extension_map);
|
RtpPacketReceived rtp_packet(&extension_map);
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
|
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
uint16_t sequence_number = 1;
|
uint16_t sequence_number = 1;
|
||||||
uint32_t rtp_timestamp = 1;
|
uint32_t rtp_timestamp = 1;
|
||||||
rtp_packet.SetSequenceNumber(sequence_number);
|
rtp_packet.SetSequenceNumber(sequence_number);
|
||||||
@ -485,7 +485,7 @@ TEST_F(RtpVideoStreamReceiver2Test,
|
|||||||
TEST_F(RtpVideoStreamReceiver2Test, GenericKeyFrameBitstreamError) {
|
TEST_F(RtpVideoStreamReceiver2Test, GenericKeyFrameBitstreamError) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
||||||
@ -587,7 +587,7 @@ TEST_P(RtpVideoStreamReceiver2TestH264, OutOfBandFmtpSpsPps) {
|
|||||||
video_header.is_last_packet_in_frame = true;
|
video_header.is_last_packet_in_frame = true;
|
||||||
video_header.codec = kVideoCodecH264;
|
video_header.codec = kVideoCodecH264;
|
||||||
video_header.frame_type = VideoFrameType::kVideoFrameKey;
|
video_header.frame_type = VideoFrameType::kVideoFrameKey;
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3'});
|
||||||
mock_on_complete_frame_callback_.AppendExpectedBitstream(
|
mock_on_complete_frame_callback_.AppendExpectedBitstream(
|
||||||
kH264StartCode, sizeof(kH264StartCode));
|
kH264StartCode, sizeof(kH264StartCode));
|
||||||
mock_on_complete_frame_callback_.AppendExpectedBitstream(data.data(),
|
mock_on_complete_frame_callback_.AppendExpectedBitstream(data.data(),
|
||||||
@ -669,7 +669,7 @@ TEST_P(RtpVideoStreamReceiver2TestH264, ForceSpsPpsIdrIsKeyframe) {
|
|||||||
TEST_F(RtpVideoStreamReceiver2Test, PaddingInMediaStream) {
|
TEST_F(RtpVideoStreamReceiver2Test, PaddingInMediaStream) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
RTPVideoHeader video_header = GetDefaultH264VideoHeader();
|
RTPVideoHeader video_header = GetDefaultH264VideoHeader();
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3'});
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtp_packet.SetSequenceNumber(2);
|
rtp_packet.SetSequenceNumber(2);
|
||||||
video_header.is_first_packet_in_frame = true;
|
video_header.is_first_packet_in_frame = true;
|
||||||
@ -706,7 +706,7 @@ TEST_F(RtpVideoStreamReceiver2Test, PaddingInMediaStream) {
|
|||||||
TEST_F(RtpVideoStreamReceiver2Test, RequestKeyframeIfFirstFrameIsDelta) {
|
TEST_F(RtpVideoStreamReceiver2Test, RequestKeyframeIfFirstFrameIsDelta) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
||||||
@ -720,7 +720,7 @@ TEST_F(RtpVideoStreamReceiver2Test, RequestKeyframeWhenPacketBufferGetsFull) {
|
|||||||
|
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
||||||
// Incomplete frames so that the packet buffer is filling up.
|
// Incomplete frames so that the packet buffer is filling up.
|
||||||
@ -1125,7 +1125,7 @@ TEST_F(RtpVideoStreamReceiver2Test, TransformFrame) {
|
|||||||
|
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
||||||
@ -1165,7 +1165,7 @@ INSTANTIATE_TEST_SUITE_P(PlayoutDelay,
|
|||||||
Values(kDefaultBehavior, kOverridePlayoutDelay));
|
Values(kDefaultBehavior, kOverridePlayoutDelay));
|
||||||
|
|
||||||
TEST_P(RtpVideoStreamReceiver2TestPlayoutDelay, PlayoutDelay) {
|
TEST_P(RtpVideoStreamReceiver2TestPlayoutDelay, PlayoutDelay) {
|
||||||
rtc::CopyOnWriteBuffer payload_data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer payload_data({'1', '2', '3', '4'});
|
||||||
RtpHeaderExtensionMap extension_map;
|
RtpHeaderExtensionMap extension_map;
|
||||||
extension_map.Register<PlayoutDelayLimits>(1);
|
extension_map.Register<PlayoutDelayLimits>(1);
|
||||||
RtpPacketToSend packet_to_send(&extension_map);
|
RtpPacketToSend packet_to_send(&extension_map);
|
||||||
|
|||||||
@ -337,7 +337,7 @@ TEST_F(RtpVideoStreamReceiverTest, CacheColorSpaceFromLastPacketOfKeyframe) {
|
|||||||
|
|
||||||
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrame) {
|
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrame) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
@ -357,7 +357,7 @@ TEST_F(RtpVideoStreamReceiverTest, PacketInfoIsPropagatedIntoVideoFrames) {
|
|||||||
extension_map.Register<AbsoluteCaptureTimeExtension>(kId0);
|
extension_map.Register<AbsoluteCaptureTimeExtension>(kId0);
|
||||||
RtpPacketReceived rtp_packet(&extension_map);
|
RtpPacketReceived rtp_packet(&extension_map);
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
rtp_packet.SetTimestamp(1);
|
rtp_packet.SetTimestamp(1);
|
||||||
rtp_packet.SetSsrc(kSsrc);
|
rtp_packet.SetSsrc(kSsrc);
|
||||||
@ -388,7 +388,7 @@ TEST_F(RtpVideoStreamReceiverTest,
|
|||||||
RtpPacketReceived rtp_packet(&extension_map);
|
RtpPacketReceived rtp_packet(&extension_map);
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
|
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
uint16_t sequence_number = 1;
|
uint16_t sequence_number = 1;
|
||||||
uint32_t rtp_timestamp = 1;
|
uint32_t rtp_timestamp = 1;
|
||||||
rtp_packet.SetSequenceNumber(sequence_number);
|
rtp_packet.SetSequenceNumber(sequence_number);
|
||||||
@ -465,7 +465,7 @@ TEST_F(RtpVideoStreamReceiverTest,
|
|||||||
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrameBitstreamError) {
|
TEST_F(RtpVideoStreamReceiverTest, GenericKeyFrameBitstreamError) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
||||||
@ -567,7 +567,7 @@ TEST_P(RtpVideoStreamReceiverTestH264, OutOfBandFmtpSpsPps) {
|
|||||||
video_header.is_last_packet_in_frame = true;
|
video_header.is_last_packet_in_frame = true;
|
||||||
video_header.codec = kVideoCodecH264;
|
video_header.codec = kVideoCodecH264;
|
||||||
video_header.frame_type = VideoFrameType::kVideoFrameKey;
|
video_header.frame_type = VideoFrameType::kVideoFrameKey;
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3'});
|
||||||
mock_on_complete_frame_callback_.AppendExpectedBitstream(
|
mock_on_complete_frame_callback_.AppendExpectedBitstream(
|
||||||
kH264StartCode, sizeof(kH264StartCode));
|
kH264StartCode, sizeof(kH264StartCode));
|
||||||
mock_on_complete_frame_callback_.AppendExpectedBitstream(data.data(),
|
mock_on_complete_frame_callback_.AppendExpectedBitstream(data.data(),
|
||||||
@ -649,7 +649,7 @@ TEST_P(RtpVideoStreamReceiverTestH264, ForceSpsPpsIdrIsKeyframe) {
|
|||||||
TEST_F(RtpVideoStreamReceiverTest, PaddingInMediaStream) {
|
TEST_F(RtpVideoStreamReceiverTest, PaddingInMediaStream) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
RTPVideoHeader video_header = GetDefaultH264VideoHeader();
|
RTPVideoHeader video_header = GetDefaultH264VideoHeader();
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3'});
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtp_packet.SetSequenceNumber(2);
|
rtp_packet.SetSequenceNumber(2);
|
||||||
video_header.is_first_packet_in_frame = true;
|
video_header.is_first_packet_in_frame = true;
|
||||||
@ -686,7 +686,7 @@ TEST_F(RtpVideoStreamReceiverTest, PaddingInMediaStream) {
|
|||||||
TEST_F(RtpVideoStreamReceiverTest, RequestKeyframeIfFirstFrameIsDelta) {
|
TEST_F(RtpVideoStreamReceiverTest, RequestKeyframeIfFirstFrameIsDelta) {
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
||||||
@ -700,7 +700,7 @@ TEST_F(RtpVideoStreamReceiverTest, RequestKeyframeWhenPacketBufferGetsFull) {
|
|||||||
|
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameDelta);
|
||||||
// Incomplete frames so that the packet buffer is filling up.
|
// Incomplete frames so that the packet buffer is filling up.
|
||||||
@ -1164,7 +1164,7 @@ TEST_F(RtpVideoStreamReceiverTest, TransformFrame) {
|
|||||||
|
|
||||||
RtpPacketReceived rtp_packet;
|
RtpPacketReceived rtp_packet;
|
||||||
rtp_packet.SetPayloadType(kPayloadType);
|
rtp_packet.SetPayloadType(kPayloadType);
|
||||||
rtc::CopyOnWriteBuffer data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer data({'1', '2', '3', '4'});
|
||||||
rtp_packet.SetSequenceNumber(1);
|
rtp_packet.SetSequenceNumber(1);
|
||||||
RTPVideoHeader video_header =
|
RTPVideoHeader video_header =
|
||||||
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
GetGenericVideoHeader(VideoFrameType::kVideoFrameKey);
|
||||||
@ -1204,7 +1204,7 @@ INSTANTIATE_TEST_SUITE_P(PlayoutDelay,
|
|||||||
Values(kDefaultBehavior, kOverridePlayoutDelay));
|
Values(kDefaultBehavior, kOverridePlayoutDelay));
|
||||||
|
|
||||||
TEST_P(RtpVideoStreamReceiverTestPlayoutDelay, PlayoutDelay) {
|
TEST_P(RtpVideoStreamReceiverTestPlayoutDelay, PlayoutDelay) {
|
||||||
rtc::CopyOnWriteBuffer payload_data({1, 2, 3, 4});
|
rtc::CopyOnWriteBuffer payload_data({'1', '2', '3', '4'});
|
||||||
RtpHeaderExtensionMap extension_map;
|
RtpHeaderExtensionMap extension_map;
|
||||||
extension_map.Register<PlayoutDelayLimits>(1);
|
extension_map.Register<PlayoutDelayLimits>(1);
|
||||||
RtpPacketToSend packet_to_send(&extension_map);
|
RtpPacketToSend packet_to_send(&extension_map);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user