Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -95,7 +95,8 @@ void CallTest::RunBaseTest(BaseTest* test) {
|
||||
audio_state_config.audio_device_module = fake_recv_audio_device_;
|
||||
recv_config.audio_state = AudioState::Create(audio_state_config);
|
||||
fake_recv_audio_device_->RegisterAudioCallback(
|
||||
recv_config.audio_state->audio_transport()); }
|
||||
recv_config.audio_state->audio_transport());
|
||||
}
|
||||
CreateReceiverCall(recv_config);
|
||||
}
|
||||
test->OnCallsCreated(sender_call_.get(), receiver_call_.get());
|
||||
@ -487,8 +488,7 @@ BaseTest::BaseTest() : event_log_(RtcEventLog::CreateNull()) {}
|
||||
BaseTest::BaseTest(unsigned int timeout_ms)
|
||||
: RtpRtcpObserver(timeout_ms), event_log_(RtcEventLog::CreateNull()) {}
|
||||
|
||||
BaseTest::~BaseTest() {
|
||||
}
|
||||
BaseTest::~BaseTest() {}
|
||||
|
||||
std::unique_ptr<TestAudioDeviceModule::Capturer> BaseTest::CreateCapturer() {
|
||||
return TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000);
|
||||
@ -513,8 +513,7 @@ Call::Config BaseTest::GetReceiverCallConfig() {
|
||||
void BaseTest::OnRtpTransportControllerSendCreated(
|
||||
RtpTransportControllerSend* controller) {}
|
||||
|
||||
void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) {
|
||||
}
|
||||
void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) {}
|
||||
|
||||
test::PacketTransport* BaseTest::CreateSendTransport(
|
||||
SingleThreadedTaskQueueForTesting* task_queue,
|
||||
@ -571,14 +570,11 @@ void BaseTest::OnFlexfecStreamsCreated(
|
||||
const std::vector<FlexfecReceiveStream*>& receive_streams) {}
|
||||
|
||||
void BaseTest::OnFrameGeneratorCapturerCreated(
|
||||
FrameGeneratorCapturer* frame_generator_capturer) {
|
||||
}
|
||||
FrameGeneratorCapturer* frame_generator_capturer) {}
|
||||
|
||||
void BaseTest::OnStreamsStopped() {
|
||||
}
|
||||
void BaseTest::OnStreamsStopped() {}
|
||||
|
||||
SendTest::SendTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {
|
||||
}
|
||||
SendTest::SendTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {}
|
||||
|
||||
bool SendTest::ShouldCreateReceivers() const {
|
||||
return false;
|
||||
@ -586,8 +582,7 @@ bool SendTest::ShouldCreateReceivers() const {
|
||||
|
||||
EndToEndTest::EndToEndTest() {}
|
||||
|
||||
EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {
|
||||
}
|
||||
EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {}
|
||||
|
||||
bool EndToEndTest::ShouldCreateReceivers() const {
|
||||
return true;
|
||||
|
||||
@ -42,8 +42,8 @@ int32_t ConfigurableFrameSizeEncoder::Encode(
|
||||
const VideoFrame& inputImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
const std::vector<FrameType>* frame_types) {
|
||||
EncodedImage encodedImage(
|
||||
buffer_.get(), current_frame_size_, max_frame_size_);
|
||||
EncodedImage encodedImage(buffer_.get(), current_frame_size_,
|
||||
max_frame_size_);
|
||||
encodedImage._completeFrame = true;
|
||||
encodedImage._encodedHeight = inputImage.height();
|
||||
encodedImage._encodedWidth = inputImage.width();
|
||||
|
||||
@ -42,8 +42,7 @@ DirectTransport::DirectTransport(
|
||||
: DirectTransport(task_queue,
|
||||
FakeNetworkPipe::Config(),
|
||||
send_call,
|
||||
payload_type_map) {
|
||||
}
|
||||
payload_type_map) {}
|
||||
|
||||
DirectTransport::DirectTransport(
|
||||
SingleThreadedTaskQueueForTesting* task_queue,
|
||||
@ -139,9 +138,8 @@ void DirectTransport::SendPackets() {
|
||||
fake_network_->Process();
|
||||
|
||||
int64_t delay_ms = fake_network_->TimeUntilNextProcess();
|
||||
next_scheduled_task_ = task_queue_->PostDelayedTask([this]() {
|
||||
SendPackets();
|
||||
}, delay_ms);
|
||||
next_scheduled_task_ =
|
||||
task_queue_->PostDelayedTask([this]() { SendPackets(); }, delay_ms);
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -123,7 +123,8 @@ void FillEncoderConfiguration(VideoCodecType codec_type,
|
||||
}
|
||||
|
||||
VideoReceiveStream::Decoder CreateMatchingDecoder(
|
||||
int payload_type, const std::string& payload_name) {
|
||||
int payload_type,
|
||||
const std::string& payload_name) {
|
||||
VideoReceiveStream::Decoder decoder;
|
||||
decoder.payload_type = payload_type;
|
||||
decoder.payload_name = payload_name;
|
||||
|
||||
@ -45,11 +45,13 @@ std::vector<VideoStream> CreateVideoStreams(
|
||||
int height,
|
||||
const webrtc::VideoEncoderConfig& encoder_config);
|
||||
|
||||
void FillEncoderConfiguration(VideoCodecType codec_type, size_t num_streams,
|
||||
void FillEncoderConfiguration(VideoCodecType codec_type,
|
||||
size_t num_streams,
|
||||
VideoEncoderConfig* configuration);
|
||||
|
||||
VideoReceiveStream::Decoder CreateMatchingDecoder(
|
||||
int payload_type, const std::string& payload_name);
|
||||
int payload_type,
|
||||
const std::string& payload_name);
|
||||
|
||||
VideoReceiveStream::Decoder CreateMatchingDecoder(
|
||||
const VideoSendStream::Config& config);
|
||||
|
||||
@ -81,9 +81,7 @@ int32_t FakeH264Decoder::Decode(const EncodedImage& input,
|
||||
}
|
||||
++value;
|
||||
}
|
||||
return FakeDecoder::Decode(input,
|
||||
missing_frames,
|
||||
codec_specific_info,
|
||||
return FakeDecoder::Decode(input, missing_frames, codec_specific_info,
|
||||
render_time_ms);
|
||||
}
|
||||
|
||||
|
||||
@ -116,8 +116,8 @@ int32_t FakeEncoder::Encode(const VideoFrame& input_image,
|
||||
(simulcast_streams[i].minBitrate * 1000) / framerate);
|
||||
size_t max_stream_bits = static_cast<size_t>(
|
||||
(simulcast_streams[i].maxBitrate * 1000) / framerate);
|
||||
size_t stream_bits = (bits_available > max_stream_bits) ? max_stream_bits :
|
||||
bits_available;
|
||||
size_t stream_bits =
|
||||
(bits_available > max_stream_bits) ? max_stream_bits : bits_available;
|
||||
size_t stream_bytes = (stream_bits + 7) / 8;
|
||||
if (keyframe) {
|
||||
// The first frame is a key frame and should be larger.
|
||||
@ -172,7 +172,9 @@ int32_t FakeEncoder::RegisterEncodeCompleteCallback(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FakeEncoder::Release() { return 0; }
|
||||
int32_t FakeEncoder::Release() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int64_t rtt) {
|
||||
return 0;
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef TEST_FAKE_ENCODER_H_
|
||||
#define TEST_FAKE_ENCODER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
|
||||
@ -43,8 +43,8 @@ void ValidateFieldTrialsStringOrDie(const std::string& trials_string) {
|
||||
size_t name_end = trials_string.find(kPersistentStringSeparator, next_item);
|
||||
if (name_end == trials_string.npos || next_item == name_end)
|
||||
break;
|
||||
size_t group_name_end = trials_string.find(kPersistentStringSeparator,
|
||||
name_end + 1);
|
||||
size_t group_name_end =
|
||||
trials_string.find(kPersistentStringSeparator, name_end + 1);
|
||||
if (group_name_end == trials_string.npos || name_end + 1 == group_name_end)
|
||||
break;
|
||||
std::string name(trials_string, next_item, name_end - next_item);
|
||||
@ -74,7 +74,7 @@ void ValidateFieldTrialsStringOrDie(const std::string& trials_string) {
|
||||
}
|
||||
|
||||
ScopedFieldTrials::ScopedFieldTrials(const std::string& config)
|
||||
: previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) {
|
||||
: previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) {
|
||||
assert(field_trials_initiated_);
|
||||
field_trials_initiated_ = false;
|
||||
current_field_trials_ = config;
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef TEST_FIELD_TRIAL_H_
|
||||
#define TEST_FIELD_TRIAL_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -38,6 +38,7 @@ class ScopedFieldTrials {
|
||||
public:
|
||||
explicit ScopedFieldTrials(const std::string& config);
|
||||
~ScopedFieldTrials();
|
||||
|
||||
private:
|
||||
std::string current_field_trials_;
|
||||
const char* previous_field_trials_;
|
||||
|
||||
@ -99,8 +99,8 @@ class FrameGenerator {
|
||||
|
||||
// Creates a frame generator that produces randomly generated slides.
|
||||
// frame_repeat_count determines how many times each slide is shown.
|
||||
static std::unique_ptr<FrameGenerator> CreateSlideGenerator(
|
||||
int width, int height, int frame_repeat_count);
|
||||
static std::unique_ptr<FrameGenerator>
|
||||
CreateSlideGenerator(int width, int height, int frame_repeat_count);
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -13,13 +13,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "call/video_send_stream.h"
|
||||
#include "rtc_base/criticalsection.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/platform_thread.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "call/video_send_stream.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -125,8 +125,8 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::CreateSlideGenerator(
|
||||
int target_fps,
|
||||
Clock* clock) {
|
||||
std::unique_ptr<FrameGeneratorCapturer> capturer(new FrameGeneratorCapturer(
|
||||
clock, FrameGenerator::CreateSlideGenerator(width, height,
|
||||
frame_repeat_count),
|
||||
clock,
|
||||
FrameGenerator::CreateSlideGenerator(width, height, frame_repeat_count),
|
||||
target_fps));
|
||||
if (!capturer->Init())
|
||||
return nullptr;
|
||||
@ -145,8 +145,7 @@ FrameGeneratorCapturer::FrameGeneratorCapturer(
|
||||
frame_generator_(std::move(frame_generator)),
|
||||
target_fps_(target_fps),
|
||||
first_frame_capture_time_(-1),
|
||||
task_queue_("FrameGenCapQ",
|
||||
rtc::TaskQueue::Priority::HIGH) {
|
||||
task_queue_("FrameGenCapQ", rtc::TaskQueue::Priority::HIGH) {
|
||||
RTC_DCHECK(frame_generator_);
|
||||
RTC_DCHECK_GT(target_fps, 0);
|
||||
}
|
||||
|
||||
@ -169,8 +169,8 @@ TEST_F(FrameGeneratorTest, SlideGenerator) {
|
||||
const int kGenCount = 9;
|
||||
const int kRepeatCount = 3;
|
||||
std::unique_ptr<FrameGenerator> generator(
|
||||
FrameGenerator::CreateSlideGenerator(
|
||||
kFrameWidth, kFrameHeight, kRepeatCount));
|
||||
FrameGenerator::CreateSlideGenerator(kFrameWidth, kFrameHeight,
|
||||
kRepeatCount));
|
||||
uint64_t hashes[kGenCount];
|
||||
for (int i = 0; i < kGenCount; ++i) {
|
||||
hashes[i] = Hash(generator->NextFrame());
|
||||
@ -178,9 +178,9 @@ TEST_F(FrameGeneratorTest, SlideGenerator) {
|
||||
// Check that the buffer changes only every |kRepeatCount| frames.
|
||||
for (int i = 1; i < kGenCount; ++i) {
|
||||
if (i % kRepeatCount == 0) {
|
||||
EXPECT_NE(hashes[i-1], hashes[i]);
|
||||
EXPECT_NE(hashes[i - 1], hashes[i]);
|
||||
} else {
|
||||
EXPECT_EQ(hashes[i-1], hashes[i]);
|
||||
EXPECT_EQ(hashes[i - 1], hashes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,18 +59,17 @@ bool FrameBufsEqual(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f1,
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420BufferInterface> f1_i420 = f1->ToI420();
|
||||
rtc::scoped_refptr<webrtc::I420BufferInterface> f2_i420 = f2->ToI420();
|
||||
return EqualPlane(f1_i420->DataY(), f2_i420->DataY(),
|
||||
f1_i420->StrideY(), f2_i420->StrideY(),
|
||||
f1_i420->width(), f1_i420->height()) &&
|
||||
EqualPlane(f1_i420->DataU(), f2_i420->DataU(),
|
||||
f1_i420->StrideU(), f2_i420->StrideU(),
|
||||
f1_i420->ChromaWidth(), f1_i420->ChromaHeight()) &&
|
||||
EqualPlane(f1_i420->DataV(), f2_i420->DataV(),
|
||||
f1_i420->StrideV(), f2_i420->StrideV(),
|
||||
f1_i420->ChromaWidth(), f1_i420->ChromaHeight());
|
||||
return EqualPlane(f1_i420->DataY(), f2_i420->DataY(), f1_i420->StrideY(),
|
||||
f2_i420->StrideY(), f1_i420->width(), f1_i420->height()) &&
|
||||
EqualPlane(f1_i420->DataU(), f2_i420->DataU(), f1_i420->StrideU(),
|
||||
f2_i420->StrideU(), f1_i420->ChromaWidth(),
|
||||
f1_i420->ChromaHeight()) &&
|
||||
EqualPlane(f1_i420->DataV(), f2_i420->DataV(), f1_i420->StrideV(),
|
||||
f2_i420->StrideV(), f1_i420->ChromaWidth(),
|
||||
f1_i420->ChromaHeight());
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE *f) {
|
||||
rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE* f) {
|
||||
int half_width = (width + 1) / 2;
|
||||
rtc::scoped_refptr<I420Buffer> buffer(
|
||||
// Explicit stride, no padding between rows.
|
||||
|
||||
@ -40,7 +40,7 @@ bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2);
|
||||
bool FrameBufsEqual(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f1,
|
||||
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f2);
|
||||
|
||||
rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE *);
|
||||
rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE*);
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
#include "modules/rtp_rtcp/include/flexfec_sender.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -20,7 +20,6 @@ class NullCallback : public video_coding::OnReceivedFrameCallback {
|
||||
} // namespace
|
||||
|
||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
|
||||
VCMPacket packet;
|
||||
NullCallback callback;
|
||||
SimulatedClock clock(0);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -30,9 +30,8 @@ class FakeIPseudoTcpNotify : public cricket::IPseudoTcpNotify {
|
||||
};
|
||||
|
||||
struct Environment {
|
||||
explicit Environment(cricket::IPseudoTcpNotify* notifier):
|
||||
ptcp(notifier, 0) {
|
||||
}
|
||||
explicit Environment(cricket::IPseudoTcpNotify* notifier)
|
||||
: ptcp(notifier, 0) {}
|
||||
|
||||
// We need the thread to avoid some uninteresting crashes, since the
|
||||
// production code expects there to be a thread object available.
|
||||
|
||||
@ -18,11 +18,11 @@ class NullModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp {
|
||||
public:
|
||||
void SetTmmbn(std::vector<rtcp::TmmbItem>) override {}
|
||||
void OnRequestSendReport() override {}
|
||||
void OnReceivedNack(const std::vector<uint16_t>&) override {};
|
||||
void OnReceivedRtcpReportBlocks(const ReportBlockList&) override {};
|
||||
void OnReceivedNack(const std::vector<uint16_t>&) override{};
|
||||
void OnReceivedRtcpReportBlocks(const ReportBlockList&) override{};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
NullModuleRtpRtcp rtp_rtcp_module;
|
||||
@ -34,4 +34,3 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
receiver.IncomingPacket(data, size);
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -62,9 +62,15 @@ class FuzzyPacketBuffer : public video_coding::PacketBuffer {
|
||||
explicit FuzzyPacketBuffer(DataReader* reader)
|
||||
: PacketBuffer(nullptr, 2, 4, nullptr), reader(reader) {
|
||||
switch (reader->GetNum<uint8_t>() % 3) {
|
||||
case 0: codec = kVideoCodecVP8; break;
|
||||
case 1: codec = kVideoCodecVP9; break;
|
||||
case 2: codec = kVideoCodecH264; break;
|
||||
case 0:
|
||||
codec = kVideoCodecVP8;
|
||||
break;
|
||||
case 1:
|
||||
codec = kVideoCodecVP9;
|
||||
break;
|
||||
case 2:
|
||||
codec = kVideoCodecH264;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
const size_t num_fec_packets = generator.NumAvailableFecPackets();
|
||||
if (num_fec_packets > 0) {
|
||||
std::vector<std::unique_ptr<RedPacket>> fec_packets =
|
||||
generator.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType, 100);
|
||||
generator.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType,
|
||||
100);
|
||||
RTC_CHECK_EQ(num_fec_packets, fec_packets.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/include/ulpfec_receiver.h"
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||
|
||||
@ -67,8 +67,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
RTPHeader parsed_header;
|
||||
if (parsed_packet.Parse(packet.get(), packet_length)) {
|
||||
parsed_packet.GetHeader(&parsed_header);
|
||||
receiver->AddReceivedRedPacket(parsed_header, packet.get(),
|
||||
packet_length, 0);
|
||||
receiver->AddReceivedRedPacket(parsed_header, packet.get(), packet_length,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,21 +20,21 @@ void InitializeWebRtcFuzzDefaults() {
|
||||
if (g_initialized)
|
||||
return;
|
||||
|
||||
// Remove default logging to prevent huge slowdowns.
|
||||
// TODO(pbos): Disable in Chromium: http://crbug.com/561667
|
||||
// Remove default logging to prevent huge slowdowns.
|
||||
// TODO(pbos): Disable in Chromium: http://crbug.com/561667
|
||||
#if !defined(WEBRTC_CHROMIUM_BUILD)
|
||||
rtc::LogMessage::LogToDebug(rtc::LS_NONE);
|
||||
#endif // !defined(WEBRTC_CHROMIUM_BUILD)
|
||||
|
||||
g_initialized = true;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace webrtc {
|
||||
extern void FuzzOneInput(const uint8_t* data, size_t size);
|
||||
} // namespace webrtc
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
|
||||
InitializeWebRtcFuzzDefaults();
|
||||
webrtc::FuzzOneInput(data, size);
|
||||
return 0;
|
||||
|
||||
@ -108,5 +108,5 @@ void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glFlush();
|
||||
}
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "test/video_renderer.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -44,7 +43,7 @@ class GlRenderer : public VideoRenderer {
|
||||
|
||||
void ResizeVideo(size_t width, size_t height);
|
||||
};
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_GL_GL_RENDERER_H_
|
||||
|
||||
@ -17,7 +17,9 @@ namespace test {
|
||||
// This is necessary as iOS doesn't like processes without a gui
|
||||
// running for longer than a few seconds.
|
||||
void RunTestsFromIOSApp();
|
||||
void InitTestSuite(int (*test_suite)(void), int argc, char* argv[],
|
||||
void InitTestSuite(int (*test_suite)(void),
|
||||
int argc,
|
||||
char* argv[],
|
||||
bool save_chartjson_result);
|
||||
|
||||
} // namespace test
|
||||
|
||||
@ -22,15 +22,14 @@ namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
GlxRenderer::GlxRenderer(size_t width, size_t height)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
display_(NULL),
|
||||
context_(NULL) {
|
||||
: width_(width), height_(height), display_(NULL), context_(NULL) {
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
}
|
||||
|
||||
GlxRenderer::~GlxRenderer() { Destroy(); }
|
||||
GlxRenderer::~GlxRenderer() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool GlxRenderer::Init(const char* window_title) {
|
||||
if ((display_ = XOpenDisplay(NULL)) == NULL) {
|
||||
@ -41,9 +40,10 @@ bool GlxRenderer::Init(const char* window_title) {
|
||||
int screen = DefaultScreen(display_);
|
||||
|
||||
XVisualInfo* vi;
|
||||
int attr_list[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 4,
|
||||
GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16,
|
||||
None, };
|
||||
int attr_list[] = {
|
||||
GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4,
|
||||
GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None,
|
||||
};
|
||||
|
||||
if ((vi = glXChooseVisual(display_, screen, attr_list)) == NULL) {
|
||||
Destroy();
|
||||
@ -106,7 +106,8 @@ void GlxRenderer::Destroy() {
|
||||
}
|
||||
}
|
||||
|
||||
GlxRenderer* GlxRenderer::Create(const char* window_title, size_t width,
|
||||
GlxRenderer* GlxRenderer::Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height) {
|
||||
GlxRenderer* glx_renderer = new GlxRenderer(width, height);
|
||||
if (!glx_renderer->Init(window_title)) {
|
||||
@ -174,5 +175,5 @@ void GlxRenderer::OnFrame(const webrtc::VideoFrame& frame) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -22,7 +22,8 @@ namespace test {
|
||||
|
||||
class GlxRenderer : public GlRenderer {
|
||||
public:
|
||||
static GlxRenderer* Create(const char* window_title, size_t width,
|
||||
static GlxRenderer* Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height);
|
||||
virtual ~GlxRenderer();
|
||||
|
||||
@ -41,7 +42,7 @@ class GlxRenderer : public GlRenderer {
|
||||
Window window_;
|
||||
GLXContext context_;
|
||||
};
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_LINUX_GLX_RENDERER_H_
|
||||
|
||||
@ -23,5 +23,5 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title,
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -34,7 +34,7 @@ class MacRenderer : public GlRenderer {
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(MacRenderer);
|
||||
};
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_MAC_VIDEO_RENDERER_MAC_H_
|
||||
|
||||
@ -18,5 +18,5 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title,
|
||||
size_t height) {
|
||||
return NULL;
|
||||
}
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -241,17 +241,17 @@ const uint32_t kPcapBOMNoSwapOrder = 0xa1b2c3d4UL;
|
||||
class PcapReader : public RtpFileReaderImpl {
|
||||
public:
|
||||
PcapReader()
|
||||
: file_(NULL),
|
||||
swap_pcap_byte_order_(false),
|
||||
: file_(NULL),
|
||||
swap_pcap_byte_order_(false),
|
||||
#ifdef WEBRTC_ARCH_BIG_ENDIAN
|
||||
swap_network_byte_order_(false),
|
||||
swap_network_byte_order_(false),
|
||||
#else
|
||||
swap_network_byte_order_(true),
|
||||
swap_network_byte_order_(true),
|
||||
#endif
|
||||
read_buffer_(),
|
||||
packets_by_ssrc_(),
|
||||
packets_(),
|
||||
next_packet_it_() {
|
||||
read_buffer_(),
|
||||
packets_by_ssrc_(),
|
||||
packets_(),
|
||||
next_packet_it_() {
|
||||
}
|
||||
|
||||
virtual ~PcapReader() {
|
||||
@ -304,7 +304,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
printf("Total RTP/RTCP packets: %" PRIuS "\n", packets_.size());
|
||||
|
||||
for (SsrcMapIterator mit = packets_by_ssrc_.begin();
|
||||
mit != packets_by_ssrc_.end(); ++mit) {
|
||||
mit != packets_by_ssrc_.end(); ++mit) {
|
||||
uint32_t ssrc = mit->first;
|
||||
const std::vector<uint32_t>& packet_indices = mit->second;
|
||||
uint8_t pt = packets_[packet_indices[0]].rtp_header.payloadType;
|
||||
@ -364,14 +364,14 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
private:
|
||||
// A marker of an RTP packet within the file.
|
||||
struct RtpPacketMarker {
|
||||
uint32_t packet_number; // One-based index (like in WireShark)
|
||||
uint32_t packet_number; // One-based index (like in WireShark)
|
||||
uint32_t time_offset_ms;
|
||||
uint32_t source_ip;
|
||||
uint32_t dest_ip;
|
||||
uint16_t source_port;
|
||||
uint16_t dest_port;
|
||||
RTPHeader rtp_header;
|
||||
int32_t pos_in_file; // Byte offset of payload from start of file.
|
||||
int32_t pos_in_file; // Byte offset of payload from start of file.
|
||||
uint32_t payload_length;
|
||||
};
|
||||
|
||||
@ -505,8 +505,8 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
|
||||
uint32_t CalcTimeDelta(uint32_t ts_sec, uint32_t ts_usec, uint32_t start_ms) {
|
||||
// Round to nearest ms.
|
||||
uint64_t t2_ms = ((static_cast<uint64_t>(ts_sec) * 1000000) + ts_usec +
|
||||
500) / 1000;
|
||||
uint64_t t2_ms =
|
||||
((static_cast<uint64_t>(ts_sec) * 1000000) + ts_usec + 500) / 1000;
|
||||
uint64_t t1_ms = static_cast<uint64_t>(start_ms);
|
||||
if (t2_ms < t1_ms) {
|
||||
return 0;
|
||||
@ -577,7 +577,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
if ((!expect_network_order && swap_pcap_byte_order_) ||
|
||||
(expect_network_order && swap_network_byte_order_)) {
|
||||
tmp = ((tmp >> 24) & 0x000000ff) | (tmp << 24) |
|
||||
((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000);
|
||||
((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000);
|
||||
}
|
||||
*out = tmp;
|
||||
return kResultSuccess;
|
||||
@ -611,7 +611,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
if ((!expect_network_order && swap_pcap_byte_order_) ||
|
||||
(expect_network_order && swap_network_byte_order_)) {
|
||||
tmp = ((tmp >> 24) & 0x000000ff) | (tmp << 24) |
|
||||
((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000);
|
||||
((tmp >> 8) & 0x0000ff00) | ((tmp << 8) & 0x00ff0000);
|
||||
}
|
||||
*out = tmp;
|
||||
return kResultSuccess;
|
||||
|
||||
@ -36,8 +36,7 @@ class RtpFileReader {
|
||||
enum FileFormat { kPcap, kRtpDump, kLengthPacketInterleaved };
|
||||
|
||||
virtual ~RtpFileReader() {}
|
||||
static RtpFileReader* Create(FileFormat format,
|
||||
const std::string& filename);
|
||||
static RtpFileReader* Create(FileFormat format, const std::string& filename);
|
||||
static RtpFileReader* Create(FileFormat format,
|
||||
const std::string& filename,
|
||||
const std::set<uint32_t>& ssrc_filter);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "call/video_send_stream.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "rtc_base/criticalsection.h"
|
||||
#include "rtc_base/event.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "test/direct_transport.h"
|
||||
#include "test/gtest.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
#include "call/video_send_stream.h"
|
||||
|
||||
namespace {
|
||||
const int kShortTimeoutMs = 500;
|
||||
|
||||
@ -16,7 +16,8 @@ namespace test {
|
||||
|
||||
void PressEnterToContinue() {
|
||||
puts(">> Press ENTER to continue...");
|
||||
while (getc(stdin) != '\n' && !feof(stdin));
|
||||
while (getc(stdin) != '\n' && !feof(stdin))
|
||||
;
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
void RunTest(void(*test)()) {
|
||||
void RunTest(void (*test)()) {
|
||||
(*test)();
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
// Running a test function on a separate thread, if required by the OS.
|
||||
void RunTest(void(*test)());
|
||||
void RunTest(void (*test)());
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -68,9 +68,8 @@ TEST(SingleThreadedTaskQueueForTestingTest,
|
||||
// queue at any given time, post one waiting task that would block the
|
||||
// task-queue, and unblock only after all tasks have been posted.
|
||||
rtc::Event rendezvous(true, false);
|
||||
task_queue.PostTask([&rendezvous]() {
|
||||
ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs));
|
||||
});
|
||||
task_queue.PostTask(
|
||||
[&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); });
|
||||
|
||||
// Post the tasks which comprise the test.
|
||||
for (size_t i = 0; i < kCount; i++) {
|
||||
@ -126,9 +125,8 @@ TEST(SingleThreadedTaskQueueForTestingTest, TasksExecutedInSequence) {
|
||||
// Prevent the chain from being set in motion before we've had time to
|
||||
// schedule it all, lest the queue only contain one task at a time.
|
||||
rtc::Event rendezvous(true, false);
|
||||
task_queue.PostTask([&rendezvous]() {
|
||||
ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs));
|
||||
});
|
||||
task_queue.PostTask(
|
||||
[&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); });
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
task_queue.PostTask([&accumulator, i]() { // |i| passed by value.
|
||||
@ -139,9 +137,7 @@ TEST(SingleThreadedTaskQueueForTestingTest, TasksExecutedInSequence) {
|
||||
|
||||
// The test will wait for the task-queue to finish.
|
||||
rtc::Event done(true, false);
|
||||
task_queue.PostTask([&done]() {
|
||||
done.Set();
|
||||
});
|
||||
task_queue.PostTask([&done]() { done.Set(); });
|
||||
|
||||
rendezvous.Set(); // Set the chain in motion.
|
||||
|
||||
@ -159,10 +155,12 @@ TEST(SingleThreadedTaskQueueForTestingTest, ExecutesPostedDelayedTask) {
|
||||
constexpr int64_t delay_ms = 20;
|
||||
static_assert(delay_ms < kMaxWaitTimeMs / 2, "Delay too long for tests.");
|
||||
|
||||
task_queue.PostDelayedTask([&executed, &done]() {
|
||||
executed.store(true);
|
||||
done.Set();
|
||||
}, delay_ms);
|
||||
task_queue.PostDelayedTask(
|
||||
[&executed, &done]() {
|
||||
executed.store(true);
|
||||
done.Set();
|
||||
},
|
||||
delay_ms);
|
||||
ASSERT_TRUE(done.Wait(kMaxWaitTimeMs));
|
||||
|
||||
EXPECT_TRUE(executed.load());
|
||||
@ -176,9 +174,7 @@ TEST(SingleThreadedTaskQueueForTestingTest, DoesNotExecuteDelayedTaskTooSoon) {
|
||||
constexpr int64_t delay_ms = 2000;
|
||||
static_assert(delay_ms < kMaxWaitTimeMs / 2, "Delay too long for tests.");
|
||||
|
||||
task_queue.PostDelayedTask([&executed]() {
|
||||
executed.store(true);
|
||||
}, delay_ms);
|
||||
task_queue.PostDelayedTask([&executed]() { executed.store(true); }, delay_ms);
|
||||
|
||||
// Wait less than is enough, make sure the task was not yet executed.
|
||||
rtc::Event not_done(true, false);
|
||||
@ -262,16 +258,11 @@ TEST(SingleThreadedTaskQueueForTestingTest, ExternalThreadCancelsTask) {
|
||||
// Prevent the to-be-cancelled task from being executed before we've had
|
||||
// time to cancel it.
|
||||
rtc::Event rendezvous(true, false);
|
||||
task_queue.PostTask([&rendezvous]() {
|
||||
ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs));
|
||||
});
|
||||
task_queue.PostTask(
|
||||
[&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); });
|
||||
|
||||
TaskId cancelled_task_id = task_queue.PostTask([]() {
|
||||
EXPECT_TRUE(false);
|
||||
});
|
||||
task_queue.PostTask([&done]() {
|
||||
done.Set();
|
||||
});
|
||||
TaskId cancelled_task_id = task_queue.PostTask([]() { EXPECT_TRUE(false); });
|
||||
task_queue.PostTask([&done]() { done.Set(); });
|
||||
|
||||
task_queue.CancelTask(cancelled_task_id);
|
||||
|
||||
@ -292,9 +283,8 @@ TEST(SingleThreadedTaskQueueForTestingTest, InternalThreadCancelsTask) {
|
||||
|
||||
// Prevent the chain from being set-off before we've set everything up.
|
||||
rtc::Event rendezvous(true, false);
|
||||
task_queue.PostTask([&rendezvous]() {
|
||||
ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs));
|
||||
});
|
||||
task_queue.PostTask(
|
||||
[&rendezvous]() { ASSERT_TRUE(rendezvous.Wait(kMaxWaitTimeMs)); });
|
||||
|
||||
// This is the canceller-task. It takes cancelled_task_id by reference,
|
||||
// because the ID will only become known after the cancelled task is
|
||||
@ -306,15 +296,11 @@ TEST(SingleThreadedTaskQueueForTestingTest, InternalThreadCancelsTask) {
|
||||
task_queue.PostTask(canceller_task);
|
||||
|
||||
// This task will be cancelled by the task before it.
|
||||
auto cancelled_task = []() {
|
||||
EXPECT_TRUE(false);
|
||||
};
|
||||
auto cancelled_task = []() { EXPECT_TRUE(false); };
|
||||
cancelled_task_id = task_queue.PostTask(cancelled_task);
|
||||
|
||||
// When this task runs, it will allow the test to be finished.
|
||||
auto completion_marker_task = [&done]() {
|
||||
done.Set();
|
||||
};
|
||||
auto completion_marker_task = [&done]() { done.Set(); };
|
||||
task_queue.PostTask(completion_marker_task);
|
||||
|
||||
rendezvous.Set(); // Set the chain in motion.
|
||||
|
||||
@ -21,10 +21,12 @@
|
||||
#if defined(WEBRTC_IOS)
|
||||
#include "test/ios/test_support.h"
|
||||
|
||||
DEFINE_string(NSTreatUnknownArgumentsAsOpen, "",
|
||||
"Intentionally ignored flag intended for iOS simulator.");
|
||||
DEFINE_string(ApplePersistenceIgnoreState, "",
|
||||
"Intentionally ignored flag intended for iOS simulator.");
|
||||
DEFINE_string(NSTreatUnknownArgumentsAsOpen,
|
||||
"",
|
||||
"Intentionally ignored flag intended for iOS simulator.");
|
||||
DEFINE_string(ApplePersistenceIgnoreState,
|
||||
"",
|
||||
"Intentionally ignored flag intended for iOS simulator.");
|
||||
DEFINE_bool(
|
||||
save_chartjson_result,
|
||||
false,
|
||||
@ -35,10 +37,9 @@ DEFINE_bool(
|
||||
|
||||
#else
|
||||
|
||||
DEFINE_string(
|
||||
isolated_script_test_output,
|
||||
"",
|
||||
"Intentionally ignored flag intended for Chromium.");
|
||||
DEFINE_string(isolated_script_test_output,
|
||||
"",
|
||||
"Intentionally ignored flag intended for Chromium.");
|
||||
|
||||
DEFINE_string(
|
||||
isolated_script_test_perf_output,
|
||||
@ -52,7 +53,9 @@ DEFINE_string(
|
||||
|
||||
DEFINE_bool(logs, false, "print logs to stderr");
|
||||
|
||||
DEFINE_string(force_fieldtrials, "",
|
||||
DEFINE_string(
|
||||
force_fieldtrials,
|
||||
"",
|
||||
"Field trials control experimental feature code which can be forced. "
|
||||
"E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
|
||||
" will assign the group Enable to field trial WebRTC-FooFeature.");
|
||||
@ -82,7 +85,6 @@ int main(int argc, char* argv[]) {
|
||||
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
|
||||
webrtc::metrics::Enable();
|
||||
|
||||
|
||||
rtc::LogMessage::SetLogToStderr(FLAG_logs);
|
||||
|
||||
#if defined(WEBRTC_IOS)
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h> // To check for directory existence.
|
||||
#ifndef S_ISDIR // Not defined in stat.h on Windows.
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#ifndef S_ISDIR // Not defined in stat.h on Windows.
|
||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -92,9 +92,9 @@ void SetExecutablePath(const std::string& path) {
|
||||
if (path.find(working_dir) != std::string::npos) {
|
||||
temp_path = path.substr(working_dir.length() + 1);
|
||||
}
|
||||
// On Windows, when tests are run under memory tools like DrMemory and TSan,
|
||||
// slashes occur in the path as directory separators. Make sure we replace
|
||||
// such cases with backslashes in order for the paths to be correct.
|
||||
// On Windows, when tests are run under memory tools like DrMemory and TSan,
|
||||
// slashes occur in the path as directory separators. Make sure we replace
|
||||
// such cases with backslashes in order for the paths to be correct.
|
||||
#ifdef WIN32
|
||||
std::replace(temp_path.begin(), temp_path.end(), '/', '\\');
|
||||
#endif
|
||||
@ -112,8 +112,8 @@ bool FileExists(const std::string& file_name) {
|
||||
|
||||
bool DirExists(const std::string& directory_name) {
|
||||
struct stat directory_info = {0};
|
||||
return stat(directory_name.c_str(), &directory_info) == 0 && S_ISDIR(
|
||||
directory_info.st_mode);
|
||||
return stat(directory_name.c_str(), &directory_info) == 0 &&
|
||||
S_ISDIR(directory_info.st_mode);
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_ANDROID
|
||||
@ -190,11 +190,11 @@ std::string WorkingDir() {
|
||||
|
||||
// Generate a temporary filename in a safe way.
|
||||
// Largely copied from talk/base/{unixfilesystem,win32filesystem}.cc.
|
||||
std::string TempFilename(const std::string &dir, const std::string &prefix) {
|
||||
std::string TempFilename(const std::string& dir, const std::string& prefix) {
|
||||
#ifdef WIN32
|
||||
wchar_t filename[MAX_PATH];
|
||||
if (::GetTempFileName(rtc::ToUtf16(dir).c_str(),
|
||||
rtc::ToUtf16(prefix).c_str(), 0, filename) != 0)
|
||||
if (::GetTempFileName(rtc::ToUtf16(dir).c_str(), rtc::ToUtf16(prefix).c_str(),
|
||||
0, filename) != 0)
|
||||
return rtc::ToUtf8(filename);
|
||||
assert(false);
|
||||
return "";
|
||||
@ -202,8 +202,7 @@ std::string TempFilename(const std::string &dir, const std::string &prefix) {
|
||||
int len = dir.size() + prefix.size() + 2 + 6;
|
||||
std::unique_ptr<char[]> tempname(new char[len]);
|
||||
|
||||
snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(),
|
||||
prefix.c_str());
|
||||
snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str());
|
||||
int fd = ::mkstemp(tempname.get());
|
||||
if (fd == -1) {
|
||||
assert(false);
|
||||
@ -279,7 +278,8 @@ bool CreateDir(const std::string& directory_name) {
|
||||
// Check if the path exists already:
|
||||
if (stat(directory_name.c_str(), &path_info) == 0) {
|
||||
if (!S_ISDIR(path_info.st_mode)) {
|
||||
fprintf(stderr, "Path %s exists but is not a directory! Remove this "
|
||||
fprintf(stderr,
|
||||
"Path %s exists but is not a directory! Remove this "
|
||||
"file and re-run to create the directory.\n",
|
||||
directory_name.c_str());
|
||||
return false;
|
||||
@ -288,7 +288,7 @@ bool CreateDir(const std::string& directory_name) {
|
||||
#ifdef WIN32
|
||||
return _mkdir(directory_name.c_str()) == 0;
|
||||
#else
|
||||
return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0;
|
||||
return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
@ -296,9 +296,9 @@ bool CreateDir(const std::string& directory_name) {
|
||||
|
||||
bool RemoveDir(const std::string& directory_name) {
|
||||
#ifdef WIN32
|
||||
return RemoveDirectoryA(directory_name.c_str()) != FALSE;
|
||||
return RemoveDirectoryA(directory_name.c_str()) != FALSE;
|
||||
#else
|
||||
return rmdir(directory_name.c_str()) == 0;
|
||||
return rmdir(directory_name.c_str()) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -332,10 +332,10 @@ std::string ResourcePath(const std::string& name,
|
||||
std::string architecture = "32";
|
||||
#endif // WEBRTC_ARCH_64_BITS
|
||||
|
||||
std::string resources_path = ProjectRootPath() + kResourcesDirName +
|
||||
kPathDelimiter;
|
||||
std::string resources_path =
|
||||
ProjectRootPath() + kResourcesDirName + kPathDelimiter;
|
||||
std::string resource_file = resources_path + name + "_" + platform + "_" +
|
||||
architecture + "." + extension;
|
||||
architecture + "." + extension;
|
||||
if (FileExists(resource_file)) {
|
||||
return resource_file;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ std::string OutputPath();
|
||||
// Generates an empty file with a unique name in the specified directory and
|
||||
// returns the file name and path.
|
||||
// TODO(titovartem) rename to TempFile and next method to TempFilename
|
||||
std::string TempFilename(const std::string &dir, const std::string &prefix);
|
||||
std::string TempFilename(const std::string& dir, const std::string& prefix);
|
||||
|
||||
// Generates a unique file name that can be used for file creation. Doesn't
|
||||
// create any files.
|
||||
|
||||
@ -69,19 +69,17 @@ void WriteStringInFile(const std::string& what, const std::string& file_path) {
|
||||
// gtest framework).
|
||||
class FileUtilsTest : public testing::Test {
|
||||
protected:
|
||||
FileUtilsTest() {
|
||||
}
|
||||
FileUtilsTest() {}
|
||||
~FileUtilsTest() override {}
|
||||
// Runs before the first test
|
||||
static void SetUpTestCase() {
|
||||
original_working_dir_ = webrtc::test::WorkingDir();
|
||||
}
|
||||
void SetUp() override {
|
||||
ASSERT_EQ(chdir(original_working_dir_.c_str()), 0);
|
||||
}
|
||||
void SetUp() override { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); }
|
||||
void TearDown() override {
|
||||
ASSERT_EQ(chdir(original_working_dir_.c_str()), 0);
|
||||
}
|
||||
|
||||
private:
|
||||
static std::string original_working_dir_;
|
||||
};
|
||||
@ -186,8 +184,8 @@ TEST_F(FileUtilsTest, GetFileSizeExistingFile) {
|
||||
webrtc::test::OutputPath(), "fileutils_unittest");
|
||||
FILE* file = fopen(temp_filename.c_str(), "wb");
|
||||
ASSERT_TRUE(file != NULL) << "Failed to open file: " << temp_filename;
|
||||
ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) <<
|
||||
"Failed to write to file: " << temp_filename;
|
||||
ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0)
|
||||
<< "Failed to write to file: " << temp_filename;
|
||||
fclose(file);
|
||||
ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u);
|
||||
remove(temp_filename.c_str());
|
||||
|
||||
@ -86,7 +86,7 @@ class Y4mFrameWriterImpl : public YuvFrameWriterImpl {
|
||||
// LibJpeg is not available on iOS. This class will do nothing on iOS.
|
||||
class JpegFrameWriter {
|
||||
public:
|
||||
JpegFrameWriter(const std::string &output_filename);
|
||||
JpegFrameWriter(const std::string& output_filename);
|
||||
// Quality can be from 0 (worst) to 100 (best). Best quality is still lossy.
|
||||
// WriteFrame can be called only once. Subsequent calls will fail.
|
||||
bool WriteFrame(const VideoFrame& input_frame, int quality);
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -29,7 +28,7 @@ extern "C" {
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
JpegFrameWriter::JpegFrameWriter(const std::string &output_filename)
|
||||
JpegFrameWriter::JpegFrameWriter(const std::string& output_filename)
|
||||
: frame_written_(false),
|
||||
output_filename_(output_filename),
|
||||
output_file_(nullptr) {}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "test/testsupport/frame_writer.h"
|
||||
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
|
||||
@ -121,8 +121,7 @@ class PerfResultsLogger {
|
||||
}
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
FILE* output_
|
||||
RTC_GUARDED_BY(&crit_);
|
||||
FILE* output_ RTC_GUARDED_BY(&crit_);
|
||||
std::map<std::string, std::vector<std::string>> graphs_
|
||||
RTC_GUARDED_BY(&crit_);
|
||||
};
|
||||
|
||||
@ -60,12 +60,9 @@ namespace test {
|
||||
|
||||
class PerfTest : public ::testing::Test {
|
||||
protected:
|
||||
void TearDown() override {
|
||||
ClearPerfResults();
|
||||
}
|
||||
void TearDown() override { ClearPerfResults(); }
|
||||
};
|
||||
|
||||
|
||||
#if defined(WEBRTC_IOS)
|
||||
#define MAYBE_TestPrintResult DISABLED_TestPrintResult
|
||||
#else
|
||||
|
||||
@ -22,7 +22,7 @@ const std::string& DefaultArtifactPath() {
|
||||
static const std::string path = webrtc::test::OutputPath();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DEFINE_string(test_artifacts_dir,
|
||||
DefaultArtifactPath().c_str(),
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "test/vcm_capturer.h"
|
||||
|
||||
#include "call/video_send_stream.h"
|
||||
#include "modules/video_capture/video_capture_factory.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "call/video_send_stream.h"
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -68,7 +68,6 @@ VcmCapturer* VcmCapturer::Create(size_t width,
|
||||
return vcm_capturer.release();
|
||||
}
|
||||
|
||||
|
||||
void VcmCapturer::Start() {
|
||||
rtc::CritScope lock(&crit_);
|
||||
started_ = true;
|
||||
@ -103,7 +102,9 @@ void VcmCapturer::Destroy() {
|
||||
vcm_ = nullptr;
|
||||
}
|
||||
|
||||
VcmCapturer::~VcmCapturer() { Destroy(); }
|
||||
VcmCapturer::~VcmCapturer() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void VcmCapturer::OnFrame(const VideoFrame& frame) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
@ -114,5 +115,5 @@ void VcmCapturer::OnFrame(const VideoFrame& frame) {
|
||||
}
|
||||
}
|
||||
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -22,9 +22,8 @@
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class VcmCapturer
|
||||
: public VideoCapturer,
|
||||
public rtc::VideoSinkInterface<VideoFrame> {
|
||||
class VcmCapturer : public VideoCapturer,
|
||||
public rtc::VideoSinkInterface<VideoFrame> {
|
||||
public:
|
||||
static VcmCapturer* Create(size_t width,
|
||||
size_t height,
|
||||
@ -55,7 +54,7 @@ class VcmCapturer
|
||||
VideoCaptureCapability capability_;
|
||||
};
|
||||
|
||||
} // test
|
||||
} // webrtc
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_VCM_CAPTURER_H_
|
||||
|
||||
@ -22,7 +22,8 @@ class VideoRenderer : public rtc::VideoSinkInterface<VideoFrame> {
|
||||
public:
|
||||
// Creates a platform-specific renderer if possible, or a null implementation
|
||||
// if failing.
|
||||
static VideoRenderer* Create(const char* window_title, size_t width,
|
||||
static VideoRenderer* Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height);
|
||||
// Returns a renderer rendering to a platform specific window if possible,
|
||||
// NULL if none can be created.
|
||||
@ -30,8 +31,10 @@ class VideoRenderer : public rtc::VideoSinkInterface<VideoFrame> {
|
||||
// platform renderer could not be created. This occurs, for instance, when
|
||||
// running without an X environment on Linux.
|
||||
static VideoRenderer* CreatePlatformRenderer(const char* window_title,
|
||||
size_t width, size_t height);
|
||||
size_t width,
|
||||
size_t height);
|
||||
virtual ~VideoRenderer() {}
|
||||
|
||||
protected:
|
||||
VideoRenderer() {}
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1)
|
||||
|
||||
struct D3dCustomVertex {
|
||||
float x, y, z;
|
||||
@ -42,9 +42,13 @@ D3dRenderer::D3dRenderer(size_t width, size_t height)
|
||||
RTC_DCHECK_GT(height, 0);
|
||||
}
|
||||
|
||||
D3dRenderer::~D3dRenderer() { Destroy(); }
|
||||
D3dRenderer::~D3dRenderer() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd,
|
||||
UINT msg,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) {
|
||||
if (msg == WM_DESTROY || (msg == WM_CHAR && wparam == VK_RETURN)) {
|
||||
PostQuitMessage(0);
|
||||
@ -68,17 +72,9 @@ void D3dRenderer::Destroy() {
|
||||
}
|
||||
|
||||
bool D3dRenderer::Init(const char* window_title) {
|
||||
hwnd_ = CreateWindowA(kD3DClassName,
|
||||
window_title,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
static_cast<int>(width_),
|
||||
static_cast<int>(height_),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
hwnd_ = CreateWindowA(kD3DClassName, window_title, WS_OVERLAPPEDWINDOW, 0, 0,
|
||||
static_cast<int>(width_), static_cast<int>(height_),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
if (hwnd_ == NULL) {
|
||||
Destroy();
|
||||
@ -97,11 +93,8 @@ bool D3dRenderer::Init(const char* window_title) {
|
||||
d3d_params.SwapEffect = D3DSWAPEFFECT_COPY;
|
||||
|
||||
IDirect3DDevice9* d3d_device;
|
||||
if (d3d_->CreateDevice(D3DADAPTER_DEFAULT,
|
||||
D3DDEVTYPE_HAL,
|
||||
hwnd_,
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||
&d3d_params,
|
||||
if (d3d_->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd_,
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3d_params,
|
||||
&d3d_device) != D3D_OK) {
|
||||
Destroy();
|
||||
return false;
|
||||
@ -112,11 +105,8 @@ bool D3dRenderer::Init(const char* window_title) {
|
||||
IDirect3DVertexBuffer9* vertex_buffer;
|
||||
const int kRectVertices = 4;
|
||||
if (d3d_device_->CreateVertexBuffer(kRectVertices * sizeof(D3dCustomVertex),
|
||||
0,
|
||||
D3DFVF_CUSTOMVERTEX,
|
||||
D3DPOOL_MANAGED,
|
||||
&vertex_buffer,
|
||||
NULL) != D3D_OK) {
|
||||
0, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED,
|
||||
&vertex_buffer, NULL) != D3D_OK) {
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
@ -166,22 +156,17 @@ void D3dRenderer::Resize(size_t width, size_t height) {
|
||||
IDirect3DTexture9* texture;
|
||||
|
||||
d3d_device_->CreateTexture(static_cast<UINT>(width_),
|
||||
static_cast<UINT>(height_),
|
||||
1,
|
||||
0,
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED,
|
||||
&texture,
|
||||
NULL);
|
||||
static_cast<UINT>(height_), 1, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, &texture, NULL);
|
||||
texture_ = texture;
|
||||
texture->Release();
|
||||
|
||||
// Vertices for the video frame to be rendered to.
|
||||
static const D3dCustomVertex rect[] = {
|
||||
{-1.0f, -1.0f, 0.0f, 0.0f, 1.0f},
|
||||
{-1.0f, 1.0f, 0.0f, 0.0f, 0.0f},
|
||||
{1.0f, -1.0f, 0.0f, 1.0f, 1.0f},
|
||||
{1.0f, 1.0f, 0.0f, 1.0f, 0.0f},
|
||||
{-1.0f, -1.0f, 0.0f, 0.0f, 1.0f},
|
||||
{-1.0f, 1.0f, 0.0f, 0.0f, 0.0f},
|
||||
{1.0f, -1.0f, 0.0f, 1.0f, 1.0f},
|
||||
{1.0f, 1.0f, 0.0f, 1.0f, 0.0f},
|
||||
};
|
||||
|
||||
void* buf_data;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <Windows.h>
|
||||
#include <d3d9.h>
|
||||
#pragma comment(lib, "d3d9.lib") // located in DirectX SDK
|
||||
#pragma comment(lib, "d3d9.lib") // located in DirectX SDK
|
||||
|
||||
#include "rtc_base/scoped_ref_ptr.h"
|
||||
#include "test/video_renderer.h"
|
||||
@ -23,7 +23,8 @@ namespace test {
|
||||
|
||||
class D3dRenderer : public VideoRenderer {
|
||||
public:
|
||||
static D3dRenderer* Create(const char* window_title, size_t width,
|
||||
static D3dRenderer* Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height);
|
||||
virtual ~D3dRenderer();
|
||||
|
||||
@ -32,7 +33,9 @@ class D3dRenderer : public VideoRenderer {
|
||||
private:
|
||||
D3dRenderer(size_t width, size_t height);
|
||||
|
||||
static LRESULT WINAPI WindowProc(HWND hwnd, UINT msg, WPARAM wparam,
|
||||
static LRESULT WINAPI WindowProc(HWND hwnd,
|
||||
UINT msg,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
bool Init(const char* window_title);
|
||||
void Resize(size_t width, size_t height);
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <Windows.h>
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
Reference in New Issue
Block a user