Replace assert() with RTC_DCHECK().
CL partially auto-generated with:
git grep -l "\bassert(" | grep "\.[c|h]" | \
xargs sed -i 's/\bassert(/RTC_DCHECK(/g'
And with:
git grep -l "RTC_DCHECK(false)" | \
xargs sed -i 's/RTC_DCHECK(false)/RTC_NOTREACHED()/g'
With some manual changes to include "rtc_base/checks.h" where
needed.
A follow-up CL will remove assert() from Obj-C code as well
and remove the #include of <assert.h>.
The choice to replace with RTC_DCHECK is because assert()
is because RTC_DCHECK has similar behavior as assert()
based on NDEBUG.
This CL also contains manual changes to switch from
basic RTC_DCHECK to other (preferred) versions like
RTC_DCHECK_GT (and similar).
Bug: webrtc:6779
Change-Id: I00bed8886e03d685a2f42324e34aef2c9b7a63b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224846
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34442}
This commit is contained in:
parent
9b5d570ae0
commit
25ab3228f3
@ -162,7 +162,7 @@ AudioDecoder::SpeechType AudioDecoder::ConvertSpeechType(int16_t type) {
|
||||
case 2:
|
||||
return kComfortNoise;
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return kSpeech;
|
||||
}
|
||||
}
|
||||
|
||||
@ -760,6 +760,7 @@ if (is_linux || is_chromeos || is_win) {
|
||||
"peerconnection/server/utils.h",
|
||||
]
|
||||
deps = [
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../system_wrappers:field_trial",
|
||||
"../test:field_trial",
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include "examples/peerconnection/server/data_socket.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -20,6 +19,7 @@
|
||||
#endif
|
||||
|
||||
#include "examples/peerconnection/server/utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
static const char kHeaderTerminator[] = "\r\n\r\n";
|
||||
static const int kHeaderTerminatorLength = sizeof(kHeaderTerminator) - 1;
|
||||
@ -53,7 +53,7 @@ WinsockInitializer WinsockInitializer::singleton;
|
||||
//
|
||||
|
||||
bool SocketBase::Create() {
|
||||
assert(!valid());
|
||||
RTC_DCHECK(!valid());
|
||||
socket_ = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
return valid();
|
||||
}
|
||||
@ -77,7 +77,7 @@ std::string DataSocket::request_arguments() const {
|
||||
}
|
||||
|
||||
bool DataSocket::PathEquals(const char* path) const {
|
||||
assert(path);
|
||||
RTC_DCHECK(path);
|
||||
size_t args = request_path_.find('?');
|
||||
if (args != std::string::npos)
|
||||
return request_path_.substr(0, args).compare(path) == 0;
|
||||
@ -85,7 +85,7 @@ bool DataSocket::PathEquals(const char* path) const {
|
||||
}
|
||||
|
||||
bool DataSocket::OnDataAvailable(bool* close_socket) {
|
||||
assert(valid());
|
||||
RTC_DCHECK(valid());
|
||||
char buffer[0xfff] = {0};
|
||||
int bytes = recv(socket_, buffer, sizeof(buffer), 0);
|
||||
if (bytes == SOCKET_ERROR || bytes == 0) {
|
||||
@ -125,8 +125,8 @@ bool DataSocket::Send(const std::string& status,
|
||||
const std::string& content_type,
|
||||
const std::string& extra_headers,
|
||||
const std::string& data) const {
|
||||
assert(valid());
|
||||
assert(!status.empty());
|
||||
RTC_DCHECK(valid());
|
||||
RTC_DCHECK(!status.empty());
|
||||
std::string buffer("HTTP/1.1 " + status + "\r\n");
|
||||
|
||||
buffer +=
|
||||
@ -165,8 +165,8 @@ void DataSocket::Clear() {
|
||||
}
|
||||
|
||||
bool DataSocket::ParseHeaders() {
|
||||
assert(!request_headers_.empty());
|
||||
assert(method_ == INVALID);
|
||||
RTC_DCHECK(!request_headers_.empty());
|
||||
RTC_DCHECK_EQ(method_, INVALID);
|
||||
size_t i = request_headers_.find("\r\n");
|
||||
if (i == std::string::npos)
|
||||
return false;
|
||||
@ -174,8 +174,8 @@ bool DataSocket::ParseHeaders() {
|
||||
if (!ParseMethodAndPath(request_headers_.data(), i))
|
||||
return false;
|
||||
|
||||
assert(method_ != INVALID);
|
||||
assert(!request_path_.empty());
|
||||
RTC_DCHECK_NE(method_, INVALID);
|
||||
RTC_DCHECK(!request_path_.empty());
|
||||
|
||||
if (method_ == POST) {
|
||||
const char* headers = request_headers_.data() + i + 2;
|
||||
@ -225,8 +225,8 @@ bool DataSocket::ParseMethodAndPath(const char* begin, size_t len) {
|
||||
}
|
||||
|
||||
bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
|
||||
assert(content_length_ == 0);
|
||||
assert(content_type_.empty());
|
||||
RTC_DCHECK_EQ(content_length_, 0);
|
||||
RTC_DCHECK(content_type_.empty());
|
||||
|
||||
const char* end = headers + length;
|
||||
while (headers && headers < end) {
|
||||
@ -267,7 +267,7 @@ bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
|
||||
//
|
||||
|
||||
bool ListeningSocket::Listen(unsigned short port) {
|
||||
assert(valid());
|
||||
RTC_DCHECK(valid());
|
||||
int enabled = 1;
|
||||
setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
|
||||
reinterpret_cast<const char*>(&enabled), sizeof(enabled));
|
||||
@ -284,7 +284,7 @@ bool ListeningSocket::Listen(unsigned short port) {
|
||||
}
|
||||
|
||||
DataSocket* ListeningSocket::Accept() const {
|
||||
assert(valid());
|
||||
RTC_DCHECK(valid());
|
||||
struct sockaddr_in addr = {0};
|
||||
socklen_t size = sizeof(addr);
|
||||
NativeSocket client =
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if defined(WEBRTC_POSIX)
|
||||
@ -24,6 +23,7 @@
|
||||
#include "absl/flags/usage.h"
|
||||
#include "examples/peerconnection/server/data_socket.h"
|
||||
#include "examples/peerconnection/server/peer_channel.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "test/field_trial.h"
|
||||
|
||||
@ -41,8 +41,8 @@ ABSL_FLAG(int, port, 8888, "default: 8888");
|
||||
static const size_t kMaxConnections = (FD_SETSIZE - 2);
|
||||
|
||||
void HandleBrowserRequest(DataSocket* ds, bool* quit) {
|
||||
assert(ds && ds->valid());
|
||||
assert(quit);
|
||||
RTC_DCHECK(ds && ds->valid());
|
||||
RTC_DCHECK(quit);
|
||||
|
||||
const std::string& path = ds->request_path();
|
||||
|
||||
@ -162,7 +162,7 @@ int main(int argc, char* argv[]) {
|
||||
if (socket_done) {
|
||||
printf("Disconnecting socket\n");
|
||||
clients.OnClosing(s);
|
||||
assert(s->valid()); // Close must not have been called yet.
|
||||
RTC_DCHECK(s->valid()); // Close must not have been called yet.
|
||||
FD_CLR(s->socket(), &socket_set);
|
||||
delete (*i);
|
||||
i = sockets.erase(i);
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include "examples/peerconnection/server/peer_channel.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -18,6 +17,7 @@
|
||||
|
||||
#include "examples/peerconnection/server/data_socket.h"
|
||||
#include "examples/peerconnection/server/utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
// Set to the peer id of the originator when messages are being
|
||||
// exchanged between peers, but set to the id of the receiving peer
|
||||
@ -57,9 +57,9 @@ ChannelMember::ChannelMember(DataSocket* socket)
|
||||
id_(++s_member_id_),
|
||||
connected_(true),
|
||||
timestamp_(time(NULL)) {
|
||||
assert(socket);
|
||||
assert(socket->method() == DataSocket::GET);
|
||||
assert(socket->PathEquals("/sign_in"));
|
||||
RTC_DCHECK(socket);
|
||||
RTC_DCHECK_EQ(socket->method(), DataSocket::GET);
|
||||
RTC_DCHECK(socket->PathEquals("/sign_in"));
|
||||
name_ = socket->request_arguments();
|
||||
if (name_.empty())
|
||||
name_ = "peer_" + int2str(id_);
|
||||
@ -85,14 +85,14 @@ std::string ChannelMember::GetPeerIdHeader() const {
|
||||
}
|
||||
|
||||
bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) {
|
||||
assert(&other != this);
|
||||
RTC_DCHECK_NE(&other, this);
|
||||
QueueResponse("200 OK", "text/plain", GetPeerIdHeader(), other.GetEntry());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns a string in the form "name,id,connected\n".
|
||||
std::string ChannelMember::GetEntry() const {
|
||||
assert(name_.length() <= kMaxNameLength);
|
||||
RTC_DCHECK(name_.length() <= kMaxNameLength);
|
||||
|
||||
// name, 11-digit int, 1-digit bool, newline, null
|
||||
char entry[kMaxNameLength + 15];
|
||||
@ -102,8 +102,8 @@ std::string ChannelMember::GetEntry() const {
|
||||
}
|
||||
|
||||
void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) {
|
||||
assert(peer);
|
||||
assert(ds);
|
||||
RTC_DCHECK(peer);
|
||||
RTC_DCHECK(ds);
|
||||
|
||||
std::string extra_headers(GetPeerIdHeader());
|
||||
|
||||
@ -129,8 +129,8 @@ void ChannelMember::QueueResponse(const std::string& status,
|
||||
const std::string& extra_headers,
|
||||
const std::string& data) {
|
||||
if (waiting_socket_) {
|
||||
assert(queue_.empty());
|
||||
assert(waiting_socket_->method() == DataSocket::GET);
|
||||
RTC_DCHECK(queue_.empty());
|
||||
RTC_DCHECK_EQ(waiting_socket_->method(), DataSocket::GET);
|
||||
bool ok =
|
||||
waiting_socket_->Send(status, true, content_type, extra_headers, data);
|
||||
if (!ok) {
|
||||
@ -149,9 +149,9 @@ void ChannelMember::QueueResponse(const std::string& status,
|
||||
}
|
||||
|
||||
void ChannelMember::SetWaitingSocket(DataSocket* ds) {
|
||||
assert(ds->method() == DataSocket::GET);
|
||||
RTC_DCHECK_EQ(ds->method(), DataSocket::GET);
|
||||
if (ds && !queue_.empty()) {
|
||||
assert(waiting_socket_ == NULL);
|
||||
RTC_DCHECK(!waiting_socket_);
|
||||
const QueuedResponse& response = queue_.front();
|
||||
ds->Send(response.status, true, response.content_type,
|
||||
response.extra_headers, response.data);
|
||||
@ -167,13 +167,13 @@ void ChannelMember::SetWaitingSocket(DataSocket* ds) {
|
||||
|
||||
// static
|
||||
bool PeerChannel::IsPeerConnection(const DataSocket* ds) {
|
||||
assert(ds);
|
||||
RTC_DCHECK(ds);
|
||||
return (ds->method() == DataSocket::POST && ds->content_length() > 0) ||
|
||||
(ds->method() == DataSocket::GET && ds->PathEquals("/sign_in"));
|
||||
}
|
||||
|
||||
ChannelMember* PeerChannel::Lookup(DataSocket* ds) const {
|
||||
assert(ds);
|
||||
RTC_DCHECK(ds);
|
||||
|
||||
if (ds->method() != DataSocket::GET && ds->method() != DataSocket::POST)
|
||||
return NULL;
|
||||
@ -209,7 +209,7 @@ ChannelMember* PeerChannel::Lookup(DataSocket* ds) const {
|
||||
}
|
||||
|
||||
ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const {
|
||||
assert(ds);
|
||||
RTC_DCHECK(ds);
|
||||
// Regardless of GET or POST, we look for the peer_id parameter
|
||||
// only in the request_path.
|
||||
const std::string& path = ds->request_path();
|
||||
@ -239,7 +239,7 @@ ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const {
|
||||
}
|
||||
|
||||
bool PeerChannel::AddMember(DataSocket* ds) {
|
||||
assert(IsPeerConnection(ds));
|
||||
RTC_DCHECK(IsPeerConnection(ds));
|
||||
ChannelMember* new_guy = new ChannelMember(ds);
|
||||
Members failures;
|
||||
BroadcastChangedState(*new_guy, &failures);
|
||||
@ -308,7 +308,7 @@ void PeerChannel::DeleteAll() {
|
||||
void PeerChannel::BroadcastChangedState(const ChannelMember& member,
|
||||
Members* delivery_failures) {
|
||||
// This function should be called prior to DataSocket::Close().
|
||||
assert(delivery_failures);
|
||||
RTC_DCHECK(delivery_failures);
|
||||
|
||||
if (!member.connected()) {
|
||||
printf("Member disconnected: %s\n", member.name().c_str());
|
||||
@ -329,12 +329,12 @@ void PeerChannel::BroadcastChangedState(const ChannelMember& member,
|
||||
}
|
||||
|
||||
void PeerChannel::HandleDeliveryFailures(Members* failures) {
|
||||
assert(failures);
|
||||
RTC_DCHECK(failures);
|
||||
|
||||
while (!failures->empty()) {
|
||||
Members::iterator i = failures->begin();
|
||||
ChannelMember* member = *i;
|
||||
assert(!member->connected());
|
||||
RTC_DCHECK(!member->connected());
|
||||
failures->erase(i);
|
||||
BroadcastChangedState(*member, failures);
|
||||
delete member;
|
||||
@ -344,14 +344,14 @@ void PeerChannel::HandleDeliveryFailures(Members* failures) {
|
||||
// Builds a simple list of "name,id\n" entries for each member.
|
||||
std::string PeerChannel::BuildResponseForNewMember(const ChannelMember& member,
|
||||
std::string* content_type) {
|
||||
assert(content_type);
|
||||
RTC_DCHECK(content_type);
|
||||
|
||||
*content_type = "text/plain";
|
||||
// The peer itself will always be the first entry.
|
||||
std::string response(member.GetEntry());
|
||||
for (Members::iterator i = members_.begin(); i != members_.end(); ++i) {
|
||||
if (member.id() != (*i)->id()) {
|
||||
assert((*i)->connected());
|
||||
RTC_DCHECK((*i)->connected());
|
||||
response += (*i)->GetEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1606,6 +1606,7 @@ if (rtc_include_tests) {
|
||||
deps += [
|
||||
":isac_fix",
|
||||
":webrtc_opus",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../test:test_main",
|
||||
"../../test:test_support",
|
||||
|
||||
@ -119,7 +119,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
|
||||
rtp_header_,
|
||||
rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
|
||||
if (ret_val < 0) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
rtp_header_.sequenceNumber++;
|
||||
|
||||
@ -31,7 +31,7 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
|
||||
size_t in_length = in_freq_hz * num_audio_channels / 100;
|
||||
if (in_freq_hz == out_freq_hz) {
|
||||
if (out_capacity_samples < in_length) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
memcpy(out_audio, in_audio, in_length * sizeof(int16_t));
|
||||
|
||||
@ -51,8 +51,8 @@ AcmSendTestOldApi::AcmSendTestOldApi(InputAudioFile* audio_source,
|
||||
input_frame_.sample_rate_hz_ = source_rate_hz_;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = input_block_size_samples_;
|
||||
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
acm_->RegisterTransportCallback(this);
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
|
||||
factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
|
||||
codec_registered_ = true;
|
||||
input_frame_.num_channels_ = num_channels;
|
||||
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
return codec_registered_;
|
||||
}
|
||||
|
||||
@ -90,13 +90,13 @@ void AcmSendTestOldApi::RegisterExternalCodec(
|
||||
std::unique_ptr<AudioEncoder> external_speech_encoder) {
|
||||
input_frame_.num_channels_ = external_speech_encoder->NumChannels();
|
||||
acm_->SetEncoder(std::move(external_speech_encoder));
|
||||
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
|
||||
AudioFrame::kMaxDataSizeSamples);
|
||||
codec_registered_ = true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
|
||||
assert(codec_registered_);
|
||||
RTC_DCHECK(codec_registered_);
|
||||
if (filter_.test(static_cast<size_t>(payload_type_))) {
|
||||
// This payload type should be filtered out. Since the payload type is the
|
||||
// same throughout the whole test run, no packet at all will be delivered.
|
||||
@ -133,7 +133,7 @@ int32_t AcmSendTestOldApi::SendData(AudioFrameType frame_type,
|
||||
payload_type_ = payload_type;
|
||||
timestamp_ = timestamp;
|
||||
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
|
||||
assert(last_payload_vec_.size() == payload_len_bytes);
|
||||
RTC_DCHECK_EQ(last_payload_vec_.size(), payload_len_bytes);
|
||||
data_to_send_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -343,13 +343,13 @@ int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
|
||||
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
|
||||
InputData* input_data) {
|
||||
if (audio_frame.samples_per_channel_ == 0) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h"
|
||||
#include "modules/audio_coding/codecs/isac/fix/source/settings.h"
|
||||
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -83,7 +84,7 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data,
|
||||
}
|
||||
clocks = clock() - clocks;
|
||||
*encoded_bytes = static_cast<size_t>(value);
|
||||
assert(*encoded_bytes <= max_bytes);
|
||||
RTC_DCHECK_LE(*encoded_bytes, max_bytes);
|
||||
return 1000.0 * clocks / CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ class SplitBySamplesTest : public ::testing::TestWithParam<NetEqDecoder> {
|
||||
samples_per_ms_ = 8;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/format_macros.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
@ -43,7 +44,7 @@ void AudioCodecSpeedTest::SetUp() {
|
||||
save_out_data_ = get<4>(GetParam());
|
||||
|
||||
FILE* fp = fopen(in_filename_.c_str(), "rb");
|
||||
assert(fp != NULL);
|
||||
RTC_DCHECK(fp);
|
||||
|
||||
// Obtain file size.
|
||||
fseek(fp, 0, SEEK_END);
|
||||
@ -83,7 +84,7 @@ void AudioCodecSpeedTest::SetUp() {
|
||||
out_filename = test::OutputPath() + out_filename + ".pcm";
|
||||
|
||||
out_file_ = fopen(out_filename.c_str(), "wb");
|
||||
assert(out_file_ != NULL);
|
||||
RTC_DCHECK(out_file_);
|
||||
|
||||
printf("Output to be saved in %s.\n", out_filename.c_str());
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ Accelerate::ReturnCodes Accelerate::CheckCriteriaAndStretch(
|
||||
peak_index = (fs_mult_120 / peak_index) * peak_index;
|
||||
}
|
||||
|
||||
assert(fs_mult_120 >= peak_index); // Should be handled in Process().
|
||||
RTC_DCHECK_GE(fs_mult_120, peak_index); // Should be handled in Process().
|
||||
// Copy first part; 0 to 15 ms.
|
||||
output->PushBackInterleaved(
|
||||
rtc::ArrayView<const int16_t>(input, fs_mult_120 * num_channels_));
|
||||
|
||||
@ -77,9 +77,9 @@ double MseInputOutput(const std::vector<int16_t>& input,
|
||||
size_t num_samples,
|
||||
size_t channels,
|
||||
int delay) {
|
||||
assert(delay < static_cast<int>(num_samples));
|
||||
assert(num_samples <= input.size());
|
||||
assert(num_samples * channels <= output.size());
|
||||
RTC_DCHECK_LT(delay, static_cast<int>(num_samples));
|
||||
RTC_DCHECK_LE(num_samples, input.size());
|
||||
RTC_DCHECK_LE(num_samples * channels, output.size());
|
||||
if (num_samples == 0)
|
||||
return 0.0;
|
||||
double squared_sum = 0.0;
|
||||
@ -303,7 +303,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
|
||||
frame_size_ = 20 * codec_input_rate_hz_ / 1000;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1);
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderPcm16B::Config config;
|
||||
config.sample_rate_hz = codec_input_rate_hz_;
|
||||
config.frame_size_ms =
|
||||
@ -320,7 +320,7 @@ class AudioDecoderIlbcTest : public AudioDecoderTest {
|
||||
frame_size_ = 240;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderIlbcImpl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderIlbcConfig config;
|
||||
config.frame_size_ms = 30;
|
||||
audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_));
|
||||
@ -414,7 +414,7 @@ class AudioDecoderG722Test : public AudioDecoderTest {
|
||||
frame_size_ = 160;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderG722Impl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderG722Config config;
|
||||
config.frame_size_ms = 10;
|
||||
config.num_channels = 1;
|
||||
@ -430,7 +430,7 @@ class AudioDecoderG722StereoTest : public AudioDecoderTest {
|
||||
frame_size_ = 160;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderG722StereoImpl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderG722Config config;
|
||||
config.frame_size_ms = 10;
|
||||
config.num_channels = 2;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
AudioMultiVector::AudioMultiVector(size_t N) {
|
||||
assert(N > 0);
|
||||
RTC_DCHECK_GT(N, 0);
|
||||
if (N < 1)
|
||||
N = 1;
|
||||
for (size_t n = 0; n < N; ++n) {
|
||||
@ -29,7 +29,7 @@ AudioMultiVector::AudioMultiVector(size_t N) {
|
||||
}
|
||||
|
||||
AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) {
|
||||
assert(N > 0);
|
||||
RTC_DCHECK_GT(N, 0);
|
||||
if (N < 1)
|
||||
N = 1;
|
||||
for (size_t n = 0; n < N; ++n) {
|
||||
@ -91,7 +91,7 @@ void AudioMultiVector::PushBackInterleaved(
|
||||
}
|
||||
|
||||
void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->PushBack(append_this[i]);
|
||||
@ -101,10 +101,10 @@ void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
|
||||
|
||||
void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this,
|
||||
size_t index) {
|
||||
assert(index < append_this.Size());
|
||||
RTC_DCHECK_LT(index, append_this.Size());
|
||||
index = std::min(index, append_this.Size() - 1);
|
||||
size_t length = append_this.Size() - index;
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->PushBack(append_this[i], length, index);
|
||||
@ -162,9 +162,9 @@ size_t AudioMultiVector::ReadInterleavedFromEnd(size_t length,
|
||||
void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
|
||||
size_t length,
|
||||
size_t position) {
|
||||
assert(num_channels_ == insert_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, insert_this.num_channels_);
|
||||
// Cap |length| at the length of |insert_this|.
|
||||
assert(length <= insert_this.Size());
|
||||
RTC_DCHECK_LE(length, insert_this.Size());
|
||||
length = std::min(length, insert_this.Size());
|
||||
if (num_channels_ == insert_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
@ -175,7 +175,7 @@ void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
|
||||
|
||||
void AudioMultiVector::CrossFade(const AudioMultiVector& append_this,
|
||||
size_t fade_length) {
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->CrossFade(append_this[i], fade_length);
|
||||
@ -188,7 +188,7 @@ size_t AudioMultiVector::Channels() const {
|
||||
}
|
||||
|
||||
size_t AudioMultiVector::Size() const {
|
||||
assert(channels_[0]);
|
||||
RTC_DCHECK(channels_[0]);
|
||||
return channels_[0]->Size();
|
||||
}
|
||||
|
||||
@ -202,13 +202,13 @@ void AudioMultiVector::AssertSize(size_t required_size) {
|
||||
}
|
||||
|
||||
bool AudioMultiVector::Empty() const {
|
||||
assert(channels_[0]);
|
||||
RTC_DCHECK(channels_[0]);
|
||||
return channels_[0]->Empty();
|
||||
}
|
||||
|
||||
void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) {
|
||||
assert(from_channel < num_channels_);
|
||||
assert(to_channel < num_channels_);
|
||||
RTC_DCHECK_LT(from_channel, num_channels_);
|
||||
RTC_DCHECK_LT(to_channel, num_channels_);
|
||||
channels_[from_channel]->CopyTo(channels_[to_channel]);
|
||||
}
|
||||
|
||||
|
||||
@ -247,8 +247,8 @@ void AudioVector::OverwriteAt(const int16_t* insert_this,
|
||||
void AudioVector::CrossFade(const AudioVector& append_this,
|
||||
size_t fade_length) {
|
||||
// Fade length cannot be longer than the current vector or |append_this|.
|
||||
assert(fade_length <= Size());
|
||||
assert(fade_length <= append_this.Size());
|
||||
RTC_DCHECK_LE(fade_length, Size());
|
||||
RTC_DCHECK_LE(fade_length, append_this.Size());
|
||||
fade_length = std::min(fade_length, Size());
|
||||
fade_length = std::min(fade_length, append_this.Size());
|
||||
size_t position = Size() - fade_length + begin_index_;
|
||||
@ -265,7 +265,7 @@ void AudioVector::CrossFade(const AudioVector& append_this,
|
||||
(16384 - alpha) * append_this[i] + 8192) >>
|
||||
14;
|
||||
}
|
||||
assert(alpha >= 0); // Verify that the slope was correct.
|
||||
RTC_DCHECK_GE(alpha, 0); // Verify that the slope was correct.
|
||||
// Append what is left of |append_this|.
|
||||
size_t samples_to_push_back = append_this.Size() - fade_length;
|
||||
if (samples_to_push_back > 0)
|
||||
|
||||
@ -136,7 +136,7 @@ void BackgroundNoise::GenerateBackgroundNoise(
|
||||
int16_t* buffer) {
|
||||
constexpr size_t kNoiseLpcOrder = kMaxLpcOrder;
|
||||
int16_t scaled_random_vector[kMaxSampleRate / 8000 * 125];
|
||||
assert(num_noise_samples <= (kMaxSampleRate / 8000 * 125));
|
||||
RTC_DCHECK_LE(num_noise_samples, (kMaxSampleRate / 8000 * 125));
|
||||
RTC_DCHECK_GE(random_vector.size(), num_noise_samples);
|
||||
int16_t* noise_samples = &buffer[kNoiseLpcOrder];
|
||||
if (initialized()) {
|
||||
@ -178,44 +178,44 @@ void BackgroundNoise::GenerateBackgroundNoise(
|
||||
}
|
||||
|
||||
int32_t BackgroundNoise::Energy(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].energy;
|
||||
}
|
||||
|
||||
void BackgroundNoise::SetMuteFactor(size_t channel, int16_t value) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
channel_parameters_[channel].mute_factor = value;
|
||||
}
|
||||
|
||||
int16_t BackgroundNoise::MuteFactor(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].mute_factor;
|
||||
}
|
||||
|
||||
const int16_t* BackgroundNoise::Filter(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].filter;
|
||||
}
|
||||
|
||||
const int16_t* BackgroundNoise::FilterState(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].filter_state;
|
||||
}
|
||||
|
||||
void BackgroundNoise::SetFilterState(size_t channel,
|
||||
rtc::ArrayView<const int16_t> input) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
size_t length = std::min(input.size(), kMaxLpcOrder);
|
||||
memcpy(channel_parameters_[channel].filter_state, input.data(),
|
||||
length * sizeof(int16_t));
|
||||
}
|
||||
|
||||
int16_t BackgroundNoise::Scale(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].scale;
|
||||
}
|
||||
int16_t BackgroundNoise::ScaleShift(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].scale_shift;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ void BackgroundNoise::IncrementEnergyThreshold(size_t channel,
|
||||
// to the limited-width operations, it is not exactly the same. The
|
||||
// difference should be inaudible, but bit-exactness would not be
|
||||
// maintained.
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
ChannelParameters& parameters = channel_parameters_[channel];
|
||||
int32_t temp_energy =
|
||||
(kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
|
||||
@ -278,7 +278,7 @@ void BackgroundNoise::SaveParameters(size_t channel,
|
||||
const int16_t* filter_state,
|
||||
int32_t sample_energy,
|
||||
int32_t residual_energy) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
ChannelParameters& parameters = channel_parameters_[channel];
|
||||
memcpy(parameters.filter, lpc_coefficients,
|
||||
(kMaxLpcOrder + 1) * sizeof(int16_t));
|
||||
|
||||
@ -45,8 +45,8 @@ int ComfortNoise::UpdateParameters(const Packet& packet) {
|
||||
|
||||
int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
// Not adapted for multi-channel yet.
|
||||
if (output->Channels() != 1) {
|
||||
RTC_LOG(LS_ERROR) << "No multi-channel support";
|
||||
|
||||
@ -96,7 +96,8 @@ void DecisionLogic::SoftReset() {
|
||||
|
||||
void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
|
||||
RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
|
||||
fs_hz == 48000);
|
||||
sample_rate_ = fs_hz;
|
||||
output_size_samples_ = output_size_samples;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ int DspHelper::RampSignal(AudioMultiVector* signal,
|
||||
size_t length,
|
||||
int factor,
|
||||
int increment) {
|
||||
assert(start_index + length <= signal->Size());
|
||||
RTC_DCHECK_LE(start_index + length, signal->Size());
|
||||
if (start_index + length > signal->Size()) {
|
||||
// Wrong parameters. Do nothing and return the scale factor unaltered.
|
||||
return factor;
|
||||
@ -355,7 +355,7 @@ int DspHelper::DownsampleTo4kHz(const int16_t* input,
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,9 +48,10 @@ Expand::Expand(BackgroundNoise* background_noise,
|
||||
stop_muting_(false),
|
||||
expand_duration_samples_(0),
|
||||
channel_parameters_(new ChannelParameters[num_channels_]) {
|
||||
assert(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
|
||||
assert(fs <= static_cast<int>(kMaxSampleRate)); // Should not be possible.
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
|
||||
RTC_DCHECK_LE(fs,
|
||||
static_cast<int>(kMaxSampleRate)); // Should not be possible.
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
memset(expand_lags_, 0, sizeof(expand_lags_));
|
||||
Reset();
|
||||
}
|
||||
@ -91,7 +92,7 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
// Extract a noise segment.
|
||||
size_t rand_length = max_lag_;
|
||||
// This only applies to SWB where length could be larger than 256.
|
||||
assert(rand_length <= kMaxSampleRate / 8000 * 120 + 30);
|
||||
RTC_DCHECK_LE(rand_length, kMaxSampleRate / 8000 * 120 + 30);
|
||||
GenerateRandomVector(2, rand_length, random_vector);
|
||||
}
|
||||
|
||||
@ -110,8 +111,8 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
ChannelParameters& parameters = channel_parameters_[channel_ix];
|
||||
if (current_lag_index_ == 0) {
|
||||
// Use only expand_vector0.
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector0.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector0.Size());
|
||||
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
|
||||
voiced_vector_storage);
|
||||
} else if (current_lag_index_ == 1) {
|
||||
@ -126,10 +127,10 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
voiced_vector_storage, temp_length);
|
||||
} else if (current_lag_index_ == 2) {
|
||||
// Mix 1/2 of expand_vector0 with 1/2 of expand_vector1.
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector0.Size());
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector1.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector0.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector1.Size());
|
||||
|
||||
std::unique_ptr<int16_t[]> temp_0(new int16_t[temp_length]);
|
||||
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
|
||||
@ -303,7 +304,7 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
if (channel_ix == 0) {
|
||||
output->AssertSize(current_lag);
|
||||
} else {
|
||||
assert(output->Size() == current_lag);
|
||||
RTC_DCHECK_EQ(output->Size(), current_lag);
|
||||
}
|
||||
(*output)[channel_ix].OverwriteAt(temp_data, current_lag, 0);
|
||||
}
|
||||
@ -465,7 +466,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
|
||||
size_t start_index = std::min(distortion_lag, correlation_lag);
|
||||
size_t correlation_lags = static_cast<size_t>(
|
||||
WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1);
|
||||
assert(correlation_lags <= static_cast<size_t>(99 * fs_mult + 1));
|
||||
RTC_DCHECK_LE(correlation_lags, static_cast<size_t>(99 * fs_mult + 1));
|
||||
|
||||
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
|
||||
ChannelParameters& parameters = channel_parameters_[channel_ix];
|
||||
@ -659,7 +660,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
|
||||
// |kRandomTableSize|.
|
||||
memcpy(random_vector, RandomVector::kRandomTable,
|
||||
sizeof(int16_t) * RandomVector::kRandomTableSize);
|
||||
assert(noise_length <= kMaxSampleRate / 8000 * 120 + 30);
|
||||
RTC_DCHECK_LE(noise_length, kMaxSampleRate / 8000 * 120 + 30);
|
||||
random_vector_->IncreaseSeedIncrement(2);
|
||||
random_vector_->Generate(
|
||||
noise_length - RandomVector::kRandomTableSize,
|
||||
|
||||
@ -59,7 +59,7 @@ class Expand {
|
||||
|
||||
// Returns the mute factor for |channel|.
|
||||
int16_t MuteFactor(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].mute_factor;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Merge::Merge(int fs_hz,
|
||||
expand_(expand),
|
||||
sync_buffer_(sync_buffer),
|
||||
expanded_(num_channels_) {
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
}
|
||||
|
||||
Merge::~Merge() = default;
|
||||
@ -47,9 +47,9 @@ size_t Merge::Process(int16_t* input,
|
||||
size_t input_length,
|
||||
AudioMultiVector* output) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
assert(fs_hz_ <= kMaxSampleRate); // Should not be possible.
|
||||
RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
RTC_DCHECK_LE(fs_hz_, kMaxSampleRate); // Should not be possible.
|
||||
if (input_length == 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -64,7 +64,7 @@ size_t Merge::Process(int16_t* input,
|
||||
input_vector.PushBackInterleaved(
|
||||
rtc::ArrayView<const int16_t>(input, input_length));
|
||||
size_t input_length_per_channel = input_vector.Size();
|
||||
assert(input_length_per_channel == input_length / num_channels_);
|
||||
RTC_DCHECK_EQ(input_length_per_channel, input_length / num_channels_);
|
||||
|
||||
size_t best_correlation_index = 0;
|
||||
size_t output_length = 0;
|
||||
@ -142,10 +142,10 @@ size_t Merge::Process(int16_t* input,
|
||||
|
||||
output_length = best_correlation_index + input_length_per_channel;
|
||||
if (channel == 0) {
|
||||
assert(output->Empty()); // Output should be empty at this point.
|
||||
RTC_DCHECK(output->Empty()); // Output should be empty at this point.
|
||||
output->AssertSize(output_length);
|
||||
} else {
|
||||
assert(output->Size() == output_length);
|
||||
RTC_DCHECK_EQ(output->Size(), output_length);
|
||||
}
|
||||
(*output)[channel].OverwriteAt(temp_data_.data(), output_length, 0);
|
||||
}
|
||||
@ -165,7 +165,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// Check how much data that is left since earlier.
|
||||
*old_length = sync_buffer_->FutureLength();
|
||||
// Should never be less than overlap_length.
|
||||
assert(*old_length >= expand_->overlap_length());
|
||||
RTC_DCHECK_GE(*old_length, expand_->overlap_length());
|
||||
// Generate data to merge the overlap with using expand.
|
||||
expand_->SetParametersForMergeAfterExpand();
|
||||
|
||||
@ -182,7 +182,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// This is the truncated length.
|
||||
}
|
||||
// This assert should always be true thanks to the if statement above.
|
||||
assert(210 * kMaxSampleRate / 8000 >= *old_length);
|
||||
RTC_DCHECK_GE(210 * kMaxSampleRate / 8000, *old_length);
|
||||
|
||||
AudioMultiVector expanded_temp(num_channels_);
|
||||
expand_->Process(&expanded_temp);
|
||||
@ -191,8 +191,8 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
expanded_.Clear();
|
||||
// Copy what is left since earlier into the expanded vector.
|
||||
expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index());
|
||||
assert(expanded_.Size() == *old_length);
|
||||
assert(expanded_temp.Size() > 0);
|
||||
RTC_DCHECK_EQ(expanded_.Size(), *old_length);
|
||||
RTC_DCHECK_GT(expanded_temp.Size(), 0);
|
||||
// Do "ugly" copy and paste from the expanded in order to generate more data
|
||||
// to correlate (but not interpolate) with.
|
||||
const size_t required_length = static_cast<size_t>((120 + 80 + 2) * fs_mult_);
|
||||
@ -204,7 +204,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// Trim the length to exactly |required_length|.
|
||||
expanded_.PopBack(expanded_.Size() - required_length);
|
||||
}
|
||||
assert(expanded_.Size() >= required_length);
|
||||
RTC_DCHECK_GE(expanded_.Size(), required_length);
|
||||
return required_length;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ size_t Merge::CorrelateAndPeakSearch(size_t start_position,
|
||||
while (((best_correlation_index + input_length) <
|
||||
(timestamps_per_call_ + expand_->overlap_length())) ||
|
||||
((best_correlation_index + input_length) < start_position)) {
|
||||
assert(false); // Should never happen.
|
||||
RTC_NOTREACHED(); // Should never happen.
|
||||
best_correlation_index += expand_period; // Jump one lag ahead.
|
||||
}
|
||||
return best_correlation_index;
|
||||
|
||||
@ -44,7 +44,7 @@ NackTracker* NackTracker::Create(int nack_threshold_packets) {
|
||||
}
|
||||
|
||||
void NackTracker::UpdateSampleRate(int sample_rate_hz) {
|
||||
assert(sample_rate_hz > 0);
|
||||
RTC_DCHECK_GT(sample_rate_hz, 0);
|
||||
sample_rate_khz_ = sample_rate_hz / 1000;
|
||||
}
|
||||
|
||||
@ -120,9 +120,9 @@ uint32_t NackTracker::EstimateTimestamp(uint16_t sequence_num) {
|
||||
}
|
||||
|
||||
void NackTracker::AddToList(uint16_t sequence_number_current_received_rtp) {
|
||||
assert(!any_rtp_decoded_ ||
|
||||
IsNewerSequenceNumber(sequence_number_current_received_rtp,
|
||||
sequence_num_last_decoded_rtp_));
|
||||
RTC_DCHECK(!any_rtp_decoded_ ||
|
||||
IsNewerSequenceNumber(sequence_number_current_received_rtp,
|
||||
sequence_num_last_decoded_rtp_));
|
||||
|
||||
// Packets with sequence numbers older than |upper_bound_missing| are
|
||||
// considered missing, and the rest are considered late.
|
||||
@ -164,7 +164,7 @@ void NackTracker::UpdateLastDecodedPacket(uint16_t sequence_number,
|
||||
++it)
|
||||
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
|
||||
} else {
|
||||
assert(sequence_number == sequence_num_last_decoded_rtp_);
|
||||
RTC_DCHECK_EQ(sequence_number, sequence_num_last_decoded_rtp_);
|
||||
|
||||
// Same sequence number as before. 10 ms is elapsed, update estimations for
|
||||
// time-to-play.
|
||||
|
||||
@ -343,7 +343,7 @@ void NetEqImpl::RemoveAllPayloadTypes() {
|
||||
bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (delay_ms >= 0 && delay_ms <= 10000) {
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
return controller_->SetMinimumDelay(
|
||||
std::max(delay_ms - output_delay_chain_ms_, 0));
|
||||
}
|
||||
@ -353,7 +353,7 @@ bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
bool NetEqImpl::SetMaximumDelay(int delay_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (delay_ms >= 0 && delay_ms <= 10000) {
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
return controller_->SetMaximumDelay(
|
||||
std::max(delay_ms - output_delay_chain_ms_, 0));
|
||||
}
|
||||
@ -392,7 +392,7 @@ int NetEqImpl::FilteredCurrentDelayMs() const {
|
||||
|
||||
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(decoder_database_.get());
|
||||
RTC_DCHECK(decoder_database_.get());
|
||||
*stats = CurrentNetworkStatisticsInternal();
|
||||
stats_->GetNetworkStatistics(decoder_frame_length_, stats);
|
||||
// Compensate for output delay chain.
|
||||
@ -409,13 +409,13 @@ NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatistics() const {
|
||||
}
|
||||
|
||||
NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatisticsInternal() const {
|
||||
assert(decoder_database_.get());
|
||||
RTC_DCHECK(decoder_database_.get());
|
||||
NetEqNetworkStatistics stats;
|
||||
const size_t total_samples_in_buffers =
|
||||
packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) +
|
||||
sync_buffer_->FutureLength();
|
||||
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
stats.preferred_buffer_size_ms = controller_->TargetLevelMs();
|
||||
stats.jitter_peaks_found = controller_->PeakFound();
|
||||
RTC_DCHECK_GT(fs_hz_, 0);
|
||||
@ -449,13 +449,13 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const {
|
||||
|
||||
void NetEqImpl::EnableVad() {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
vad_->Enable();
|
||||
}
|
||||
|
||||
void NetEqImpl::DisableVad() {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
vad_->Disable();
|
||||
}
|
||||
|
||||
@ -506,8 +506,8 @@ void NetEqImpl::FlushBuffers() {
|
||||
MutexLock lock(&mutex_);
|
||||
RTC_LOG(LS_VERBOSE) << "FlushBuffers";
|
||||
packet_buffer_->Flush(stats_.get());
|
||||
assert(sync_buffer_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
sync_buffer_->Flush();
|
||||
sync_buffer_->set_next_index(sync_buffer_->next_index() -
|
||||
expand_->overlap_length());
|
||||
@ -797,12 +797,12 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
|
||||
size_t channels = 1;
|
||||
if (!decoder_database_->IsComfortNoise(payload_type)) {
|
||||
AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type);
|
||||
assert(decoder); // Payloads are already checked to be valid.
|
||||
RTC_DCHECK(decoder); // Payloads are already checked to be valid.
|
||||
channels = decoder->Channels();
|
||||
}
|
||||
const DecoderDatabase::DecoderInfo* decoder_info =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
assert(decoder_info);
|
||||
RTC_DCHECK(decoder_info);
|
||||
if (decoder_info->SampleRateHz() != fs_hz_ ||
|
||||
channels != algorithm_buffer_->Channels()) {
|
||||
SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels);
|
||||
@ -816,7 +816,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
|
||||
|
||||
const DecoderDatabase::DecoderInfo* dec_info =
|
||||
decoder_database_->GetDecoderInfo(main_payload_type);
|
||||
assert(dec_info); // Already checked that the payload type is known.
|
||||
RTC_DCHECK(dec_info); // Already checked that the payload type is known.
|
||||
|
||||
NetEqController::PacketArrivedInfo info;
|
||||
info.is_cng_or_dtmf = dec_info->IsComfortNoise() || dec_info->IsDtmf();
|
||||
@ -894,7 +894,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
||||
int decode_return_value =
|
||||
Decode(&packet_list, &operation, &length, &speech_type);
|
||||
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
bool sid_frame_available =
|
||||
(operation == Operation::kRfc3389Cng && !packet_list.empty());
|
||||
vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type,
|
||||
@ -965,7 +965,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
||||
}
|
||||
case Operation::kUndefined: {
|
||||
RTC_LOG(LS_ERROR) << "Invalid operation kUndefined.";
|
||||
assert(false); // This should not happen.
|
||||
RTC_NOTREACHED(); // This should not happen.
|
||||
last_mode_ = Mode::kError;
|
||||
return kInvalidOperation;
|
||||
}
|
||||
@ -1101,7 +1101,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
*play_dtmf = false;
|
||||
*operation = Operation::kUndefined;
|
||||
|
||||
assert(sync_buffer_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
uint32_t end_timestamp = sync_buffer_->end_timestamp();
|
||||
if (!new_codec_) {
|
||||
const uint32_t five_seconds_samples = 5 * fs_hz_;
|
||||
@ -1128,7 +1128,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
// Don't use this packet, discard it.
|
||||
if (packet_buffer_->DiscardNextPacket(stats_.get()) !=
|
||||
PacketBuffer::kOK) {
|
||||
assert(false); // Must be ok by design.
|
||||
RTC_NOTREACHED(); // Must be ok by design.
|
||||
}
|
||||
// Check buffer again.
|
||||
if (!new_codec_) {
|
||||
@ -1139,7 +1139,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
}
|
||||
}
|
||||
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
const int samples_left = static_cast<int>(sync_buffer_->FutureLength() -
|
||||
expand_->overlap_length());
|
||||
if (last_mode_ == Mode::kAccelerateSuccess ||
|
||||
@ -1159,8 +1159,8 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
}
|
||||
|
||||
// Get instruction.
|
||||
assert(sync_buffer_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
generated_noise_samples =
|
||||
generated_noise_stopwatch_
|
||||
? generated_noise_stopwatch_->ElapsedTicks() * output_size_samples_ +
|
||||
@ -1228,7 +1228,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
// Check conditions for reset.
|
||||
if (new_codec_ || *operation == Operation::kUndefined) {
|
||||
// The only valid reason to get kUndefined is that new_codec_ is set.
|
||||
assert(new_codec_);
|
||||
RTC_DCHECK(new_codec_);
|
||||
if (*play_dtmf && !packet) {
|
||||
timestamp_ = dtmf_event->timestamp;
|
||||
} else {
|
||||
@ -1400,7 +1400,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
uint8_t payload_type = packet.payload_type;
|
||||
if (!decoder_database_->IsComfortNoise(payload_type)) {
|
||||
decoder = decoder_database_->GetDecoder(payload_type);
|
||||
assert(decoder);
|
||||
RTC_DCHECK(decoder);
|
||||
if (!decoder) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Unknown payload type " << static_cast<int>(payload_type);
|
||||
@ -1413,7 +1413,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
// We have a new decoder. Re-init some values.
|
||||
const DecoderDatabase::DecoderInfo* decoder_info =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
assert(decoder_info);
|
||||
RTC_DCHECK(decoder_info);
|
||||
if (!decoder_info) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Unknown payload type " << static_cast<int>(payload_type);
|
||||
@ -1485,8 +1485,8 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
// Don't increment timestamp if codec returned CNG speech type
|
||||
// since in this case, the we will increment the CNGplayedTS counter.
|
||||
// Increase with number of samples per channel.
|
||||
assert(*decoded_length == 0 ||
|
||||
(decoder && decoder->Channels() == sync_buffer_->Channels()));
|
||||
RTC_DCHECK(*decoded_length == 0 ||
|
||||
(decoder && decoder->Channels() == sync_buffer_->Channels()));
|
||||
sync_buffer_->IncreaseEndTimestamp(
|
||||
*decoded_length / static_cast<int>(sync_buffer_->Channels()));
|
||||
}
|
||||
@ -1535,16 +1535,16 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
|
||||
// Do decoding.
|
||||
while (!packet_list->empty() && !decoder_database_->IsComfortNoise(
|
||||
packet_list->front().payload_type)) {
|
||||
assert(decoder); // At this point, we must have a decoder object.
|
||||
RTC_DCHECK(decoder); // At this point, we must have a decoder object.
|
||||
// The number of channels in the |sync_buffer_| should be the same as the
|
||||
// number decoder channels.
|
||||
assert(sync_buffer_->Channels() == decoder->Channels());
|
||||
assert(decoded_buffer_length_ >= kMaxFrameSize * decoder->Channels());
|
||||
assert(operation == Operation::kNormal ||
|
||||
operation == Operation::kAccelerate ||
|
||||
operation == Operation::kFastAccelerate ||
|
||||
operation == Operation::kMerge ||
|
||||
operation == Operation::kPreemptiveExpand);
|
||||
RTC_DCHECK_EQ(sync_buffer_->Channels(), decoder->Channels());
|
||||
RTC_DCHECK_GE(decoded_buffer_length_, kMaxFrameSize * decoder->Channels());
|
||||
RTC_DCHECK(operation == Operation::kNormal ||
|
||||
operation == Operation::kAccelerate ||
|
||||
operation == Operation::kFastAccelerate ||
|
||||
operation == Operation::kMerge ||
|
||||
operation == Operation::kPreemptiveExpand);
|
||||
|
||||
auto opt_result = packet_list->front().frame->Decode(
|
||||
rtc::ArrayView<int16_t>(&decoded_buffer_[*decoded_length],
|
||||
@ -1581,9 +1581,10 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
|
||||
|
||||
// If the list is not empty at this point, either a decoding error terminated
|
||||
// the while-loop, or list must hold exactly one CNG packet.
|
||||
assert(packet_list->empty() || *decoded_length < 0 ||
|
||||
(packet_list->size() == 1 && decoder_database_->IsComfortNoise(
|
||||
packet_list->front().payload_type)));
|
||||
RTC_DCHECK(
|
||||
packet_list->empty() || *decoded_length < 0 ||
|
||||
(packet_list->size() == 1 &&
|
||||
decoder_database_->IsComfortNoise(packet_list->front().payload_type)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1591,7 +1592,7 @@ void NetEqImpl::DoNormal(const int16_t* decoded_buffer,
|
||||
size_t decoded_length,
|
||||
AudioDecoder::SpeechType speech_type,
|
||||
bool play_dtmf) {
|
||||
assert(normal_.get());
|
||||
RTC_DCHECK(normal_.get());
|
||||
normal_->Process(decoded_buffer, decoded_length, last_mode_,
|
||||
algorithm_buffer_.get());
|
||||
if (decoded_length != 0) {
|
||||
@ -1614,7 +1615,7 @@ void NetEqImpl::DoMerge(int16_t* decoded_buffer,
|
||||
size_t decoded_length,
|
||||
AudioDecoder::SpeechType speech_type,
|
||||
bool play_dtmf) {
|
||||
assert(merge_.get());
|
||||
RTC_DCHECK(merge_.get());
|
||||
size_t new_length =
|
||||
merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get());
|
||||
// Correction can be negative.
|
||||
@ -1775,7 +1776,7 @@ int NetEqImpl::DoAccelerate(int16_t* decoded_buffer,
|
||||
sync_buffer_->Size() - borrowed_samples_per_channel);
|
||||
sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length);
|
||||
algorithm_buffer_->PopFront(length);
|
||||
assert(algorithm_buffer_->Empty());
|
||||
RTC_DCHECK(algorithm_buffer_->Empty());
|
||||
} else {
|
||||
sync_buffer_->ReplaceAtIndex(
|
||||
*algorithm_buffer_, borrowed_samples_per_channel,
|
||||
@ -1864,7 +1865,7 @@ int NetEqImpl::DoPreemptiveExpand(int16_t* decoded_buffer,
|
||||
int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) {
|
||||
if (!packet_list->empty()) {
|
||||
// Must have exactly one SID frame at this point.
|
||||
assert(packet_list->size() == 1);
|
||||
RTC_DCHECK_EQ(packet_list->size(), 1);
|
||||
const Packet& packet = packet_list->front();
|
||||
if (!decoder_database_->IsComfortNoise(packet.payload_type)) {
|
||||
RTC_LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG.";
|
||||
@ -1947,14 +1948,14 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
|
||||
// // it must be copied to the speech buffer.
|
||||
// // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and
|
||||
// // verify correct operation.
|
||||
// assert(false);
|
||||
// RTC_NOTREACHED();
|
||||
// // Must generate enough data to replace all of the |sync_buffer_|
|
||||
// // "future".
|
||||
// int required_length = sync_buffer_->FutureLength();
|
||||
// assert(dtmf_tone_generator_->initialized());
|
||||
// RTC_DCHECK(dtmf_tone_generator_->initialized());
|
||||
// dtmf_return_value = dtmf_tone_generator_->Generate(required_length,
|
||||
// algorithm_buffer_);
|
||||
// assert((size_t) required_length == algorithm_buffer_->Size());
|
||||
// RTC_DCHECK((size_t) required_length == algorithm_buffer_->Size());
|
||||
// if (dtmf_return_value < 0) {
|
||||
// algorithm_buffer_->Zeros(output_size_samples_);
|
||||
// return dtmf_return_value;
|
||||
@ -1964,7 +1965,7 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
|
||||
// // data.
|
||||
// // TODO(hlundin): It seems that this overwriting has gone lost.
|
||||
// // Not adapted for multi-channel yet.
|
||||
// assert(algorithm_buffer_->Channels() == 1);
|
||||
// RTC_DCHECK(algorithm_buffer_->Channels() == 1);
|
||||
// if (algorithm_buffer_->Channels() != 1) {
|
||||
// RTC_LOG(LS_WARNING) << "DTMF not supported for more than one channel";
|
||||
// return kStereoNotSupported;
|
||||
@ -2006,7 +2007,7 @@ int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event,
|
||||
if (dtmf_return_value == 0) {
|
||||
dtmf_return_value =
|
||||
dtmf_tone_generator_->Generate(overdub_length, &dtmf_output);
|
||||
assert(overdub_length == dtmf_output.Size());
|
||||
RTC_DCHECK_EQ(overdub_length, dtmf_output.Size());
|
||||
}
|
||||
dtmf_output.ReadInterleaved(overdub_length, &output[out_index]);
|
||||
return dtmf_return_value < 0 ? dtmf_return_value : 0;
|
||||
@ -2037,7 +2038,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
|
||||
next_packet = nullptr;
|
||||
if (!packet) {
|
||||
RTC_LOG(LS_ERROR) << "Should always be able to extract a packet here";
|
||||
assert(false); // Should always be able to extract a packet here.
|
||||
RTC_NOTREACHED(); // Should always be able to extract a packet here.
|
||||
return -1;
|
||||
}
|
||||
const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs();
|
||||
@ -2130,8 +2131,9 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " "
|
||||
<< channels;
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
|
||||
fs_hz == 48000);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
|
||||
// Before changing the sample rate, end and report any ongoing expand event.
|
||||
stats_->EndExpandEvent(fs_hz_);
|
||||
@ -2147,7 +2149,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
cng_decoder->Reset();
|
||||
|
||||
// Reinit post-decode VAD with new sample rate.
|
||||
assert(vad_.get()); // Cannot be NULL here.
|
||||
RTC_DCHECK(vad_.get()); // Cannot be NULL here.
|
||||
vad_->Init();
|
||||
|
||||
// Delete algorithm buffer and create a new one.
|
||||
@ -2190,8 +2192,8 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
}
|
||||
|
||||
NetEqImpl::OutputType NetEqImpl::LastOutputType() {
|
||||
assert(vad_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
if (last_mode_ == Mode::kCodecInternalCng ||
|
||||
last_mode_ == Mode::kRfc3389Cng) {
|
||||
return OutputType::kCNG;
|
||||
|
||||
@ -41,7 +41,7 @@ bool RedPayloadSplitter::SplitRed(PacketList* packet_list) {
|
||||
PacketList::iterator it = packet_list->begin();
|
||||
while (it != packet_list->end()) {
|
||||
const Packet& red_packet = *it;
|
||||
assert(!red_packet.payload.empty());
|
||||
RTC_DCHECK(!red_packet.payload.empty());
|
||||
const uint8_t* payload_ptr = red_packet.payload.data();
|
||||
size_t payload_length = red_packet.payload.size();
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ Packet CreateRedPayload(size_t num_payloads,
|
||||
rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset);
|
||||
*payload_ptr = this_offset >> 6;
|
||||
++payload_ptr;
|
||||
assert(kPayloadLength <= 1023); // Max length described by 10 bits.
|
||||
RTC_DCHECK_LE(kPayloadLength, 1023); // Max length described by 10 bits.
|
||||
*payload_ptr = ((this_offset & 0x3F) << 2) | (kPayloadLength >> 8);
|
||||
++payload_ptr;
|
||||
*payload_ptr = kPayloadLength & 0xFF;
|
||||
|
||||
@ -375,7 +375,7 @@ uint16_t StatisticsCalculator::CalculateQ14Ratio(size_t numerator,
|
||||
return 0;
|
||||
} else if (numerator < denominator) {
|
||||
// Ratio must be smaller than 1 in Q14.
|
||||
assert((numerator << 14) / denominator < (1 << 14));
|
||||
RTC_DCHECK_LT((numerator << 14) / denominator, (1 << 14));
|
||||
return static_cast<uint16_t>((numerator << 14) / denominator);
|
||||
} else {
|
||||
// Will not produce a ratio larger than 1, since this is probably an error.
|
||||
|
||||
@ -28,7 +28,7 @@ void SyncBuffer::PushBack(const AudioMultiVector& append_this) {
|
||||
next_index_ -= samples_added;
|
||||
} else {
|
||||
// This means that we are pushing out future data that was never used.
|
||||
// assert(false);
|
||||
// RTC_NOTREACHED();
|
||||
// TODO(hlundin): This assert must be disabled to support 60 ms frames.
|
||||
// This should not happen even for 60 ms frames, but it does. Investigate
|
||||
// why.
|
||||
|
||||
@ -66,7 +66,7 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
|
||||
DspHelper::PeakDetection(auto_correlation_, kCorrelationLen, kNumPeaks,
|
||||
fs_mult_, &peak_index, &peak_value);
|
||||
// Assert that |peak_index| stays within boundaries.
|
||||
assert(peak_index <= (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
RTC_DCHECK_LE(peak_index, (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
|
||||
// Compensate peak_index for displaced starting position. The displacement
|
||||
// happens in AutoCorrelation(). Here, |kMinLag| is in the down-sampled 4 kHz
|
||||
@ -74,8 +74,9 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
|
||||
// multiplication by fs_mult_ * 2.
|
||||
peak_index += kMinLag * fs_mult_ * 2;
|
||||
// Assert that |peak_index| stays within boundaries.
|
||||
assert(peak_index >= static_cast<size_t>(20 * fs_mult_));
|
||||
assert(peak_index <= 20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
RTC_DCHECK_GE(peak_index, static_cast<size_t>(20 * fs_mult_));
|
||||
RTC_DCHECK_LE(peak_index,
|
||||
20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
|
||||
// Calculate scaling to ensure that |peak_index| samples can be square-summed
|
||||
// without overflowing.
|
||||
|
||||
@ -42,9 +42,9 @@ class TimeStretch {
|
||||
num_channels_(num_channels),
|
||||
background_noise_(background_noise),
|
||||
max_input_value_(0) {
|
||||
assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
|
||||
sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
|
||||
sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
memset(auto_correlation_, 0, sizeof(auto_correlation_));
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class OutputAudioFile : public AudioSink {
|
||||
}
|
||||
|
||||
bool WriteArray(const int16_t* audio, size_t num_samples) override {
|
||||
assert(out_file_);
|
||||
RTC_DCHECK(out_file_);
|
||||
return fwrite(audio, sizeof(*audio), num_samples, out_file_) == num_samples;
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {
|
||||
printf("Input file: %s\n", args[1]);
|
||||
std::unique_ptr<webrtc::test::RtpFileSource> file_source(
|
||||
webrtc::test::RtpFileSource::Create(args[1]));
|
||||
assert(file_source.get());
|
||||
RTC_DCHECK(file_source.get());
|
||||
// Set RTP extension IDs.
|
||||
bool print_audio_level = false;
|
||||
if (absl::GetFlag(FLAGS_audio_level) != -1) {
|
||||
@ -151,7 +151,7 @@ int main(int argc, char* argv[]) {
|
||||
packet->ExtractRedHeaders(&red_headers);
|
||||
while (!red_headers.empty()) {
|
||||
webrtc::RTPHeader* red = red_headers.front();
|
||||
assert(red);
|
||||
RTC_DCHECK(red);
|
||||
fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber,
|
||||
red->timestamp, static_cast<unsigned int>(packet->time_ms()),
|
||||
red->payloadType);
|
||||
|
||||
@ -18,7 +18,7 @@ namespace test {
|
||||
uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
|
||||
size_t payload_length_samples,
|
||||
RTPHeader* rtp_header) {
|
||||
assert(rtp_header);
|
||||
RTC_DCHECK(rtp_header);
|
||||
if (!rtp_header) {
|
||||
return 0;
|
||||
}
|
||||
@ -31,7 +31,7 @@ uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
|
||||
rtp_header->numCSRCs = 0;
|
||||
|
||||
uint32_t this_send_time = next_send_time_ms_;
|
||||
assert(samples_per_ms_ > 0);
|
||||
RTC_DCHECK_GT(samples_per_ms_, 0);
|
||||
next_send_time_ms_ +=
|
||||
((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_;
|
||||
return this_send_time;
|
||||
|
||||
@ -125,7 +125,7 @@ void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) {
|
||||
(uint32_t)((uint32_t)rtp_header.timestamp -
|
||||
(uint32_t)currentPayloadStr->lastTimestamp);
|
||||
}
|
||||
assert(_lastFrameSizeSample > 0);
|
||||
RTC_DCHECK_GT(_lastFrameSizeSample, 0);
|
||||
int k = 0;
|
||||
for (; k < MAX_NUM_FRAMESIZES; ++k) {
|
||||
if ((currentPayloadStr->frameSizeStats[k].frameSizeSample ==
|
||||
|
||||
@ -1490,7 +1490,7 @@ bool AudioDeviceLinuxALSA::PlayThreadProcess() {
|
||||
Lock();
|
||||
|
||||
_playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer);
|
||||
assert(_playoutFramesLeft == _playoutFramesIn10MS);
|
||||
RTC_DCHECK_EQ(_playoutFramesLeft, _playoutFramesIn10MS);
|
||||
}
|
||||
|
||||
if (static_cast<uint32_t>(avail_frames) > _playoutFramesLeft)
|
||||
@ -1509,7 +1509,7 @@ bool AudioDeviceLinuxALSA::PlayThreadProcess() {
|
||||
UnLock();
|
||||
return true;
|
||||
} else {
|
||||
assert(frames == avail_frames);
|
||||
RTC_DCHECK_EQ(frames, avail_frames);
|
||||
_playoutFramesLeft -= frames;
|
||||
}
|
||||
|
||||
@ -1559,7 +1559,7 @@ bool AudioDeviceLinuxALSA::RecThreadProcess() {
|
||||
UnLock();
|
||||
return true;
|
||||
} else if (frames > 0) {
|
||||
assert(frames == avail_frames);
|
||||
RTC_DCHECK_EQ(frames, avail_frames);
|
||||
|
||||
int left_size =
|
||||
LATE(snd_pcm_frames_to_bytes)(_handleRecord, _recordingFramesLeft);
|
||||
|
||||
@ -11,10 +11,10 @@
|
||||
#ifndef AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
|
||||
#define AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h> // for NULL
|
||||
#include <string.h>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
|
||||
// This file provides macros for creating "symbol table" classes to simplify the
|
||||
@ -59,7 +59,7 @@ class LateBindingSymbolTable {
|
||||
|
||||
// We do not use this, but we offer it for theoretical convenience.
|
||||
static const char* GetSymbolName(int index) {
|
||||
assert(index < NumSymbols());
|
||||
RTC_DCHECK_LT(index, NumSymbols());
|
||||
return kSymbolNames[index];
|
||||
}
|
||||
|
||||
@ -100,8 +100,8 @@ class LateBindingSymbolTable {
|
||||
// Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below
|
||||
// instead of this.
|
||||
void* GetSymbol(int index) const {
|
||||
assert(IsLoaded());
|
||||
assert(index < NumSymbols());
|
||||
RTC_DCHECK(IsLoaded());
|
||||
RTC_DCHECK_LT(index, NumSymbols());
|
||||
return symbols_[index];
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +225,7 @@ int32_t AudioMixerManagerMac::SetSpeakerVolume(uint32_t volume) {
|
||||
// volume range is 0.0 - 1.0, convert from 0 -255
|
||||
const Float32 vol = (Float32)(volume / 255.0);
|
||||
|
||||
assert(vol <= 1.0 && vol >= 0.0);
|
||||
RTC_DCHECK(vol <= 1.0 && vol >= 0.0);
|
||||
|
||||
// Does the capture device have a master volume control?
|
||||
// If so, use it exclusively.
|
||||
@ -311,7 +311,7 @@ int32_t AudioMixerManagerMac::SpeakerVolume(uint32_t& volume) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
// vol 0.0 to 1.0 -> convert to 0 - 255
|
||||
volume = static_cast<uint32_t>(255 * vol / channels + 0.5);
|
||||
}
|
||||
@ -522,7 +522,7 @@ int32_t AudioMixerManagerMac::SpeakerMute(bool& enabled) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
// 1 means muted
|
||||
enabled = static_cast<bool>(muted);
|
||||
}
|
||||
@ -690,7 +690,7 @@ int32_t AudioMixerManagerMac::MicrophoneMute(bool& enabled) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
// 1 means muted
|
||||
enabled = static_cast<bool>(muted);
|
||||
}
|
||||
@ -757,7 +757,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneVolume(uint32_t volume) {
|
||||
// volume range is 0.0 - 1.0, convert from 0 - 255
|
||||
const Float32 vol = (Float32)(volume / 255.0);
|
||||
|
||||
assert(vol <= 1.0 && vol >= 0.0);
|
||||
RTC_DCHECK(vol <= 1.0 && vol >= 0.0);
|
||||
|
||||
// Does the capture device have a master volume control?
|
||||
// If so, use it exclusively.
|
||||
@ -843,7 +843,7 @@ int32_t AudioMixerManagerMac::MicrophoneVolume(uint32_t& volume) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
// vol 0.0 to 1.0 -> convert to 0 - 255
|
||||
volume = static_cast<uint32_t>(255 * volFloat32 / channels + 0.5);
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() {
|
||||
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
|
||||
MAXERRORLENGTH, NULL);
|
||||
|
||||
assert(messageLength <= MAXERRORLENGTH);
|
||||
RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
|
||||
|
||||
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
|
||||
for (; messageLength && ::isspace(errorText[messageLength - 1]);
|
||||
@ -469,7 +469,7 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore()
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
|
||||
__uuidof(IMMDeviceEnumerator),
|
||||
reinterpret_cast<void**>(&_ptrEnumerator));
|
||||
assert(NULL != _ptrEnumerator);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
// DMO initialization for built-in WASAPI AEC.
|
||||
{
|
||||
@ -1411,7 +1411,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(uint16_t index) {
|
||||
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrRenderCollection != NULL);
|
||||
RTC_DCHECK(_ptrRenderCollection);
|
||||
|
||||
// Select an endpoint rendering device given the specified index
|
||||
SAFE_RELEASE(_ptrDeviceOut);
|
||||
@ -1461,7 +1461,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(
|
||||
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
// Select an endpoint rendering device given the specified role
|
||||
SAFE_RELEASE(_ptrDeviceOut);
|
||||
@ -1677,7 +1677,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(uint16_t index) {
|
||||
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrCaptureCollection != NULL);
|
||||
RTC_DCHECK(_ptrCaptureCollection);
|
||||
|
||||
// Select an endpoint capture device given the specified index
|
||||
SAFE_RELEASE(_ptrDeviceIn);
|
||||
@ -1727,7 +1727,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(
|
||||
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
// Select an endpoint capture device given the specified role
|
||||
SAFE_RELEASE(_ptrDeviceIn);
|
||||
@ -2036,8 +2036,8 @@ Exit:
|
||||
// handles device initialization itself.
|
||||
// Reference: http://msdn.microsoft.com/en-us/library/ff819492(v=vs.85).aspx
|
||||
int32_t AudioDeviceWindowsCore::InitRecordingDMO() {
|
||||
assert(_builtInAecEnabled);
|
||||
assert(_dmo != NULL);
|
||||
RTC_DCHECK(_builtInAecEnabled);
|
||||
RTC_DCHECK(_dmo);
|
||||
|
||||
if (SetDMOProperties() == -1) {
|
||||
return -1;
|
||||
@ -2356,7 +2356,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() {
|
||||
}
|
||||
}
|
||||
|
||||
assert(_hRecThread == NULL);
|
||||
RTC_DCHECK(_hRecThread);
|
||||
_hRecThread = CreateThread(NULL, 0, lpStartAddress, this, 0, NULL);
|
||||
if (_hRecThread == NULL) {
|
||||
RTC_LOG(LS_ERROR) << "failed to create the recording thread";
|
||||
@ -2421,8 +2421,8 @@ int32_t AudioDeviceWindowsCore::StopRecording() {
|
||||
|
||||
ResetEvent(_hShutdownCaptureEvent); // Must be manually reset.
|
||||
// Ensure that the thread has released these interfaces properly.
|
||||
assert(err == -1 || _ptrClientIn == NULL);
|
||||
assert(err == -1 || _ptrCaptureClient == NULL);
|
||||
RTC_DCHECK(err == -1 || _ptrClientIn == NULL);
|
||||
RTC_DCHECK(err == -1 || _ptrCaptureClient == NULL);
|
||||
|
||||
_recIsInitialized = false;
|
||||
_recording = false;
|
||||
@ -2433,7 +2433,7 @@ int32_t AudioDeviceWindowsCore::StopRecording() {
|
||||
_hRecThread = NULL;
|
||||
|
||||
if (_builtInAecEnabled) {
|
||||
assert(_dmo != NULL);
|
||||
RTC_DCHECK(_dmo);
|
||||
// This is necessary. Otherwise the DMO can generate garbage render
|
||||
// audio even after rendering has stopped.
|
||||
HRESULT hr = _dmo->FreeStreamingResources();
|
||||
@ -2493,7 +2493,7 @@ int32_t AudioDeviceWindowsCore::StartPlayout() {
|
||||
MutexLock lockScoped(&mutex_);
|
||||
|
||||
// Create thread which will drive the rendering.
|
||||
assert(_hPlayThread == NULL);
|
||||
RTC_DCHECK(_hPlayThread);
|
||||
_hPlayThread = CreateThread(NULL, 0, WSAPIRenderThread, this, 0, NULL);
|
||||
if (_hPlayThread == NULL) {
|
||||
RTC_LOG(LS_ERROR) << "failed to create the playout thread";
|
||||
@ -2954,7 +2954,7 @@ void AudioDeviceWindowsCore::RevertCaptureThreadPriority() {
|
||||
}
|
||||
|
||||
DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
|
||||
assert(_mediaBuffer != NULL);
|
||||
RTC_DCHECK(_mediaBuffer);
|
||||
bool keepRecording = true;
|
||||
|
||||
// Initialize COM as MTA in this thread.
|
||||
@ -3010,7 +3010,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
|
||||
if (FAILED(hr)) {
|
||||
_TraceCOMError(hr);
|
||||
keepRecording = false;
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3022,7 +3022,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
|
||||
if (FAILED(hr)) {
|
||||
_TraceCOMError(hr);
|
||||
keepRecording = false;
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3031,8 +3031,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
|
||||
// TODO(andrew): verify that this is always satisfied. It might
|
||||
// be that ProcessOutput will try to return more than 10 ms if
|
||||
// we fail to call it frequently enough.
|
||||
assert(kSamplesProduced == static_cast<int>(_recBlockSize));
|
||||
assert(sizeof(BYTE) == sizeof(int8_t));
|
||||
RTC_DCHECK_EQ(kSamplesProduced, static_cast<int>(_recBlockSize));
|
||||
RTC_DCHECK_EQ(sizeof(BYTE), sizeof(int8_t));
|
||||
_ptrAudioBuffer->SetRecordedBuffer(reinterpret_cast<int8_t*>(data),
|
||||
kSamplesProduced);
|
||||
_ptrAudioBuffer->SetVQEData(0, 0);
|
||||
@ -3047,7 +3047,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() {
|
||||
if (FAILED(hr)) {
|
||||
_TraceCOMError(hr);
|
||||
keepRecording = false;
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3228,7 +3228,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() {
|
||||
pData = NULL;
|
||||
}
|
||||
|
||||
assert(framesAvailable != 0);
|
||||
RTC_DCHECK_NE(framesAvailable, 0);
|
||||
|
||||
if (pData) {
|
||||
CopyMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize], pData,
|
||||
@ -3237,8 +3237,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() {
|
||||
ZeroMemory(&syncBuffer[syncBufIndex * _recAudioFrameSize],
|
||||
framesAvailable * _recAudioFrameSize);
|
||||
}
|
||||
assert(syncBufferSize >= (syncBufIndex * _recAudioFrameSize) +
|
||||
framesAvailable * _recAudioFrameSize);
|
||||
RTC_DCHECK_GE(syncBufferSize, (syncBufIndex * _recAudioFrameSize) +
|
||||
framesAvailable * _recAudioFrameSize);
|
||||
|
||||
// Release the capture buffer
|
||||
//
|
||||
@ -3377,7 +3377,7 @@ void AudioDeviceWindowsCore::_UnLock() RTC_NO_THREAD_SAFETY_ANALYSIS {
|
||||
|
||||
int AudioDeviceWindowsCore::SetDMOProperties() {
|
||||
HRESULT hr = S_OK;
|
||||
assert(_dmo != NULL);
|
||||
RTC_DCHECK(_dmo);
|
||||
|
||||
rtc::scoped_refptr<IPropertyStore> ps;
|
||||
{
|
||||
@ -3517,8 +3517,8 @@ int32_t AudioDeviceWindowsCore::_RefreshDeviceList(EDataFlow dir) {
|
||||
HRESULT hr = S_OK;
|
||||
IMMDeviceCollection* pCollection = NULL;
|
||||
|
||||
assert(dir == eRender || dir == eCapture);
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(dir == eRender || dir == eCapture);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
// Create a fresh list of devices using the specified direction
|
||||
hr = _ptrEnumerator->EnumAudioEndpoints(dir, DEVICE_STATE_ACTIVE,
|
||||
@ -3553,7 +3553,7 @@ int16_t AudioDeviceWindowsCore::_DeviceListCount(EDataFlow dir) {
|
||||
HRESULT hr = S_OK;
|
||||
UINT count = 0;
|
||||
|
||||
assert(eRender == dir || eCapture == dir);
|
||||
RTC_DCHECK(eRender == dir || eCapture == dir);
|
||||
|
||||
if (eRender == dir && NULL != _ptrRenderCollection) {
|
||||
hr = _ptrRenderCollection->GetCount(&count);
|
||||
@ -3589,7 +3589,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceName(EDataFlow dir,
|
||||
HRESULT hr = S_OK;
|
||||
IMMDevice* pDevice = NULL;
|
||||
|
||||
assert(dir == eRender || dir == eCapture);
|
||||
RTC_DCHECK(dir == eRender || dir == eCapture);
|
||||
|
||||
if (eRender == dir && NULL != _ptrRenderCollection) {
|
||||
hr = _ptrRenderCollection->Item(index, &pDevice);
|
||||
@ -3626,9 +3626,9 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceName(EDataFlow dir,
|
||||
HRESULT hr = S_OK;
|
||||
IMMDevice* pDevice = NULL;
|
||||
|
||||
assert(dir == eRender || dir == eCapture);
|
||||
assert(role == eConsole || role == eCommunications);
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(dir == eRender || dir == eCapture);
|
||||
RTC_DCHECK(role == eConsole || role == eCommunications);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
|
||||
|
||||
@ -3663,7 +3663,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceID(EDataFlow dir,
|
||||
HRESULT hr = S_OK;
|
||||
IMMDevice* pDevice = NULL;
|
||||
|
||||
assert(dir == eRender || dir == eCapture);
|
||||
RTC_DCHECK(dir == eRender || dir == eCapture);
|
||||
|
||||
if (eRender == dir && NULL != _ptrRenderCollection) {
|
||||
hr = _ptrRenderCollection->Item(index, &pDevice);
|
||||
@ -3700,9 +3700,9 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceID(EDataFlow dir,
|
||||
HRESULT hr = S_OK;
|
||||
IMMDevice* pDevice = NULL;
|
||||
|
||||
assert(dir == eRender || dir == eCapture);
|
||||
assert(role == eConsole || role == eCommunications);
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(dir == eRender || dir == eCapture);
|
||||
RTC_DCHECK(role == eConsole || role == eCommunications);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, &pDevice);
|
||||
|
||||
@ -3727,8 +3727,8 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir,
|
||||
WCHAR szDeviceID[MAX_PATH] = {0};
|
||||
|
||||
const size_t kDeviceIDLength = sizeof(szDeviceID) / sizeof(szDeviceID[0]);
|
||||
assert(kDeviceIDLength ==
|
||||
sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0]));
|
||||
RTC_DCHECK_EQ(kDeviceIDLength,
|
||||
sizeof(szDefaultDeviceID) / sizeof(szDefaultDeviceID[0]));
|
||||
|
||||
if (_GetDefaultDeviceID(dir, role, szDefaultDeviceID, kDeviceIDLength) ==
|
||||
-1) {
|
||||
@ -3801,8 +3801,8 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice,
|
||||
IPropertyStore* pProps = NULL;
|
||||
PROPVARIANT varName;
|
||||
|
||||
assert(pszBuffer != NULL);
|
||||
assert(bufferLen > 0);
|
||||
RTC_DCHECK(pszBuffer);
|
||||
RTC_DCHECK_GT(bufferLen, 0);
|
||||
|
||||
if (pDevice != NULL) {
|
||||
hr = pDevice->OpenPropertyStore(STGM_READ, &pProps);
|
||||
@ -3867,8 +3867,8 @@ int32_t AudioDeviceWindowsCore::_GetDeviceID(IMMDevice* pDevice,
|
||||
HRESULT hr = E_FAIL;
|
||||
LPWSTR pwszID = NULL;
|
||||
|
||||
assert(pszBuffer != NULL);
|
||||
assert(bufferLen > 0);
|
||||
RTC_DCHECK(pszBuffer);
|
||||
RTC_DCHECK_GT(bufferLen, 0);
|
||||
|
||||
if (pDevice != NULL) {
|
||||
hr = pDevice->GetId(&pwszID);
|
||||
@ -3897,7 +3897,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDevice(EDataFlow dir,
|
||||
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
hr = _ptrEnumerator->GetDefaultAudioEndpoint(dir, role, ppDevice);
|
||||
if (FAILED(hr)) {
|
||||
@ -3917,7 +3917,7 @@ int32_t AudioDeviceWindowsCore::_GetListDevice(EDataFlow dir,
|
||||
IMMDevice** ppDevice) {
|
||||
HRESULT hr(S_OK);
|
||||
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
IMMDeviceCollection* pCollection = NULL;
|
||||
|
||||
@ -3951,7 +3951,7 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(
|
||||
EDataFlow dataFlow) const {
|
||||
RTC_DLOG(LS_VERBOSE) << __FUNCTION__;
|
||||
|
||||
assert(_ptrEnumerator != NULL);
|
||||
RTC_DCHECK(_ptrEnumerator);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
IMMDeviceCollection* pCollection = NULL;
|
||||
@ -4143,7 +4143,7 @@ void AudioDeviceWindowsCore::_TraceCOMError(HRESULT hr) const {
|
||||
DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, errorText,
|
||||
MAXERRORLENGTH, NULL);
|
||||
|
||||
assert(messageLength <= MAXERRORLENGTH);
|
||||
RTC_DCHECK_LE(messageLength, MAXERRORLENGTH);
|
||||
|
||||
// Trims tailing white space (FormatMessage() leaves a trailing cr-lf.).
|
||||
for (; messageLength && ::isspace(errorText[messageLength - 1]);
|
||||
|
||||
@ -36,7 +36,7 @@ double GetIncreaseFactor(const LossBasedControlConfig& config, TimeDelta rtt) {
|
||||
}
|
||||
auto rtt_range = config.increase_high_rtt.Get() - config.increase_low_rtt;
|
||||
if (rtt_range <= TimeDelta::Zero()) {
|
||||
RTC_DCHECK(false); // Only on misconfiguration.
|
||||
RTC_NOTREACHED(); // Only on misconfiguration.
|
||||
return config.min_increase_factor;
|
||||
}
|
||||
auto rtt_offset = rtt - config.increase_low_rtt;
|
||||
@ -57,7 +57,7 @@ DataRate BitrateFromLoss(double loss,
|
||||
DataRate loss_bandwidth_balance,
|
||||
double exponent) {
|
||||
if (exponent <= 0) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return DataRate::Infinity();
|
||||
}
|
||||
if (loss < 1e-5)
|
||||
@ -69,7 +69,7 @@ double ExponentialUpdate(TimeDelta window, TimeDelta interval) {
|
||||
// Use the convention that exponential window length (which is really
|
||||
// infinite) is the time it takes to dampen to 1/e.
|
||||
if (window <= TimeDelta::Zero()) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return 1.0f;
|
||||
}
|
||||
return 1.0f - exp(interval / window * -1.0);
|
||||
@ -134,7 +134,7 @@ void LossBasedBandwidthEstimation::UpdateLossStatistics(
|
||||
const std::vector<PacketResult>& packet_results,
|
||||
Timestamp at_time) {
|
||||
if (packet_results.empty()) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return;
|
||||
}
|
||||
int loss_count = 0;
|
||||
|
||||
@ -118,7 +118,7 @@ struct TopWindowVerifierContext : public SelectedWindowContext {
|
||||
// firing an assert when enabled, report that the selected window isn't
|
||||
// topmost to avoid inadvertent capture of other windows.
|
||||
RTC_LOG(LS_ERROR) << "Failed to enumerate windows: " << lastError;
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
#include "modules/desktop_capture/desktop_region.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right)
|
||||
@ -109,7 +109,7 @@ void DesktopRegion::AddRect(const DesktopRect& rect) {
|
||||
// If the |top| falls in the middle of the |row| then split |row| into
|
||||
// two, at |top|, and leave |row| referring to the lower of the two,
|
||||
// ready to insert a new span into.
|
||||
assert(top <= row->second->bottom);
|
||||
RTC_DCHECK_LE(top, row->second->bottom);
|
||||
Rows::iterator new_row = rows_.insert(
|
||||
row, Rows::value_type(top, new Row(row->second->top, top)));
|
||||
row->second->top = top;
|
||||
@ -148,7 +148,7 @@ void DesktopRegion::AddRects(const DesktopRect* rects, int count) {
|
||||
}
|
||||
|
||||
void DesktopRegion::MergeWithPrecedingRow(Rows::iterator row) {
|
||||
assert(row != rows_.end());
|
||||
RTC_DCHECK(row != rows_.end());
|
||||
|
||||
if (row != rows_.begin()) {
|
||||
Rows::iterator previous_row = row;
|
||||
@ -230,7 +230,7 @@ void DesktopRegion::IntersectRows(const RowSpanSet& set1,
|
||||
RowSpanSet::const_iterator end1 = set1.end();
|
||||
RowSpanSet::const_iterator it2 = set2.begin();
|
||||
RowSpanSet::const_iterator end2 = set2.end();
|
||||
assert(it1 != end1 && it2 != end2);
|
||||
RTC_DCHECK(it1 != end1 && it2 != end2);
|
||||
|
||||
do {
|
||||
// Arrange for |it1| to always be the left-most of the spans.
|
||||
@ -247,7 +247,7 @@ void DesktopRegion::IntersectRows(const RowSpanSet& set1,
|
||||
|
||||
int32_t left = it2->left;
|
||||
int32_t right = std::min(it1->right, it2->right);
|
||||
assert(left < right);
|
||||
RTC_DCHECK_LT(left, right);
|
||||
|
||||
output->push_back(RowSpan(left, right));
|
||||
|
||||
@ -302,7 +302,7 @@ void DesktopRegion::Subtract(const DesktopRegion& region) {
|
||||
// If |top| falls in the middle of |row_a| then split |row_a| into two, at
|
||||
// |top|, and leave |row_a| referring to the lower of the two, ready to
|
||||
// subtract spans from.
|
||||
assert(top <= row_a->second->bottom);
|
||||
RTC_DCHECK_LE(top, row_a->second->bottom);
|
||||
Rows::iterator new_row = rows_.insert(
|
||||
row_a, Rows::value_type(top, new Row(row_a->second->top, top)));
|
||||
row_a->second->top = top;
|
||||
@ -420,7 +420,7 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) {
|
||||
// Find the first span that ends at or after |left|.
|
||||
RowSpanSet::iterator start = std::lower_bound(
|
||||
row->spans.begin(), row->spans.end(), left, CompareSpanRight);
|
||||
assert(start < row->spans.end());
|
||||
RTC_DCHECK(start < row->spans.end());
|
||||
|
||||
// Find the first span that starts after |right|.
|
||||
RowSpanSet::iterator end =
|
||||
@ -467,7 +467,7 @@ bool DesktopRegion::IsSpanInRow(const Row& row, const RowSpan& span) {
|
||||
void DesktopRegion::SubtractRows(const RowSpanSet& set_a,
|
||||
const RowSpanSet& set_b,
|
||||
RowSpanSet* output) {
|
||||
assert(!set_a.empty() && !set_b.empty());
|
||||
RTC_DCHECK(!set_a.empty() && !set_b.empty());
|
||||
|
||||
RowSpanSet::const_iterator it_b = set_b.begin();
|
||||
|
||||
@ -503,7 +503,7 @@ DesktopRegion::Iterator::Iterator(const DesktopRegion& region)
|
||||
row_(region.rows_.begin()),
|
||||
previous_row_(region.rows_.end()) {
|
||||
if (!IsAtEnd()) {
|
||||
assert(row_->second->spans.size() > 0);
|
||||
RTC_DCHECK_GT(row_->second->spans.size(), 0);
|
||||
row_span_ = row_->second->spans.begin();
|
||||
UpdateCurrentRect();
|
||||
}
|
||||
@ -516,7 +516,7 @@ bool DesktopRegion::Iterator::IsAtEnd() const {
|
||||
}
|
||||
|
||||
void DesktopRegion::Iterator::Advance() {
|
||||
assert(!IsAtEnd());
|
||||
RTC_DCHECK(!IsAtEnd());
|
||||
|
||||
while (true) {
|
||||
++row_span_;
|
||||
@ -524,7 +524,7 @@ void DesktopRegion::Iterator::Advance() {
|
||||
previous_row_ = row_;
|
||||
++row_;
|
||||
if (row_ != region_.rows_.end()) {
|
||||
assert(row_->second->spans.size() > 0);
|
||||
RTC_DCHECK_GT(row_->second->spans.size(), 0);
|
||||
row_span_ = row_->second->spans.begin();
|
||||
}
|
||||
}
|
||||
@ -544,7 +544,7 @@ void DesktopRegion::Iterator::Advance() {
|
||||
break;
|
||||
}
|
||||
|
||||
assert(!IsAtEnd());
|
||||
RTC_DCHECK(!IsAtEnd());
|
||||
UpdateCurrentRect();
|
||||
}
|
||||
|
||||
|
||||
@ -10,9 +10,10 @@
|
||||
|
||||
#include "modules/desktop_capture/linux/x_error_trap.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
@ -22,7 +23,7 @@ static bool g_xserver_error_trap_enabled = false;
|
||||
static int g_last_xserver_error_code = 0;
|
||||
|
||||
int XServerErrorHandler(Display* display, XErrorEvent* error_event) {
|
||||
assert(g_xserver_error_trap_enabled);
|
||||
RTC_DCHECK(g_xserver_error_trap_enabled);
|
||||
g_last_xserver_error_code = error_event->error_code;
|
||||
return 0;
|
||||
}
|
||||
@ -31,7 +32,7 @@ int XServerErrorHandler(Display* display, XErrorEvent* error_event) {
|
||||
|
||||
XErrorTrap::XErrorTrap(Display* display)
|
||||
: original_error_handler_(NULL), enabled_(true) {
|
||||
assert(!g_xserver_error_trap_enabled);
|
||||
RTC_DCHECK(!g_xserver_error_trap_enabled);
|
||||
original_error_handler_ = XSetErrorHandler(&XServerErrorHandler);
|
||||
g_xserver_error_trap_enabled = true;
|
||||
g_last_xserver_error_code = 0;
|
||||
@ -39,7 +40,7 @@ XErrorTrap::XErrorTrap(Display* display)
|
||||
|
||||
int XErrorTrap::GetLastErrorAndDisable() {
|
||||
enabled_ = false;
|
||||
assert(g_xserver_error_trap_enabled);
|
||||
RTC_DCHECK(g_xserver_error_trap_enabled);
|
||||
XSetErrorHandler(original_error_handler_);
|
||||
g_xserver_error_trap_enabled = false;
|
||||
return g_last_xserver_error_code;
|
||||
|
||||
@ -10,9 +10,8 @@
|
||||
|
||||
#include "modules/desktop_capture/mouse_cursor.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "modules/desktop_capture/desktop_frame.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -20,8 +19,8 @@ MouseCursor::MouseCursor() {}
|
||||
|
||||
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
|
||||
: image_(image), hotspot_(hotspot) {
|
||||
assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
|
||||
assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
|
||||
RTC_DCHECK(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
|
||||
RTC_DCHECK(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
|
||||
}
|
||||
|
||||
MouseCursor::~MouseCursor() {}
|
||||
|
||||
@ -65,7 +65,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(FromScreen)) {
|
||||
MouseCursorMonitor::CreateForScreen(
|
||||
DesktopCaptureOptions::CreateDefault(),
|
||||
webrtc::kFullDesktopScreenId));
|
||||
assert(capturer.get());
|
||||
RTC_DCHECK(capturer.get());
|
||||
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
|
||||
capturer->Capture();
|
||||
|
||||
@ -102,7 +102,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(FromWindow)) {
|
||||
std::unique_ptr<MouseCursorMonitor> capturer(
|
||||
MouseCursorMonitor::CreateForWindow(
|
||||
DesktopCaptureOptions::CreateDefault(), sources[i].id));
|
||||
assert(capturer.get());
|
||||
RTC_DCHECK(capturer.get());
|
||||
|
||||
capturer->Init(this, MouseCursorMonitor::SHAPE_AND_POSITION);
|
||||
capturer->Capture();
|
||||
@ -118,7 +118,7 @@ TEST_F(MouseCursorMonitorTest, MAYBE(ShapeOnly)) {
|
||||
MouseCursorMonitor::CreateForScreen(
|
||||
DesktopCaptureOptions::CreateDefault(),
|
||||
webrtc::kFullDesktopScreenId));
|
||||
assert(capturer.get());
|
||||
RTC_DCHECK(capturer.get());
|
||||
capturer->Init(this, MouseCursorMonitor::SHAPE_ONLY);
|
||||
capturer->Capture();
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ MouseCursorMonitorWin::MouseCursorMonitorWin(ScreenId screen)
|
||||
callback_(NULL),
|
||||
mode_(SHAPE_AND_POSITION),
|
||||
desktop_dc_(NULL) {
|
||||
assert(screen >= kFullDesktopScreenId);
|
||||
RTC_DCHECK_GE(screen, kFullDesktopScreenId);
|
||||
memset(&last_cursor_, 0, sizeof(CURSORINFO));
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ MouseCursorMonitorWin::~MouseCursorMonitorWin() {
|
||||
}
|
||||
|
||||
void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
|
||||
assert(!callback_);
|
||||
assert(callback);
|
||||
RTC_DCHECK(!callback_);
|
||||
RTC_DCHECK(callback);
|
||||
|
||||
callback_ = callback;
|
||||
mode_ = mode;
|
||||
@ -97,7 +97,7 @@ void MouseCursorMonitorWin::Init(Callback* callback, Mode mode) {
|
||||
}
|
||||
|
||||
void MouseCursorMonitorWin::Capture() {
|
||||
assert(callback_);
|
||||
RTC_DCHECK(callback_);
|
||||
|
||||
CURSORINFO cursor_info;
|
||||
cursor_info.cbSize = sizeof(CURSORINFO);
|
||||
@ -158,7 +158,7 @@ void MouseCursorMonitorWin::Capture() {
|
||||
position = position.subtract(cropped_rect.top_left());
|
||||
}
|
||||
} else {
|
||||
assert(screen_ != kInvalidScreenId);
|
||||
RTC_DCHECK_NE(screen_, kInvalidScreenId);
|
||||
DesktopRect rect = GetScreenRect();
|
||||
if (inside)
|
||||
inside = rect.Contains(position);
|
||||
@ -169,7 +169,7 @@ void MouseCursorMonitorWin::Capture() {
|
||||
}
|
||||
|
||||
DesktopRect MouseCursorMonitorWin::GetScreenRect() {
|
||||
assert(screen_ != kInvalidScreenId);
|
||||
RTC_DCHECK_NE(screen_, kInvalidScreenId);
|
||||
if (screen_ == kFullDesktopScreenId) {
|
||||
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
|
||||
GetSystemMetrics(SM_YVIRTUALSCREEN),
|
||||
|
||||
@ -74,7 +74,7 @@ static int UpToMultiple(int x, int n, int nMask) {
|
||||
void ScreenCapturerHelper::ExpandToGrid(const DesktopRegion& region,
|
||||
int log_grid_size,
|
||||
DesktopRegion* result) {
|
||||
assert(log_grid_size >= 1);
|
||||
RTC_DCHECK_GE(log_grid_size, 1);
|
||||
int grid_size = 1 << log_grid_size;
|
||||
int grid_size_mask = ~(grid_size - 1);
|
||||
|
||||
|
||||
@ -8,10 +8,9 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "modules/desktop_capture/desktop_capturer.h"
|
||||
#include "modules/desktop_capture/desktop_frame.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -49,8 +48,8 @@ bool WindowCapturerNull::SelectSource(SourceId id) {
|
||||
}
|
||||
|
||||
void WindowCapturerNull::Start(Callback* callback) {
|
||||
assert(!callback_);
|
||||
assert(callback);
|
||||
RTC_DCHECK(!callback_);
|
||||
RTC_DCHECK(callback);
|
||||
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
|
||||
current_bitrate_ = ClampBitrate(new_bitrate.value_or(current_bitrate_));
|
||||
@ -417,7 +417,7 @@ void AimdRateControl::ChangeState(const RateControlInput& input,
|
||||
rate_control_state_ = RateControlState::kRcHold;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,9 +37,9 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
|
||||
uint32_t* timestamp_delta,
|
||||
int64_t* arrival_time_delta_ms,
|
||||
int* packet_size_delta) {
|
||||
assert(timestamp_delta != NULL);
|
||||
assert(arrival_time_delta_ms != NULL);
|
||||
assert(packet_size_delta != NULL);
|
||||
RTC_DCHECK(timestamp_delta);
|
||||
RTC_DCHECK(arrival_time_delta_ms);
|
||||
RTC_DCHECK(packet_size_delta);
|
||||
bool calculated_deltas = false;
|
||||
if (current_timestamp_group_.IsFirstPacket()) {
|
||||
// We don't have enough data to update the filter, so we store it until we
|
||||
@ -85,7 +85,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
|
||||
} else {
|
||||
num_consecutive_reordered_packets_ = 0;
|
||||
}
|
||||
assert(*arrival_time_delta_ms >= 0);
|
||||
RTC_DCHECK_GE(*arrival_time_delta_ms, 0);
|
||||
*packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
|
||||
static_cast<int>(prev_timestamp_group_.size);
|
||||
calculated_deltas = true;
|
||||
@ -141,7 +141,7 @@ bool InterArrival::BelongsToBurst(int64_t arrival_time_ms,
|
||||
if (!burst_grouping_) {
|
||||
return false;
|
||||
}
|
||||
assert(current_timestamp_group_.complete_time_ms >= 0);
|
||||
RTC_DCHECK_GE(current_timestamp_group_.complete_time_ms, 0);
|
||||
int64_t arrival_time_delta_ms =
|
||||
arrival_time_ms - current_timestamp_group_.complete_time_ms;
|
||||
uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
|
||||
|
||||
@ -110,7 +110,7 @@ void OveruseEstimator::Update(int64_t t_delta,
|
||||
bool positive_semi_definite =
|
||||
E_[0][0] + E_[1][1] >= 0 &&
|
||||
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0;
|
||||
assert(positive_semi_definite);
|
||||
RTC_DCHECK(positive_semi_definite);
|
||||
if (!positive_semi_definite) {
|
||||
RTC_LOG(LS_ERROR)
|
||||
<< "The over-use estimator's covariance matrix is no longer "
|
||||
|
||||
@ -234,7 +234,7 @@ bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
|
||||
std::vector<uint32_t>* ssrcs,
|
||||
uint32_t* bitrate_bps) const {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(bitrate_bps);
|
||||
RTC_DCHECK(bitrate_bps);
|
||||
if (!remote_rate_->ValidEstimate()) {
|
||||
return false;
|
||||
}
|
||||
@ -248,7 +248,7 @@ bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
std::vector<uint32_t>* ssrcs) const {
|
||||
assert(ssrcs);
|
||||
RTC_DCHECK(ssrcs);
|
||||
ssrcs->resize(overuse_detectors_.size());
|
||||
int i = 0;
|
||||
for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();
|
||||
|
||||
@ -46,7 +46,7 @@ RtpStream::RtpStream(int fps,
|
||||
next_rtcp_time_(rtcp_receive_time),
|
||||
rtp_timestamp_offset_(timestamp_offset),
|
||||
kNtpFracPerMs(4.294967296E6) {
|
||||
assert(fps_ > 0);
|
||||
RTC_DCHECK_GT(fps_, 0);
|
||||
}
|
||||
|
||||
void RtpStream::set_rtp_timestamp_offset(uint32_t offset) {
|
||||
@ -60,7 +60,7 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) {
|
||||
if (time_now_us < next_rtp_time_) {
|
||||
return next_rtp_time_;
|
||||
}
|
||||
assert(packets != NULL);
|
||||
RTC_DCHECK(packets);
|
||||
size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
|
||||
size_t n_packets =
|
||||
std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
|
||||
@ -173,9 +173,9 @@ void StreamGenerator::set_rtp_timestamp_offset(uint32_t ssrc, uint32_t offset) {
|
||||
// it possible to simulate different types of channels.
|
||||
int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets,
|
||||
int64_t time_now_us) {
|
||||
assert(packets != NULL);
|
||||
assert(packets->empty());
|
||||
assert(capacity_ > 0);
|
||||
RTC_DCHECK(packets);
|
||||
RTC_DCHECK(packets->empty());
|
||||
RTC_DCHECK_GT(capacity_, 0);
|
||||
StreamMap::iterator it =
|
||||
std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
|
||||
(*it).second->GenerateFrame(time_now_us, packets);
|
||||
|
||||
@ -131,7 +131,7 @@ bool RtpHeaderParser::RTCP() const {
|
||||
}
|
||||
|
||||
bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const {
|
||||
assert(header != NULL);
|
||||
RTC_DCHECK(header);
|
||||
|
||||
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
|
||||
if (length < kRtcpMinParseLength) {
|
||||
|
||||
@ -225,7 +225,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
// Check that we can only recover 1 packet.
|
||||
assert(check_num_recovered == 1);
|
||||
RTC_DCHECK_EQ(check_num_recovered, 1);
|
||||
// Update the state with the newly recovered media packet.
|
||||
state_tmp[jsel] = 0;
|
||||
}
|
||||
@ -260,7 +260,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
} else { // Gilbert-Elliot model for burst model.
|
||||
assert(loss_model_[k].loss_type == kBurstyLossModel);
|
||||
RTC_DCHECK_EQ(loss_model_[k].loss_type, kBurstyLossModel);
|
||||
// Transition probabilities: from previous to current state.
|
||||
// Prob. of previous = lost --> current = received.
|
||||
double prob10 = 1.0 / burst_length;
|
||||
@ -425,8 +425,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
} // Done with loop over total number of packets.
|
||||
assert(num_media_packets_lost <= num_media_packets);
|
||||
assert(num_packets_lost <= tot_num_packets && num_packets_lost > 0);
|
||||
RTC_DCHECK_LE(num_media_packets_lost, num_media_packets);
|
||||
RTC_DCHECK_LE(num_packets_lost, tot_num_packets && num_packets_lost > 0);
|
||||
double residual_loss = 0.0;
|
||||
// Only need to compute residual loss (number of recovered packets) for
|
||||
// configurations that have at least one media packet lost.
|
||||
@ -445,7 +445,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
num_recovered_packets = num_media_packets_lost;
|
||||
}
|
||||
}
|
||||
assert(num_recovered_packets <= num_media_packets);
|
||||
RTC_DCHECK_LE(num_recovered_packets, num_media_packets);
|
||||
// Compute the residual loss. We only care about recovering media/source
|
||||
// packets, so residual loss is based on lost/recovered media packets.
|
||||
residual_loss =
|
||||
@ -464,9 +464,9 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
// Update the distribution statistics.
|
||||
// Compute the gap of the loss (the "consecutiveness" of the loss).
|
||||
int gap_loss = GapLoss(tot_num_packets, state.get());
|
||||
assert(gap_loss < kMaxGapSize);
|
||||
RTC_DCHECK_LT(gap_loss, kMaxGapSize);
|
||||
int index = gap_loss * (2 * kMaxMediaPacketsTest) + num_packets_lost;
|
||||
assert(index < kNumStatesDistribution);
|
||||
RTC_DCHECK_LT(index, kNumStatesDistribution);
|
||||
metrics_code.residual_loss_per_loss_gap[index] += residual_loss;
|
||||
if (code_type == xor_random_code) {
|
||||
// The configuration density is only a function of the code length and
|
||||
@ -492,8 +492,8 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
metrics_code.variance_residual_loss[k] -
|
||||
(metrics_code.average_residual_loss[k] *
|
||||
metrics_code.average_residual_loss[k]);
|
||||
assert(metrics_code.variance_residual_loss[k] >= 0.0);
|
||||
assert(metrics_code.average_residual_loss[k] > 0.0);
|
||||
RTC_DCHECK_GE(metrics_code.variance_residual_loss[k], 0.0);
|
||||
RTC_DCHECK_GT(metrics_code.average_residual_loss[k], 0.0);
|
||||
metrics_code.variance_residual_loss[k] =
|
||||
std::sqrt(metrics_code.variance_residual_loss[k]) /
|
||||
metrics_code.average_residual_loss[k];
|
||||
@ -509,7 +509,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
} else if (code_type == xor_bursty_code) {
|
||||
CopyMetrics(&kMetricsXorBursty[code_index], metrics_code);
|
||||
} else {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
num_loss_models++;
|
||||
}
|
||||
}
|
||||
assert(num_loss_models == kNumLossModels);
|
||||
RTC_DCHECK_EQ(num_loss_models, kNumLossModels);
|
||||
}
|
||||
|
||||
void SetCodeParams() {
|
||||
@ -738,7 +738,7 @@ class FecPacketMaskMetricsTest : public ::testing::Test {
|
||||
code_index++;
|
||||
}
|
||||
}
|
||||
assert(code_index == kNumberCodes);
|
||||
RTC_DCHECK_EQ(code_index, kNumberCodes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ int32_t DeviceInfoImpl::NumberOfCapabilities(const char* deviceUniqueIdUTF8) {
|
||||
int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
|
||||
const uint32_t deviceCapabilityNumber,
|
||||
VideoCaptureCapability& capability) {
|
||||
assert(deviceUniqueIdUTF8 != NULL);
|
||||
RTC_DCHECK(deviceUniqueIdUTF8);
|
||||
|
||||
MutexLock lock(&_apiLock);
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ class VideoCaptureTest : public ::testing::Test {
|
||||
|
||||
void SetUp() override {
|
||||
device_info_.reset(VideoCaptureFactory::CreateDeviceInfo());
|
||||
assert(device_info_.get());
|
||||
RTC_DCHECK(device_info_.get());
|
||||
number_of_devices_ = device_info_->NumberOfDevices();
|
||||
ASSERT_GT(number_of_devices_, 0u);
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
|
||||
supportFORMAT_VideoInfo2 = true;
|
||||
VIDEOINFOHEADER2* h =
|
||||
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
|
||||
assert(h);
|
||||
RTC_DCHECK(h);
|
||||
foundInterlacedFormat |=
|
||||
h->dwInterlaceFlags &
|
||||
(AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOnly);
|
||||
@ -418,7 +418,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
|
||||
|
||||
if (pmt->formattype == FORMAT_VideoInfo) {
|
||||
VIDEOINFOHEADER* h = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
|
||||
assert(h);
|
||||
RTC_DCHECK(h);
|
||||
capability.directShowCapabilityIndex = tmp;
|
||||
capability.width = h->bmiHeader.biWidth;
|
||||
capability.height = h->bmiHeader.biHeight;
|
||||
@ -427,7 +427,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8)
|
||||
if (pmt->formattype == FORMAT_VideoInfo2) {
|
||||
VIDEOINFOHEADER2* h =
|
||||
reinterpret_cast<VIDEOINFOHEADER2*>(pmt->pbFormat);
|
||||
assert(h);
|
||||
RTC_DCHECK(h);
|
||||
capability.directShowCapabilityIndex = tmp;
|
||||
capability.width = h->bmiHeader.biWidth;
|
||||
capability.height = h->bmiHeader.biHeight;
|
||||
|
||||
@ -58,7 +58,7 @@ class EnumPins : public IEnumPins {
|
||||
}
|
||||
|
||||
STDMETHOD(Clone)(IEnumPins** pins) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class EnumPins : public IEnumPins {
|
||||
}
|
||||
|
||||
STDMETHOD(Skip)(ULONG count) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ class MediaTypesEnum : public IEnumMediaTypes {
|
||||
|
||||
// IEnumMediaTypes
|
||||
STDMETHOD(Clone)(IEnumMediaTypes** pins) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ class MediaTypesEnum : public IEnumMediaTypes {
|
||||
}
|
||||
|
||||
STDMETHOD(Skip)(ULONG count) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ STDMETHODIMP CaptureInputPin::Connect(IPin* receive_pin,
|
||||
return VFW_E_NOT_STOPPED;
|
||||
|
||||
if (receive_pin_) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return VFW_E_ALREADY_CONNECTED;
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ STDMETHODIMP CaptureInputPin::ReceiveConnection(
|
||||
RTC_DCHECK(Filter()->IsStopped());
|
||||
|
||||
if (receive_pin_) {
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
return VFW_E_ALREADY_CONNECTED;
|
||||
}
|
||||
|
||||
|
||||
@ -1037,7 +1037,7 @@ int LibvpxVp8Encoder::Encode(const VideoFrame& frame,
|
||||
// would like to use the duration of the previous frame. Unfortunately the
|
||||
// rate control seems to be off with that setup. Using the average input
|
||||
// frame rate to calculate an average duration for now.
|
||||
assert(codec_.maxFramerate > 0);
|
||||
RTC_DCHECK_GT(codec_.maxFramerate, 0);
|
||||
uint32_t duration = kRtpTicksPerSecond / codec_.maxFramerate;
|
||||
|
||||
int error = WEBRTC_VIDEO_CODEC_OK;
|
||||
@ -1074,7 +1074,7 @@ void LibvpxVp8Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
|
||||
int stream_idx,
|
||||
int encoder_idx,
|
||||
uint32_t timestamp) {
|
||||
assert(codec_specific != NULL);
|
||||
RTC_DCHECK(codec_specific);
|
||||
codec_specific->codecType = kVideoCodecVP8;
|
||||
codec_specific->codecSpecific.VP8.keyIdx =
|
||||
kNoKeyIdx; // TODO(hlundin) populate this
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "modules/video_coding/codecs/interface/common_constants.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -131,7 +132,7 @@ struct GofInfoVP9 {
|
||||
pid_diff[7][1] = 2;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,21 +55,22 @@ uint16_t VCMDecodingState::sequence_num() const {
|
||||
}
|
||||
|
||||
bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const {
|
||||
assert(frame != NULL);
|
||||
RTC_DCHECK(frame);
|
||||
if (in_initial_state_)
|
||||
return false;
|
||||
return !IsNewerTimestamp(frame->Timestamp(), time_stamp_);
|
||||
}
|
||||
|
||||
bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const {
|
||||
assert(packet != NULL);
|
||||
RTC_DCHECK(packet);
|
||||
if (in_initial_state_)
|
||||
return false;
|
||||
return !IsNewerTimestamp(packet->timestamp, time_stamp_);
|
||||
}
|
||||
|
||||
void VCMDecodingState::SetState(const VCMFrameBuffer* frame) {
|
||||
assert(frame != NULL && frame->GetHighSeqNum() >= 0);
|
||||
RTC_DCHECK(frame);
|
||||
RTC_CHECK_GE(frame->GetHighSeqNum(), 0);
|
||||
if (!UsingFlexibleMode(frame))
|
||||
UpdateSyncState(frame);
|
||||
sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum());
|
||||
@ -150,7 +151,7 @@ bool VCMDecodingState::UpdateEmptyFrame(const VCMFrameBuffer* frame) {
|
||||
}
|
||||
|
||||
void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) {
|
||||
assert(packet != NULL);
|
||||
RTC_DCHECK(packet);
|
||||
if (packet->timestamp == time_stamp_) {
|
||||
// Late packet belonging to the last decoded frame - make sure we update the
|
||||
// last decoded sequence number.
|
||||
@ -204,7 +205,7 @@ bool VCMDecodingState::ContinuousFrame(const VCMFrameBuffer* frame) const {
|
||||
// - Sequence numbers.
|
||||
// Return true when in initial state.
|
||||
// Note that when a method is not applicable it will return false.
|
||||
assert(frame != NULL);
|
||||
RTC_DCHECK(frame);
|
||||
// A key frame is always considered continuous as it doesn't refer to any
|
||||
// frames and therefore won't introduce any errors even if prior frames are
|
||||
// missing.
|
||||
|
||||
@ -75,7 +75,7 @@ VCMFrameBufferEnum VCMFrameBuffer::InsertPacket(const VCMPacket& packet,
|
||||
int64_t timeInMs,
|
||||
const FrameData& frame_data) {
|
||||
TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket");
|
||||
assert(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
|
||||
RTC_DCHECK(!(NULL == packet.dataPtr && packet.sizeBytes > 0));
|
||||
if (packet.dataPtr != NULL) {
|
||||
_payloadType = packet.payloadType;
|
||||
}
|
||||
@ -230,19 +230,19 @@ void VCMFrameBuffer::SetState(VCMFrameBufferStateEnum state) {
|
||||
switch (state) {
|
||||
case kStateIncomplete:
|
||||
// we can go to this state from state kStateEmpty
|
||||
assert(_state == kStateEmpty);
|
||||
RTC_DCHECK_EQ(_state, kStateEmpty);
|
||||
|
||||
// Do nothing, we received a packet
|
||||
break;
|
||||
|
||||
case kStateComplete:
|
||||
assert(_state == kStateEmpty || _state == kStateIncomplete);
|
||||
RTC_DCHECK(_state == kStateEmpty || _state == kStateIncomplete);
|
||||
|
||||
break;
|
||||
|
||||
case kStateEmpty:
|
||||
// Should only be set to empty through Reset().
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
_state = state;
|
||||
|
||||
@ -347,7 +347,7 @@ VCMFrameBufferEnum VCMJitterBuffer::GetFrame(const VCMPacket& packet,
|
||||
|
||||
int64_t VCMJitterBuffer::LastPacketTime(const VCMEncodedFrame* frame,
|
||||
bool* retransmitted) const {
|
||||
assert(retransmitted);
|
||||
RTC_DCHECK(retransmitted);
|
||||
MutexLock lock(&mutex_);
|
||||
const VCMFrameBuffer* frame_buffer =
|
||||
static_cast<const VCMFrameBuffer*>(frame);
|
||||
@ -498,7 +498,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet,
|
||||
RecycleFrameBuffer(frame);
|
||||
return kFlushIndicator;
|
||||
default:
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
return buffer_state;
|
||||
}
|
||||
@ -580,8 +580,8 @@ void VCMJitterBuffer::SetNackSettings(size_t max_nack_list_size,
|
||||
int max_packet_age_to_nack,
|
||||
int max_incomplete_time_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(max_packet_age_to_nack >= 0);
|
||||
assert(max_incomplete_time_ms_ >= 0);
|
||||
RTC_DCHECK_GE(max_packet_age_to_nack, 0);
|
||||
RTC_DCHECK_GE(max_incomplete_time_ms_, 0);
|
||||
max_nack_list_size_ = max_nack_list_size;
|
||||
max_packet_age_to_nack_ = max_packet_age_to_nack;
|
||||
max_incomplete_time_ms_ = max_incomplete_time_ms;
|
||||
@ -600,7 +600,7 @@ int VCMJitterBuffer::NonContinuousOrIncompleteDuration() {
|
||||
|
||||
uint16_t VCMJitterBuffer::EstimatedLowSequenceNumber(
|
||||
const VCMFrameBuffer& frame) const {
|
||||
assert(frame.GetLowSeqNum() >= 0);
|
||||
RTC_DCHECK_GE(frame.GetLowSeqNum(), 0);
|
||||
if (frame.HaveFirstPacket())
|
||||
return frame.GetLowSeqNum();
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS,
|
||||
hMh_sigma = deltaFSBytes * Mh[0] + Mh[1] + sigma;
|
||||
if ((hMh_sigma < 1e-9 && hMh_sigma >= 0) ||
|
||||
(hMh_sigma > -1e-9 && hMh_sigma <= 0)) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return;
|
||||
}
|
||||
kalmanGain[0] = Mh[0] / hMh_sigma;
|
||||
@ -276,11 +276,11 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS,
|
||||
kalmanGain[1] * deltaFSBytes * t01;
|
||||
|
||||
// Covariance matrix, must be positive semi-definite.
|
||||
assert(_thetaCov[0][0] + _thetaCov[1][1] >= 0 &&
|
||||
_thetaCov[0][0] * _thetaCov[1][1] -
|
||||
_thetaCov[0][1] * _thetaCov[1][0] >=
|
||||
0 &&
|
||||
_thetaCov[0][0] >= 0);
|
||||
RTC_DCHECK(_thetaCov[0][0] + _thetaCov[1][1] >= 0 &&
|
||||
_thetaCov[0][0] * _thetaCov[1][1] -
|
||||
_thetaCov[0][1] * _thetaCov[1][0] >=
|
||||
0 &&
|
||||
_thetaCov[0][0] >= 0);
|
||||
}
|
||||
|
||||
// Calculate difference in delay between a sample and the expected delay
|
||||
@ -302,7 +302,7 @@ void VCMJitterEstimator::EstimateRandomJitter(double d_dT,
|
||||
_lastUpdateT = now;
|
||||
|
||||
if (_alphaCount == 0) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return;
|
||||
}
|
||||
double alpha =
|
||||
@ -428,7 +428,7 @@ double VCMJitterEstimator::GetFrameRate() const {
|
||||
|
||||
double fps = 1000000.0 / fps_counter_.ComputeMean();
|
||||
// Sanity check.
|
||||
assert(fps >= 0.0);
|
||||
RTC_DCHECK_GE(fps, 0.0);
|
||||
if (fps > kMaxFramerateEstimate) {
|
||||
fps = kMaxFramerateEstimate;
|
||||
}
|
||||
|
||||
@ -87,10 +87,10 @@ VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs,
|
||||
_lowRttNackMs(lowRttNackThresholdMs),
|
||||
_highRttNackMs(highRttNackThresholdMs),
|
||||
_maxFramesFec(1) {
|
||||
assert(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1);
|
||||
assert(highRttNackThresholdMs == -1 ||
|
||||
lowRttNackThresholdMs <= highRttNackThresholdMs);
|
||||
assert(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1);
|
||||
RTC_DCHECK(lowRttNackThresholdMs >= -1 && highRttNackThresholdMs >= -1);
|
||||
RTC_DCHECK(highRttNackThresholdMs == -1 ||
|
||||
lowRttNackThresholdMs <= highRttNackThresholdMs);
|
||||
RTC_DCHECK(lowRttNackThresholdMs > -1 || highRttNackThresholdMs == -1);
|
||||
_type = kNackFec;
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) {
|
||||
indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize);
|
||||
|
||||
// Check on table index
|
||||
assert(indexTableKey < kFecRateTableSize);
|
||||
RTC_DCHECK_LT(indexTableKey, kFecRateTableSize);
|
||||
|
||||
// Protection factor for I frame
|
||||
codeRateKey = kFecRateTable[indexTableKey];
|
||||
|
||||
@ -49,7 +49,7 @@ void VCMSessionInfo::UpdateDataPointers(const uint8_t* old_base_ptr,
|
||||
const uint8_t* new_base_ptr) {
|
||||
for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it)
|
||||
if ((*it).dataPtr != NULL) {
|
||||
assert(old_base_ptr != NULL && new_base_ptr != NULL);
|
||||
RTC_DCHECK(old_base_ptr != NULL && new_base_ptr != NULL);
|
||||
(*it).dataPtr = new_base_ptr + ((*it).dataPtr - old_base_ptr);
|
||||
}
|
||||
}
|
||||
@ -348,7 +348,7 @@ VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning(
|
||||
|
||||
VCMSessionInfo::PacketIterator VCMSessionInfo::FindPartitionEnd(
|
||||
PacketIterator it) const {
|
||||
assert((*it).codec() == kVideoCodecVP8);
|
||||
RTC_DCHECK_EQ((*it).codec(), kVideoCodecVP8);
|
||||
PacketIterator prev_it = it;
|
||||
const int partition_id =
|
||||
absl::get<RTPVideoHeaderVP8>((*it).video_header.video_type_header)
|
||||
|
||||
@ -157,7 +157,7 @@ void VCMTiming::StopDecodeTimer(uint32_t /*time_stamp*/,
|
||||
void VCMTiming::StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
codec_timer_->AddTiming(decode_time_ms, now_ms);
|
||||
assert(decode_time_ms >= 0);
|
||||
RTC_DCHECK_GE(decode_time_ms, 0);
|
||||
++num_decoded_frames_;
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp,
|
||||
|
||||
int VCMTiming::RequiredDecodeTimeMs() const {
|
||||
const int decode_time_ms = codec_timer_->RequiredDecodeTimeMs();
|
||||
assert(decode_time_ms >= 0);
|
||||
RTC_DCHECK_GE(decode_time_ms, 0);
|
||||
return decode_time_ms;
|
||||
}
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ void ConfigureStream(int width,
|
||||
float max_framerate,
|
||||
SpatialLayer* stream,
|
||||
int num_temporal_layers) {
|
||||
assert(stream);
|
||||
RTC_DCHECK(stream);
|
||||
stream->width = width;
|
||||
stream->height = height;
|
||||
stream->maxBitrate = max_bitrate;
|
||||
|
||||
@ -82,8 +82,8 @@ size_t SctpPacket::Builder::bytes_remaining() const {
|
||||
// The packet header (CommonHeader) hasn't been written yet:
|
||||
return max_packet_size_ - kHeaderSize;
|
||||
} else if (out_.size() > max_packet_size_) {
|
||||
RTC_DCHECK(false) << "Exceeded max size, data=" << out_.size()
|
||||
<< ", max_size=" << max_packet_size_;
|
||||
RTC_NOTREACHED() << "Exceeded max size, data=" << out_.size()
|
||||
<< ", max_size=" << max_packet_size_;
|
||||
return 0;
|
||||
}
|
||||
return max_packet_size_ - out_.size();
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
// Prevent the compiler from warning about an unused variable. For example:
|
||||
// int result = DoSomething();
|
||||
// assert(result == 17);
|
||||
// RTC_DCHECK(result == 17);
|
||||
// RTC_UNUSED(result);
|
||||
// Note: In most cases it is better to remove the unused variable rather than
|
||||
// suppressing the compiler warning.
|
||||
|
||||
5
rtc_base/third_party/base64/BUILD.gn
vendored
5
rtc_base/third_party/base64/BUILD.gn
vendored
@ -14,5 +14,8 @@ rtc_library("base64") {
|
||||
"base64.cc",
|
||||
"base64.h",
|
||||
]
|
||||
deps = [ "../../system:rtc_export" ]
|
||||
deps = [
|
||||
"../..:checks",
|
||||
"../../system:rtc_export",
|
||||
]
|
||||
}
|
||||
|
||||
14
rtc_base/third_party/base64/base64.cc
vendored
14
rtc_base/third_party/base64/base64.cc
vendored
@ -19,6 +19,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace rtc {
|
||||
@ -95,7 +97,7 @@ bool Base64::IsBase64Encoded(const std::string& str) {
|
||||
void Base64::EncodeFromArray(const void* data,
|
||||
size_t len,
|
||||
std::string* result) {
|
||||
assert(nullptr != result);
|
||||
RTC_DCHECK(result);
|
||||
result->clear();
|
||||
result->resize(((len + 2) / 3) * 4);
|
||||
const unsigned char* byte_data = static_cast<const unsigned char*>(data);
|
||||
@ -223,15 +225,15 @@ bool Base64::DecodeFromArrayTemplate(const char* data,
|
||||
DecodeFlags flags,
|
||||
T* result,
|
||||
size_t* data_used) {
|
||||
assert(nullptr != result);
|
||||
assert(flags <= (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK));
|
||||
RTC_DCHECK(result);
|
||||
RTC_DCHECK_LE(flags, (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK));
|
||||
|
||||
const DecodeFlags parse_flags = flags & DO_PARSE_MASK;
|
||||
const DecodeFlags pad_flags = flags & DO_PAD_MASK;
|
||||
const DecodeFlags term_flags = flags & DO_TERM_MASK;
|
||||
assert(0 != parse_flags);
|
||||
assert(0 != pad_flags);
|
||||
assert(0 != term_flags);
|
||||
RTC_DCHECK_NE(0, parse_flags);
|
||||
RTC_DCHECK_NE(0, pad_flags);
|
||||
RTC_DCHECK_NE(0, term_flags);
|
||||
|
||||
result->clear();
|
||||
result->reserve(len);
|
||||
|
||||
@ -280,7 +280,7 @@ class DecoderIvfFileWriter : public test::FakeDecoder {
|
||||
video_codec_type_ = VideoCodecType::kVideoCodecH264;
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR) << "Unsupported video codec " << codec;
|
||||
RTC_DCHECK(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
}
|
||||
~DecoderIvfFileWriter() override { file_writer_->Close(); }
|
||||
|
||||
@ -85,7 +85,7 @@ void InsertOrReplaceFieldTrialStringsInMap(
|
||||
(*fieldtrial_map)[tokens[idx]] = tokens[idx + 1];
|
||||
}
|
||||
} else {
|
||||
RTC_DCHECK(false) << "Invalid field trials string:" << trials_string;
|
||||
RTC_NOTREACHED() << "Invalid field trials string:" << trials_string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class FrameGeneratorTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
void WriteYuvFile(FILE* file, uint8_t y, uint8_t u, uint8_t v) {
|
||||
assert(file);
|
||||
RTC_DCHECK(file);
|
||||
std::unique_ptr<uint8_t[]> plane_buffer(new uint8_t[y_size]);
|
||||
memset(plane_buffer.get(), y, y_size);
|
||||
fwrite(plane_buffer.get(), 1, y_size, file);
|
||||
|
||||
@ -20,8 +20,8 @@ namespace test {
|
||||
|
||||
GlxRenderer::GlxRenderer(size_t width, size_t height)
|
||||
: width_(width), height_(height), display_(NULL), context_(NULL) {
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
RTC_DCHECK_GT(width, 0);
|
||||
RTC_DCHECK_GT(height, 0);
|
||||
}
|
||||
|
||||
GlxRenderer::~GlxRenderer() {
|
||||
|
||||
@ -83,7 +83,7 @@ class InterleavedRtpFileReader : public RtpFileReaderImpl {
|
||||
}
|
||||
|
||||
bool NextPacket(RtpPacket* packet) override {
|
||||
assert(file_ != nullptr);
|
||||
RTC_DCHECK(file_);
|
||||
packet->length = RtpPacket::kMaxPacketBufferSize;
|
||||
uint32_t len = 0;
|
||||
TRY(ReadUint32(&len, file_));
|
||||
@ -276,7 +276,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
if (result == kResultFail) {
|
||||
break;
|
||||
} else if (result == kResultSuccess && packets_.size() == 1) {
|
||||
assert(stream_start_ms == 0);
|
||||
RTC_DCHECK_EQ(stream_start_ms, 0);
|
||||
PacketIterator it = packets_.begin();
|
||||
stream_start_ms = it->time_offset_ms;
|
||||
it->time_offset_ms = 0;
|
||||
@ -330,9 +330,9 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
}
|
||||
|
||||
virtual int NextPcap(uint8_t* data, uint32_t* length, uint32_t* time_ms) {
|
||||
assert(data);
|
||||
assert(length);
|
||||
assert(time_ms);
|
||||
RTC_DCHECK(data);
|
||||
RTC_DCHECK(length);
|
||||
RTC_DCHECK(time_ms);
|
||||
|
||||
if (next_packet_it_ == packets_.end()) {
|
||||
return -1;
|
||||
@ -409,7 +409,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
uint32_t stream_start_ms,
|
||||
uint32_t number,
|
||||
const std::set<uint32_t>& ssrc_filter) {
|
||||
assert(next_packet_pos);
|
||||
RTC_DCHECK(next_packet_pos);
|
||||
|
||||
uint32_t ts_sec; // Timestamp seconds.
|
||||
uint32_t ts_usec; // Timestamp microseconds.
|
||||
@ -504,7 +504,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
}
|
||||
|
||||
int ReadXxpIpHeader(RtpPacketMarker* marker) {
|
||||
assert(marker);
|
||||
RTC_DCHECK(marker);
|
||||
|
||||
uint16_t version;
|
||||
uint16_t length;
|
||||
@ -534,7 +534,7 @@ class PcapReader : public RtpFileReaderImpl {
|
||||
|
||||
// Skip remaining fields of IP header.
|
||||
uint16_t header_length = (version & 0x0f00) >> (8 - 2);
|
||||
assert(header_length >= kMinIpHeaderLength);
|
||||
RTC_DCHECK_GE(header_length, kMinIpHeaderLength);
|
||||
TRY_PCAP(Skip(header_length - kMinIpHeaderLength));
|
||||
|
||||
protocol = protocol & 0x00ff;
|
||||
|
||||
@ -107,7 +107,7 @@ std::string TempFilename(const std::string& dir, const std::string& prefix) {
|
||||
if (::GetTempFileNameW(rtc::ToUtf16(dir).c_str(),
|
||||
rtc::ToUtf16(prefix).c_str(), 0, filename) != 0)
|
||||
return rtc::ToUtf8(filename);
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return "";
|
||||
#else
|
||||
int len = dir.size() + prefix.size() + 2 + 6;
|
||||
@ -116,7 +116,7 @@ std::string TempFilename(const std::string& dir, const std::string& prefix) {
|
||||
snprintf(tempname.get(), len, "%s/%sXXXXXX", dir.c_str(), prefix.c_str());
|
||||
int fd = ::mkstemp(tempname.get());
|
||||
if (fd == -1) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return "";
|
||||
} else {
|
||||
::close(fd);
|
||||
|
||||
@ -142,8 +142,8 @@ TEST_F(StatsEndToEndTest, GetStats) {
|
||||
stats.rtcp_packet_type_counts.nack_requests != 0 ||
|
||||
stats.rtcp_packet_type_counts.unique_nack_requests != 0;
|
||||
|
||||
assert(stats.current_payload_type == -1 ||
|
||||
stats.current_payload_type == kFakeVideoSendPayloadType);
|
||||
RTC_DCHECK(stats.current_payload_type == -1 ||
|
||||
stats.current_payload_type == kFakeVideoSendPayloadType);
|
||||
receive_stats_filled_["IncomingPayloadType"] |=
|
||||
stats.current_payload_type == kFakeVideoSendPayloadType;
|
||||
}
|
||||
|
||||
@ -601,7 +601,7 @@ bool VideoAnalyzer::AllFramesRecordedLocked() {
|
||||
bool VideoAnalyzer::FrameProcessed() {
|
||||
MutexLock lock(&comparison_lock_);
|
||||
++frames_processed_;
|
||||
assert(frames_processed_ <= frames_to_process_);
|
||||
RTC_DCHECK_LE(frames_processed_, frames_to_process_);
|
||||
return frames_processed_ == frames_to_process_ ||
|
||||
(clock_->CurrentTime() > test_end_ && comparisons_.empty());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user