Add RTC_ prefix to (D)CHECKs and related macros.
We must remove dependency on Chromium, i.e. we can't use Chromium's base/logging.h. That means we need to define these macros in WebRTC also when doing Chromium builds. And this causes redefinition. Alternative solutions: * Check if we already have defined e.g. CHECK, and don't define them in that case. This makes us depend on include order in Chromium, which is not acceptable. * Don't allow using the macros in WebRTC headers. Error prone since if someone adds it there by mistake it may compile fine, but later break if a header in added or order is changed in Chromium. That will be confusing and hard to enforce. * Ensure that headers that are included by an embedder don't include our macros. This would require some heavy refactoring to be maintainable and enforcable. * Changes in Chromium for this is obviously not an option. BUG=chromium:468375 NOTRY=true Review URL: https://codereview.webrtc.org/1335923002 Cr-Commit-Position: refs/heads/master@{#9964}
This commit is contained in:
@ -32,11 +32,11 @@ ConstantPcmPacketSource::ConstantPcmPacketSource(size_t payload_len_samples,
|
||||
timestamp_(0),
|
||||
payload_ssrc_(0xABCD1234) {
|
||||
size_t encoded_len = WebRtcPcm16b_Encode(&sample_value, 1, encoded_sample_);
|
||||
CHECK_EQ(2U, encoded_len);
|
||||
RTC_CHECK_EQ(2U, encoded_len);
|
||||
}
|
||||
|
||||
Packet* ConstantPcmPacketSource::NextPacket() {
|
||||
CHECK_GT(packet_len_bytes_, kHeaderLenBytes);
|
||||
RTC_CHECK_GT(packet_len_bytes_, kHeaderLenBytes);
|
||||
uint8_t* packet_memory = new uint8_t[packet_len_bytes_];
|
||||
// Fill the payload part of the packet memory with the pre-encoded value.
|
||||
for (unsigned i = 0; i < 2 * payload_len_samples_; ++i)
|
||||
|
||||
@ -45,16 +45,18 @@ bool InputAudioFile::Seek(int samples) {
|
||||
}
|
||||
// Find file boundaries.
|
||||
const long current_pos = ftell(fp_);
|
||||
CHECK_NE(EOF, current_pos) << "Error returned when getting file position.";
|
||||
CHECK_EQ(0, fseek(fp_, 0, SEEK_END)); // Move to end of file.
|
||||
RTC_CHECK_NE(EOF, current_pos)
|
||||
<< "Error returned when getting file position.";
|
||||
RTC_CHECK_EQ(0, fseek(fp_, 0, SEEK_END)); // Move to end of file.
|
||||
const long file_size = ftell(fp_);
|
||||
CHECK_NE(EOF, file_size) << "Error returned when getting file position.";
|
||||
RTC_CHECK_NE(EOF, file_size) << "Error returned when getting file position.";
|
||||
// Find new position.
|
||||
long new_pos = current_pos + sizeof(int16_t) * samples; // Samples to bytes.
|
||||
CHECK_GE(new_pos, 0) << "Trying to move to before the beginning of the file";
|
||||
RTC_CHECK_GE(new_pos, 0)
|
||||
<< "Trying to move to before the beginning of the file";
|
||||
new_pos = new_pos % file_size; // Wrap around the end of the file.
|
||||
// Move to new position relative to the beginning of the file.
|
||||
CHECK_EQ(0, fseek(fp_, new_pos, SEEK_SET));
|
||||
RTC_CHECK_EQ(0, fseek(fp_, new_pos, SEEK_SET));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ NetEqQualityTest::NetEqQualityTest(int block_duration_ms,
|
||||
const std::string out_filename = FLAGS_out_filename;
|
||||
const std::string log_filename = out_filename + ".log";
|
||||
log_file_.open(log_filename.c_str(), std::ofstream::out);
|
||||
CHECK(log_file_.is_open());
|
||||
RTC_CHECK(log_file_.is_open());
|
||||
|
||||
if (out_filename.size() >= 4 &&
|
||||
out_filename.substr(out_filename.size() - 4) == ".wav") {
|
||||
@ -402,7 +402,7 @@ int NetEqQualityTest::DecodeBlock() {
|
||||
} else {
|
||||
assert(channels == channels_);
|
||||
assert(samples == static_cast<size_t>(kOutputSizeMs * out_sampling_khz_));
|
||||
CHECK(output_->WriteArray(out_data_.get(), samples * channels));
|
||||
RTC_CHECK(output_->WriteArray(out_data_.get(), samples * channels));
|
||||
return static_cast<int>(samples);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ int main(int argc, char* argv[]) {
|
||||
// Check if an SSRC value was provided.
|
||||
if (!FLAGS_ssrc.empty()) {
|
||||
uint32_t ssrc;
|
||||
CHECK(ParseSsrc(FLAGS_ssrc, &ssrc)) << "Flag verification has failed.";
|
||||
RTC_CHECK(ParseSsrc(FLAGS_ssrc, &ssrc)) << "Flag verification has failed.";
|
||||
file_source->SelectSsrc(ssrc);
|
||||
}
|
||||
|
||||
|
||||
@ -20,22 +20,22 @@ bool ResampleInputAudioFile::Read(size_t samples,
|
||||
int output_rate_hz,
|
||||
int16_t* destination) {
|
||||
const size_t samples_to_read = samples * file_rate_hz_ / output_rate_hz;
|
||||
CHECK_EQ(samples_to_read * output_rate_hz, samples * file_rate_hz_)
|
||||
RTC_CHECK_EQ(samples_to_read * output_rate_hz, samples * file_rate_hz_)
|
||||
<< "Frame size and sample rates don't add up to an integer.";
|
||||
rtc::scoped_ptr<int16_t[]> temp_destination(new int16_t[samples_to_read]);
|
||||
if (!InputAudioFile::Read(samples_to_read, temp_destination.get()))
|
||||
return false;
|
||||
resampler_.ResetIfNeeded(file_rate_hz_, output_rate_hz, 1);
|
||||
size_t output_length = 0;
|
||||
CHECK_EQ(resampler_.Push(temp_destination.get(), samples_to_read, destination,
|
||||
samples, output_length),
|
||||
0);
|
||||
CHECK_EQ(samples, output_length);
|
||||
RTC_CHECK_EQ(resampler_.Push(temp_destination.get(), samples_to_read,
|
||||
destination, samples, output_length),
|
||||
0);
|
||||
RTC_CHECK_EQ(samples, output_length);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResampleInputAudioFile::Read(size_t samples, int16_t* destination) {
|
||||
CHECK_GT(output_rate_hz_, 0) << "Output rate not set.";
|
||||
RTC_CHECK_GT(output_rate_hz_, 0) << "Output rate not set.";
|
||||
return Read(samples, output_rate_hz_, destination);
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ const rtclog::DebugEvent* GetAudioOutputEvent(const rtclog::Event& event) {
|
||||
|
||||
RtcEventLogSource* RtcEventLogSource::Create(const std::string& file_name) {
|
||||
RtcEventLogSource* source = new RtcEventLogSource();
|
||||
CHECK(source->OpenFile(file_name));
|
||||
RTC_CHECK(source->OpenFile(file_name));
|
||||
return source;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ RtcEventLogSource::~RtcEventLogSource() {}
|
||||
|
||||
bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type,
|
||||
uint8_t id) {
|
||||
CHECK(parser_.get());
|
||||
RTC_CHECK(parser_.get());
|
||||
return parser_->RegisterRtpHeaderExtension(type, id);
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ namespace test {
|
||||
|
||||
RtpFileSource* RtpFileSource::Create(const std::string& file_name) {
|
||||
RtpFileSource* source = new RtpFileSource();
|
||||
CHECK(source->OpenFile(file_name));
|
||||
RTC_CHECK(source->OpenFile(file_name));
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@ -28,18 +28,18 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
scoped_ptr<RtpFileWriter> output(
|
||||
RtpFileWriter::Create(RtpFileWriter::kRtpDump, argv[argc - 1]));
|
||||
CHECK(output.get() != NULL) << "Cannot open output file.";
|
||||
RTC_CHECK(output.get() != NULL) << "Cannot open output file.";
|
||||
printf("Output RTP file: %s\n", argv[argc - 1]);
|
||||
|
||||
for (int i = 1; i < argc - 1; i++) {
|
||||
scoped_ptr<RtpFileReader> input(
|
||||
RtpFileReader::Create(RtpFileReader::kRtpDump, argv[i]));
|
||||
CHECK(input.get() != NULL) << "Cannot open input file " << argv[i];
|
||||
RTC_CHECK(input.get() != NULL) << "Cannot open input file " << argv[i];
|
||||
printf("Input RTP file: %s\n", argv[i]);
|
||||
|
||||
webrtc::test::RtpPacket packet;
|
||||
while (input->NextPacket(&packet))
|
||||
CHECK(output->WritePacket(&packet));
|
||||
RTC_CHECK(output->WritePacket(&packet));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user