Add RTC_ prefix to (D)CHECKs and related macros.

We must remove dependency on Chromium, i.e. we can't use Chromium's base/logging.h. That means we need to define these macros in WebRTC also when doing Chromium builds. And this causes redefinition.

Alternative solutions:
* Check if we already have defined e.g. CHECK, and don't define them in that case. This makes us depend on include order in Chromium, which is not acceptable.
* Don't allow using the macros in WebRTC headers. Error prone since if someone adds it there by mistake it may compile fine, but later break if a header in added or order is changed in Chromium. That will be confusing and hard to enforce.
* Ensure that headers that are included by an embedder don't include our macros. This would require some heavy refactoring to be maintainable and enforcable.
* Changes in Chromium for this is obviously not an option.

BUG=chromium:468375
NOTRY=true

Review URL: https://codereview.webrtc.org/1335923002

Cr-Commit-Position: refs/heads/master@{#9964}
This commit is contained in:
henrikg 2015-09-17 00:24:34 -07:00 committed by Commit bot
parent c0ac6cad00
commit 91d6edef35
232 changed files with 1665 additions and 1646 deletions

View File

@ -82,7 +82,7 @@ class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory {
int dst_width,
int dst_height) const override {
// Check that captured_frame is actually our frame.
CHECK(captured_frame == &captured_frame_);
RTC_CHECK(captured_frame == &captured_frame_);
rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame(
ShallowCenterCrop(buffer_, dst_width, dst_height),
captured_frame->elapsed_time, captured_frame->time_stamp,
@ -119,8 +119,9 @@ AndroidVideoCapturer::AndroidVideoCapturer(
std::vector<cricket::VideoFormat> formats;
for (Json::ArrayIndex i = 0; i < json_values.size(); ++i) {
const Json::Value& json_value = json_values[i];
CHECK(!json_value["width"].isNull() && !json_value["height"].isNull() &&
!json_value["framerate"].isNull());
RTC_CHECK(!json_value["width"].isNull() &&
!json_value["height"].isNull() &&
!json_value["framerate"].isNull());
cricket::VideoFormat format(
json_value["width"].asInt(),
json_value["height"].asInt(),
@ -134,13 +135,13 @@ AndroidVideoCapturer::AndroidVideoCapturer(
}
AndroidVideoCapturer::~AndroidVideoCapturer() {
CHECK(!running_);
RTC_CHECK(!running_);
}
cricket::CaptureState AndroidVideoCapturer::Start(
const cricket::VideoFormat& capture_format) {
CHECK(thread_checker_.CalledOnValidThread());
CHECK(!running_);
RTC_CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(!running_);
const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval);
LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x"
<< capture_format.height << "@" << fps;
@ -157,8 +158,8 @@ cricket::CaptureState AndroidVideoCapturer::Start(
void AndroidVideoCapturer::Stop() {
LOG(LS_INFO) << " AndroidVideoCapturer::Stop ";
CHECK(thread_checker_.CalledOnValidThread());
CHECK(running_);
RTC_CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(running_);
running_ = false;
SetCaptureFormat(NULL);
@ -168,18 +169,18 @@ void AndroidVideoCapturer::Stop() {
}
bool AndroidVideoCapturer::IsRunning() {
CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(thread_checker_.CalledOnValidThread());
return running_;
}
bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(thread_checker_.CalledOnValidThread());
fourccs->push_back(cricket::FOURCC_YV12);
return true;
}
void AndroidVideoCapturer::OnCapturerStarted(bool success) {
CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(thread_checker_.CalledOnValidThread());
cricket::CaptureState new_state =
success ? cricket::CS_RUNNING : cricket::CS_FAILED;
if (new_state == current_state_)
@ -196,7 +197,7 @@ void AndroidVideoCapturer::OnIncomingFrame(
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
int rotation,
int64 time_stamp) {
CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(thread_checker_.CalledOnValidThread());
frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp);
SignalFrameCaptured(this, frame_factory_->GetCapturedFrame());
frame_factory_->ClearCapturedFrame();
@ -204,7 +205,7 @@ void AndroidVideoCapturer::OnIncomingFrame(
void AndroidVideoCapturer::OnOutputFormatRequest(
int width, int height, int fps) {
CHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(thread_checker_.CalledOnValidThread());
const cricket::VideoFormat& current = video_adapter()->output_format();
cricket::VideoFormat format(
width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc);

View File

@ -120,7 +120,7 @@ class DataChannelInterface : public rtc::RefCountInterface {
case kClosed:
return "closed";
}
CHECK(false) << "Unknown DataChannel state: " << state;
RTC_CHECK(false) << "Unknown DataChannel state: " << state;
return "";
}

View File

@ -61,7 +61,7 @@ class DtlsIdentityStoreImpl::WorkerTask : public sigslot::has_slots<>,
store_->SignalDestroyed.connect(this, &WorkerTask::OnStoreDestroyed);
}
virtual ~WorkerTask() { DCHECK(signaling_thread_->IsCurrent()); }
virtual ~WorkerTask() { RTC_DCHECK(signaling_thread_->IsCurrent()); }
private:
void GenerateIdentity_w() {
@ -87,7 +87,7 @@ class DtlsIdentityStoreImpl::WorkerTask : public sigslot::has_slots<>,
signaling_thread_->Post(this, MSG_DESTROY, msg->pdata);
break;
case MSG_GENERATE_IDENTITY_RESULT:
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
{
rtc::scoped_ptr<IdentityResultMessageData> pdata(
static_cast<IdentityResultMessageData*>(msg->pdata));
@ -98,17 +98,17 @@ class DtlsIdentityStoreImpl::WorkerTask : public sigslot::has_slots<>,
}
break;
case MSG_DESTROY:
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
delete msg->pdata;
// |this| has now been deleted. Don't touch member variables.
break;
default:
CHECK(false) << "Unexpected message type";
RTC_CHECK(false) << "Unexpected message type";
}
}
void OnStoreDestroyed() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
store_ = nullptr;
}
@ -122,7 +122,7 @@ DtlsIdentityStoreImpl::DtlsIdentityStoreImpl(rtc::Thread* signaling_thread,
: signaling_thread_(signaling_thread),
worker_thread_(worker_thread),
request_info_() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
// Preemptively generate identities unless the worker thread and signaling
// thread are the same (only do preemptive work in the background).
if (worker_thread_ != signaling_thread_) {
@ -132,21 +132,21 @@ DtlsIdentityStoreImpl::DtlsIdentityStoreImpl(rtc::Thread* signaling_thread,
}
DtlsIdentityStoreImpl::~DtlsIdentityStoreImpl() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
SignalDestroyed();
}
void DtlsIdentityStoreImpl::RequestIdentity(
rtc::KeyType key_type,
const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer) {
DCHECK(signaling_thread_->IsCurrent());
DCHECK(observer);
RTC_DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(observer);
GenerateIdentity(key_type, observer);
}
void DtlsIdentityStoreImpl::OnMessage(rtc::Message* msg) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
switch (msg->message_id) {
case MSG_GENERATE_IDENTITY_RESULT: {
rtc::scoped_ptr<IdentityResultMessageData> pdata(
@ -160,14 +160,14 @@ void DtlsIdentityStoreImpl::OnMessage(rtc::Message* msg) {
bool DtlsIdentityStoreImpl::HasFreeIdentityForTesting(
rtc::KeyType key_type) const {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
return request_info_[key_type].free_identity_.get() != nullptr;
}
void DtlsIdentityStoreImpl::GenerateIdentity(
rtc::KeyType key_type,
const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
// Enqueue observer to be informed when generation of |key_type| is completed.
if (observer.get()) {
@ -205,9 +205,9 @@ void DtlsIdentityStoreImpl::GenerateIdentity(
void DtlsIdentityStoreImpl::OnIdentityGenerated(
rtc::KeyType key_type, rtc::scoped_ptr<rtc::SSLIdentity> identity) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
DCHECK(request_info_[key_type].gen_in_progress_counts_);
RTC_DCHECK(request_info_[key_type].gen_in_progress_counts_);
--request_info_[key_type].gen_in_progress_counts_;
rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer;
@ -218,7 +218,7 @@ void DtlsIdentityStoreImpl::OnIdentityGenerated(
if (observer.get() == nullptr) {
// No observer - store result in |free_identities_|.
DCHECK(!request_info_[key_type].free_identity_.get());
RTC_DCHECK(!request_info_[key_type].free_identity_.get());
request_info_[key_type].free_identity_.swap(identity);
if (request_info_[key_type].free_identity_.get())
LOG(LS_VERBOSE) << "A free DTLS identity was saved.";

View File

@ -83,7 +83,7 @@ class DtlsIdentityStoreTest : public testing::Test {
worker_thread_.get())),
observer_(
new rtc::RefCountedObject<MockDtlsIdentityRequestObserver>()) {
CHECK(worker_thread_->Start());
RTC_CHECK(worker_thread_->Start());
}
~DtlsIdentityStoreTest() {}

View File

@ -35,7 +35,7 @@ FakeMetricsObserver::FakeMetricsObserver() {
}
void FakeMetricsObserver::Reset() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
counters_.clear();
memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_));
for (std::string& type : string_histogram_samples_) {
@ -47,7 +47,7 @@ void FakeMetricsObserver::IncrementEnumCounter(
PeerConnectionEnumCounterType type,
int counter,
int counter_max) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (counters_.size() <= static_cast<size_t>(type)) {
counters_.resize(type + 1);
}
@ -60,34 +60,34 @@ void FakeMetricsObserver::IncrementEnumCounter(
void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
int value) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(int_histogram_samples_[type], 0);
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK_EQ(int_histogram_samples_[type], 0);
int_histogram_samples_[type] = value;
}
void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
const std::string& value) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
string_histogram_samples_[type].assign(value);
}
int FakeMetricsObserver::GetEnumCounter(PeerConnectionEnumCounterType type,
int counter) const {
DCHECK(thread_checker_.CalledOnValidThread());
CHECK(counters_.size() > static_cast<size_t>(type) &&
counters_[type].size() > static_cast<size_t>(counter));
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_CHECK(counters_.size() > static_cast<size_t>(type) &&
counters_[type].size() > static_cast<size_t>(counter));
return counters_[type][counter];
}
int FakeMetricsObserver::GetIntHistogramSample(
PeerConnectionMetricsName type) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return int_histogram_samples_[type];
}
const std::string& FakeMetricsObserver::GetStringHistogramSample(
PeerConnectionMetricsName type) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return string_histogram_samples_[type];
}

View File

@ -183,7 +183,7 @@ MediaCodecVideoDecoder::MediaCodecVideoDecoder(
"()V"))) {
ScopedLocalRefFrame local_ref_frame(jni);
codec_thread_->SetName("MediaCodecVideoDecoder", NULL);
CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
j_init_decode_method_ = GetMethodID(
jni, *j_media_codec_video_decoder_class_, "initDecode",
@ -262,8 +262,8 @@ int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
// Factory should guard against other codecs being used with us.
CHECK(inst->codecType == codecType_) << "Unsupported codec " <<
inst->codecType << " for " << codecType_;
RTC_CHECK(inst->codecType == codecType_)
<< "Unsupported codec " << inst->codecType << " for " << codecType_;
if (sw_fallback_required_) {
ALOGE("InitDecode() - fallback to SW decoder");
@ -394,7 +394,7 @@ int32_t MediaCodecVideoDecoder::ReleaseOnCodecThread() {
}
void MediaCodecVideoDecoder::CheckOnCodecThread() {
CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
RTC_CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
<< "Running on wrong thread!";
}
@ -514,7 +514,7 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
jobject j_input_buffer = input_buffers_[j_input_buffer_index];
uint8* buffer =
reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
CHECK(buffer) << "Indirect buffer??";
RTC_CHECK(buffer) << "Indirect buffer??";
int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer);
if (CheckException(jni) || buffer_capacity < inputImage._length) {
ALOGE("Input frame size %d is bigger than buffer size %d.",
@ -731,8 +731,8 @@ void MediaCodecVideoDecoder::OnMessage(rtc::Message* msg) {
}
// We only ever send one message to |this| directly (not through a Bind()'d
// functor), so expect no ID/data.
CHECK(!msg->message_id) << "Unexpected message!";
CHECK(!msg->pdata) << "Unexpected message!";
RTC_CHECK(!msg->message_id) << "Unexpected message!";
RTC_CHECK(!msg->pdata) << "Unexpected message!";
CheckOnCodecThread();
if (!DeliverPendingOutputs(jni, 0)) {

View File

@ -236,7 +236,7 @@ MediaCodecVideoEncoder::MediaCodecVideoEncoder(
// in the bug, we have a problem. For now work around that with a dedicated
// thread.
codec_thread_->SetName("MediaCodecVideoEncoder", NULL);
CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder";
RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder";
jclass j_output_buffer_info_class =
FindClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo");
@ -292,8 +292,9 @@ int32_t MediaCodecVideoEncoder::InitEncode(
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
// Factory should guard against other codecs being used with us.
CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " <<
codec_settings->codecType << " for " << codecType_;
RTC_CHECK(codec_settings->codecType == codecType_)
<< "Unsupported codec " << codec_settings->codecType << " for "
<< codecType_;
ALOGD("InitEncode request");
scale_ = false;
@ -359,8 +360,8 @@ void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) {
// We only ever send one message to |this| directly (not through a Bind()'d
// functor), so expect no ID/data.
CHECK(!msg->message_id) << "Unexpected message!";
CHECK(!msg->pdata) << "Unexpected message!";
RTC_CHECK(!msg->message_id) << "Unexpected message!";
RTC_CHECK(!msg->pdata) << "Unexpected message!";
CheckOnCodecThread();
if (!inited_) {
return;
@ -374,7 +375,7 @@ void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) {
}
void MediaCodecVideoEncoder::CheckOnCodecThread() {
CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
RTC_CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
<< "Running on wrong thread!";
}
@ -460,7 +461,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
return WEBRTC_VIDEO_CODEC_ERROR;
}
size_t num_input_buffers = jni->GetArrayLength(input_buffers);
CHECK(input_buffers_.empty())
RTC_CHECK(input_buffers_.empty())
<< "Unexpected double InitEncode without Release";
input_buffers_.resize(num_input_buffers);
for (size_t i = 0; i < num_input_buffers; ++i) {
@ -469,7 +470,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
int64 yuv_buffer_capacity =
jni->GetDirectBufferCapacity(input_buffers_[i]);
CHECK_EXCEPTION(jni);
CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity";
RTC_CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity";
}
CHECK_EXCEPTION(jni);
@ -499,7 +500,7 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread(
return WEBRTC_VIDEO_CODEC_OK;
}
CHECK(frame_types->size() == 1) << "Unexpected stream count";
RTC_CHECK(frame_types->size() == 1) << "Unexpected stream count";
// Check framerate before spatial resolution change.
if (scale_ && codecType_ == kVideoCodecVP8) {
quality_scaler_->OnEncodeFrame(frame);
@ -555,17 +556,12 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread(
uint8* yuv_buffer =
reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
CHECK_EXCEPTION(jni);
CHECK(yuv_buffer) << "Indirect buffer??";
CHECK(!libyuv::ConvertFromI420(
input_frame.buffer(webrtc::kYPlane),
input_frame.stride(webrtc::kYPlane),
input_frame.buffer(webrtc::kUPlane),
input_frame.stride(webrtc::kUPlane),
input_frame.buffer(webrtc::kVPlane),
input_frame.stride(webrtc::kVPlane),
yuv_buffer, width_,
width_, height_,
encoder_fourcc_))
RTC_CHECK(yuv_buffer) << "Indirect buffer??";
RTC_CHECK(!libyuv::ConvertFromI420(
input_frame.buffer(webrtc::kYPlane), input_frame.stride(webrtc::kYPlane),
input_frame.buffer(webrtc::kUPlane), input_frame.stride(webrtc::kUPlane),
input_frame.buffer(webrtc::kVPlane), input_frame.stride(webrtc::kVPlane),
yuv_buffer, width_, width_, height_, encoder_fourcc_))
<< "ConvertFromI420 failed";
last_input_timestamp_ms_ = current_timestamp_us_ / 1000;
frames_in_queue_++;

View File

@ -93,11 +93,11 @@ AndroidVideoCapturerJni::~AndroidVideoCapturerJni() {
void AndroidVideoCapturerJni::Start(int width, int height, int framerate,
webrtc::AndroidVideoCapturer* capturer) {
LOG(LS_INFO) << "AndroidVideoCapturerJni start";
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
{
rtc::CritScope cs(&capturer_lock_);
CHECK(capturer_ == nullptr);
CHECK(invoker_.get() == nullptr);
RTC_CHECK(capturer_ == nullptr);
RTC_CHECK(invoker_.get() == nullptr);
capturer_ = capturer;
invoker_.reset(new rtc::GuardedAsyncInvoker());
}
@ -121,7 +121,7 @@ void AndroidVideoCapturerJni::Start(int width, int height, int framerate,
void AndroidVideoCapturerJni::Stop() {
LOG(LS_INFO) << "AndroidVideoCapturerJni stop";
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
{
rtc::CritScope cs(&capturer_lock_);
// Destroying |invoker_| will cancel all pending calls to |capturer_|.
@ -220,7 +220,8 @@ JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured)
// that the memory is valid when we have released |j_frame|.
// TODO(magjed): Move ReleaseByteArrayElements() into ReturnBuffer() and
// remove this check.
CHECK(!is_copy) << "NativeObserver_nativeOnFrameCaptured: frame is a copy";
RTC_CHECK(!is_copy)
<< "NativeObserver_nativeOnFrameCaptured: frame is a copy";
reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
->OnIncomingFrame(bytes, length, width, height, rotation, ts);
jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);

View File

@ -51,7 +51,7 @@ class ClassReferenceHolder {
static ClassReferenceHolder* g_class_reference_holder = nullptr;
void LoadGlobalClassReferenceHolder() {
CHECK(g_class_reference_holder == nullptr);
RTC_CHECK(g_class_reference_holder == nullptr);
g_class_reference_holder = new ClassReferenceHolder(GetEnv());
}
@ -114,7 +114,7 @@ ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) {
}
ClassReferenceHolder::~ClassReferenceHolder() {
CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
RTC_CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
}
void ClassReferenceHolder::FreeReferences(JNIEnv* jni) {
@ -127,19 +127,19 @@ void ClassReferenceHolder::FreeReferences(JNIEnv* jni) {
jclass ClassReferenceHolder::GetClass(const std::string& name) {
std::map<std::string, jclass>::iterator it = classes_.find(name);
CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name;
RTC_CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name;
return it->second;
}
void ClassReferenceHolder::LoadClass(JNIEnv* jni, const std::string& name) {
jclass localRef = jni->FindClass(name.c_str());
CHECK_EXCEPTION(jni) << "error during FindClass: " << name;
CHECK(localRef) << name;
RTC_CHECK(localRef) << name;
jclass globalRef = reinterpret_cast<jclass>(jni->NewGlobalRef(localRef));
CHECK_EXCEPTION(jni) << "error during NewGlobalRef: " << name;
CHECK(globalRef) << name;
RTC_CHECK(globalRef) << name;
bool inserted = classes_.insert(std::make_pair(name, globalRef)).second;
CHECK(inserted) << "Duplicate class name: " << name;
RTC_CHECK(inserted) << "Duplicate class name: " << name;
}
// Returns a global reference guaranteed to be valid for the lifetime of the

View File

@ -49,7 +49,7 @@ static pthread_key_t g_jni_ptr;
using icu::UnicodeString;
JavaVM *GetJVM() {
CHECK(g_jvm) << "JNI_OnLoad failed to run?";
RTC_CHECK(g_jvm) << "JNI_OnLoad failed to run?";
return g_jvm;
}
@ -57,8 +57,8 @@ JavaVM *GetJVM() {
JNIEnv* GetEnv() {
void* env = NULL;
jint status = g_jvm->GetEnv(&env, JNI_VERSION_1_6);
CHECK(((env != NULL) && (status == JNI_OK)) ||
((env == NULL) && (status == JNI_EDETACHED)))
RTC_CHECK(((env != NULL) && (status == JNI_OK)) ||
((env == NULL) && (status == JNI_EDETACHED)))
<< "Unexpected GetEnv return: " << status << ":" << env;
return reinterpret_cast<JNIEnv*>(env);
}
@ -74,24 +74,24 @@ static void ThreadDestructor(void* prev_jni_ptr) {
if (!GetEnv())
return;
CHECK(GetEnv() == prev_jni_ptr)
RTC_CHECK(GetEnv() == prev_jni_ptr)
<< "Detaching from another thread: " << prev_jni_ptr << ":" << GetEnv();
jint status = g_jvm->DetachCurrentThread();
CHECK(status == JNI_OK) << "Failed to detach thread: " << status;
CHECK(!GetEnv()) << "Detaching was a successful no-op???";
RTC_CHECK(status == JNI_OK) << "Failed to detach thread: " << status;
RTC_CHECK(!GetEnv()) << "Detaching was a successful no-op???";
}
static void CreateJNIPtrKey() {
CHECK(!pthread_key_create(&g_jni_ptr, &ThreadDestructor))
RTC_CHECK(!pthread_key_create(&g_jni_ptr, &ThreadDestructor))
<< "pthread_key_create";
}
jint InitGlobalJniVariables(JavaVM *jvm) {
CHECK(!g_jvm) << "InitGlobalJniVariables!";
RTC_CHECK(!g_jvm) << "InitGlobalJniVariables!";
g_jvm = jvm;
CHECK(g_jvm) << "InitGlobalJniVariables handed NULL?";
RTC_CHECK(g_jvm) << "InitGlobalJniVariables handed NULL?";
CHECK(!pthread_once(&g_jni_ptr_once, &CreateJNIPtrKey)) << "pthread_once";
RTC_CHECK(!pthread_once(&g_jni_ptr_once, &CreateJNIPtrKey)) << "pthread_once";
JNIEnv* jni = nullptr;
if (jvm->GetEnv(reinterpret_cast<void**>(&jni), JNI_VERSION_1_6) != JNI_OK)
@ -103,9 +103,9 @@ jint InitGlobalJniVariables(JavaVM *jvm) {
// Return thread ID as a string.
static std::string GetThreadId() {
char buf[21]; // Big enough to hold a kuint64max plus terminating NULL.
CHECK_LT(snprintf(buf, sizeof(buf), "%ld",
static_cast<long>(syscall(__NR_gettid))),
sizeof(buf))
RTC_CHECK_LT(snprintf(buf, sizeof(buf), "%ld",
static_cast<long>(syscall(__NR_gettid))),
sizeof(buf))
<< "Thread id is bigger than uint64??";
return std::string(buf);
}
@ -123,7 +123,7 @@ JNIEnv* AttachCurrentThreadIfNeeded() {
JNIEnv* jni = GetEnv();
if (jni)
return jni;
CHECK(!pthread_getspecific(g_jni_ptr))
RTC_CHECK(!pthread_getspecific(g_jni_ptr))
<< "TLS has a JNIEnv* but not attached?";
std::string name(GetThreadName() + " - " + GetThreadId());
@ -137,10 +137,11 @@ JNIEnv* AttachCurrentThreadIfNeeded() {
#else
JNIEnv* env = NULL;
#endif
CHECK(!g_jvm->AttachCurrentThread(&env, &args)) << "Failed to attach thread";
CHECK(env) << "AttachCurrentThread handed back NULL!";
RTC_CHECK(!g_jvm->AttachCurrentThread(&env, &args))
<< "Failed to attach thread";
RTC_CHECK(env) << "AttachCurrentThread handed back NULL!";
jni = reinterpret_cast<JNIEnv*>(env);
CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific";
RTC_CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific";
return jni;
}
@ -154,18 +155,18 @@ jlong jlongFromPointer(void* ptr) {
// conversion from pointer to integral type. intptr_t to jlong is a standard
// widening by the static_assert above.
jlong ret = reinterpret_cast<intptr_t>(ptr);
DCHECK(reinterpret_cast<void*>(ret) == ptr);
RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr);
return ret;
}
// JNIEnv-helper methods that CHECK success: no Java exception thrown and found
// object/class/method/field is non-null.
// JNIEnv-helper methods that RTC_CHECK success: no Java exception thrown and
// found object/class/method/field is non-null.
jmethodID GetMethodID(
JNIEnv* jni, jclass c, const std::string& name, const char* signature) {
jmethodID m = jni->GetMethodID(c, name.c_str(), signature);
CHECK_EXCEPTION(jni) << "error during GetMethodID: " << name << ", "
<< signature;
CHECK(m) << name << ", " << signature;
RTC_CHECK(m) << name << ", " << signature;
return m;
}
@ -174,7 +175,7 @@ jmethodID GetStaticMethodID(
jmethodID m = jni->GetStaticMethodID(c, name, signature);
CHECK_EXCEPTION(jni) << "error during GetStaticMethodID: " << name << ", "
<< signature;
CHECK(m) << name << ", " << signature;
RTC_CHECK(m) << name << ", " << signature;
return m;
}
@ -182,21 +183,21 @@ jfieldID GetFieldID(
JNIEnv* jni, jclass c, const char* name, const char* signature) {
jfieldID f = jni->GetFieldID(c, name, signature);
CHECK_EXCEPTION(jni) << "error during GetFieldID";
CHECK(f) << name << ", " << signature;
RTC_CHECK(f) << name << ", " << signature;
return f;
}
jclass GetObjectClass(JNIEnv* jni, jobject object) {
jclass c = jni->GetObjectClass(object);
CHECK_EXCEPTION(jni) << "error during GetObjectClass";
CHECK(c) << "GetObjectClass returned NULL";
RTC_CHECK(c) << "GetObjectClass returned NULL";
return c;
}
jobject GetObjectField(JNIEnv* jni, jobject object, jfieldID id) {
jobject o = jni->GetObjectField(object, id);
CHECK_EXCEPTION(jni) << "error during GetObjectField";
CHECK(o) << "GetObjectField returned NULL";
RTC_CHECK(o) << "GetObjectField returned NULL";
return o;
}
@ -265,7 +266,7 @@ jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class,
jobject NewGlobalRef(JNIEnv* jni, jobject o) {
jobject ret = jni->NewGlobalRef(o);
CHECK_EXCEPTION(jni) << "error during NewGlobalRef";
CHECK(ret);
RTC_CHECK(ret);
return ret;
}
@ -278,7 +279,7 @@ void DeleteGlobalRef(JNIEnv* jni, jobject o) {
// callbacks (i.e. entry points that don't originate in a Java callstack
// through a "native" method call).
ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) {
CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame";
RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame";
}
ScopedLocalRefFrame::~ScopedLocalRefFrame() {
jni_->PopLocalFrame(NULL);

View File

@ -41,14 +41,14 @@
// This macros uses the comma operator to execute ExceptionDescribe
// and ExceptionClear ignoring their return values and sending ""
// to the error stream.
#define CHECK_EXCEPTION(jni) \
CHECK(!jni->ExceptionCheck()) \
#define CHECK_EXCEPTION(jni) \
RTC_CHECK(!jni->ExceptionCheck()) \
<< (jni->ExceptionDescribe(), jni->ExceptionClear(), "")
// Helper that calls ptr->Release() and aborts the process with a useful
// message if that didn't actually delete *ptr because of extra refcounts.
#define CHECK_RELEASE(ptr) \
CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
namespace webrtc_jni {
@ -67,8 +67,8 @@ JNIEnv* AttachCurrentThreadIfNeeded();
// function expecting a 64-bit param) picks up garbage in the high 32 bits.
jlong jlongFromPointer(void* ptr);
// JNIEnv-helper methods that CHECK success: no Java exception thrown and found
// object/class/method/field is non-null.
// JNIEnv-helper methods that RTC_CHECK success: no Java exception thrown and
// found object/class/method/field is non-null.
jmethodID GetMethodID(
JNIEnv* jni, jclass c, const std::string& name, const char* signature);

View File

@ -66,7 +66,7 @@ class JniNativeHandleBuffer : public webrtc::NativeHandleBuffer {
private:
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override {
// TODO(pbos): Implement before using this in the encoder pipeline (or
// remove the CHECK() in VideoCapture).
// remove the RTC_CHECK() in VideoCapture).
RTC_NOTREACHED();
return nullptr;
}

View File

@ -140,7 +140,7 @@ extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
if (ret < 0)
return -1;
CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
LoadGlobalClassReferenceHolder();
return ret;
@ -148,7 +148,7 @@ extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) {
FreeGlobalClassReferenceHolder();
CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
}
// Return the (singleton) Java Enum object corresponding to |index|;
@ -219,7 +219,7 @@ class PCOJava : public PeerConnectionObserver {
void OnIceCandidate(const IceCandidateInterface* candidate) override {
ScopedLocalRefFrame local_ref_frame(jni());
std::string sdp;
CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp;
RTC_CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp;
jclass candidate_class = FindClass(jni(), "org/webrtc/IceCandidate");
jmethodID ctor = GetMethodID(jni(), candidate_class,
"<init>", "(Ljava/lang/String;ILjava/lang/String;)V");
@ -308,7 +308,7 @@ class PCOJava : public PeerConnectionObserver {
"(Ljava/lang/Object;)Z");
jboolean added = jni()->CallBooleanMethod(audio_tracks, add, j_track);
CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod";
CHECK(added);
RTC_CHECK(added);
}
for (const auto& track : stream->GetVideoTracks()) {
@ -331,7 +331,7 @@ class PCOJava : public PeerConnectionObserver {
"(Ljava/lang/Object;)Z");
jboolean added = jni()->CallBooleanMethod(video_tracks, add, j_track);
CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod";
CHECK(added);
RTC_CHECK(added);
}
remote_streams_[stream] = NewGlobalRef(jni(), j_stream);
@ -344,8 +344,8 @@ class PCOJava : public PeerConnectionObserver {
void OnRemoveStream(MediaStreamInterface* stream) override {
ScopedLocalRefFrame local_ref_frame(jni());
NativeToJavaStreamsMap::iterator it = remote_streams_.find(stream);
CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex
<< stream;
RTC_CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex
<< stream;
jobject j_stream = it->second;
jmethodID m = GetMethodID(jni(), *j_observer_class_, "onRemoveStream",
"(Lorg/webrtc/MediaStream;)V");
@ -369,7 +369,7 @@ class PCOJava : public PeerConnectionObserver {
// CallVoidMethod above as Java code might call back into native code and be
// surprised to see a refcount of 2.
int bumped_count = channel->AddRef();
CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel";
RTC_CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel";
CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
}
@ -383,7 +383,7 @@ class PCOJava : public PeerConnectionObserver {
}
void SetConstraints(ConstraintsWrapper* constraints) {
CHECK(!constraints_.get()) << "constraints already set!";
RTC_CHECK(!constraints_.get()) << "constraints already set!";
constraints_.reset(constraints);
}
@ -482,7 +482,7 @@ class ConstraintsWrapper : public MediaConstraintsInterface {
static jobject JavaSdpFromNativeSdp(
JNIEnv* jni, const SessionDescriptionInterface* desc) {
std::string sdp;
CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
jstring j_description = JavaStringFromStdString(jni, sdp);
jclass j_type_class = FindClass(
@ -871,7 +871,7 @@ JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) {
JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) {
uint64 buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount();
CHECK_LE(buffered_amount, std::numeric_limits<int64>::max())
RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64>::max())
<< "buffered_amount overflowed jlong!";
return static_cast<jlong>(buffered_amount);
}
@ -903,7 +903,7 @@ JOW(void, Logging_nativeEnableTracing)(
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
if (path != "logcat:") {
#endif
CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
<< "SetTraceFile failed";
#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
} else {
@ -1087,7 +1087,7 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnectionFactory)(
worker_thread->SetName("worker_thread", NULL);
Thread* signaling_thread = new Thread();
signaling_thread->SetName("signaling_thread", NULL);
CHECK(worker_thread->Start() && signaling_thread->Start())
RTC_CHECK(worker_thread->Start() && signaling_thread->Start())
<< "Failed to start threads";
WebRtcVideoEncoderFactory* encoder_factory = nullptr;
WebRtcVideoDecoderFactory* decoder_factory = nullptr;
@ -1251,7 +1251,7 @@ JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) {
if (enum_name == "NONE")
return PeerConnectionInterface::kNone;
CHECK(false) << "Unexpected IceTransportsType enum_name " << enum_name;
RTC_CHECK(false) << "Unexpected IceTransportsType enum_name " << enum_name;
return PeerConnectionInterface::kAll;
}
@ -1270,7 +1270,7 @@ JavaBundlePolicyToNativeType(JNIEnv* jni, jobject j_bundle_policy) {
if (enum_name == "MAXCOMPAT")
return PeerConnectionInterface::kBundlePolicyMaxCompat;
CHECK(false) << "Unexpected BundlePolicy enum_name " << enum_name;
RTC_CHECK(false) << "Unexpected BundlePolicy enum_name " << enum_name;
return PeerConnectionInterface::kBundlePolicyBalanced;
}
@ -1286,7 +1286,7 @@ JavaRtcpMuxPolicyToNativeType(JNIEnv* jni, jobject j_rtcp_mux_policy) {
if (enum_name == "REQUIRE")
return PeerConnectionInterface::kRtcpMuxPolicyRequire;
CHECK(false) << "Unexpected RtcpMuxPolicy enum_name " << enum_name;
RTC_CHECK(false) << "Unexpected RtcpMuxPolicy enum_name " << enum_name;
return PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
}
@ -1303,7 +1303,7 @@ JavaTcpCandidatePolicyToNativeType(
if (enum_name == "DISABLED")
return PeerConnectionInterface::kTcpCandidatePolicyDisabled;
CHECK(false) << "Unexpected TcpCandidatePolicy enum_name " << enum_name;
RTC_CHECK(false) << "Unexpected TcpCandidatePolicy enum_name " << enum_name;
return PeerConnectionInterface::kTcpCandidatePolicyEnabled;
}
@ -1316,7 +1316,7 @@ static rtc::KeyType JavaKeyTypeToNativeType(JNIEnv* jni, jobject j_key_type) {
if (enum_name == "ECDSA")
return rtc::KT_ECDSA;
CHECK(false) << "Unexpected KeyType enum_name " << enum_name;
RTC_CHECK(false) << "Unexpected KeyType enum_name " << enum_name;
return rtc::KT_ECDSA;
}
@ -1477,7 +1477,7 @@ JOW(jobject, PeerConnection_createDataChannel)(
// vararg parameter as 64-bit and reading memory that doesn't belong to the
// 32-bit parameter.
jlong nativeChannelPtr = jlongFromPointer(channel.get());
CHECK(nativeChannelPtr) << "Failed to create DataChannel";
RTC_CHECK(nativeChannelPtr) << "Failed to create DataChannel";
jclass j_data_channel_class = FindClass(jni, "org/webrtc/DataChannel");
jmethodID j_data_channel_ctor = GetMethodID(
jni, j_data_channel_class, "<init>", "(J)V");
@ -1486,7 +1486,7 @@ JOW(jobject, PeerConnection_createDataChannel)(
CHECK_EXCEPTION(jni) << "error during NewObject";
// Channel is now owned by Java object, and will be freed from there.
int bumped_count = channel->AddRef();
CHECK(bumped_count == 2) << "Unexpected refcount";
RTC_CHECK(bumped_count == 2) << "Unexpected refcount";
return j_channel;
}
@ -1648,7 +1648,7 @@ JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)(
std::string device_name = JavaToStdString(jni, j_device_name);
scoped_ptr<cricket::DeviceManagerInterface> device_manager(
cricket::DeviceManagerFactory::Create());
CHECK(device_manager->Init()) << "DeviceManager::Init() failed";
RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed";
cricket::Device device;
if (!device_manager->GetVideoCaptureDevice(device_name, &device)) {
LOG(LS_ERROR) << "GetVideoCaptureDevice failed for " << device_name;
@ -1695,11 +1695,11 @@ JOW(void, VideoRenderer_nativeCopyPlane)(
jint src_stride, jobject j_dst_buffer, jint dst_stride) {
size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer);
size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer);
CHECK(src_stride >= width) << "Wrong source stride " << src_stride;
CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride;
CHECK(src_size >= src_stride * height)
RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride;
RTC_CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride;
RTC_CHECK(src_size >= src_stride * height)
<< "Insufficient source buffer capacity " << src_size;
CHECK(dst_size >= dst_stride * height)
RTC_CHECK(dst_size >= dst_stride * height)
<< "Isufficient destination buffer capacity " << dst_size;
uint8_t *src =
reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer));

View File

@ -42,7 +42,7 @@ class MediaController : public webrtc::MediaControllerInterface {
MediaController(rtc::Thread* worker_thread,
webrtc::VoiceEngine* voice_engine)
: worker_thread_(worker_thread) {
DCHECK(nullptr != worker_thread);
RTC_DCHECK(nullptr != worker_thread);
worker_thread_->Invoke<void>(
rtc::Bind(&MediaController::Construct_w, this, voice_engine));
}
@ -52,13 +52,13 @@ class MediaController : public webrtc::MediaControllerInterface {
}
webrtc::Call* call_w() override {
DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(worker_thread_->IsCurrent());
return call_.get();
}
private:
void Construct_w(webrtc::VoiceEngine* voice_engine) {
DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(worker_thread_->IsCurrent());
webrtc::Call::Config config;
config.voice_engine = voice_engine;
config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
@ -67,7 +67,7 @@ class MediaController : public webrtc::MediaControllerInterface {
call_.reset(webrtc::Call::Create(config));
}
void Destruct_w() {
DCHECK(worker_thread_->IsCurrent());
RTC_DCHECK(worker_thread_->IsCurrent());
call_.reset(nullptr);
}

View File

@ -109,7 +109,7 @@ NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB.
if (!_hasStarted) {
return;
}
DCHECK(_logSink);
RTC_DCHECK(_logSink);
rtc::LogMessage::RemoveLogToStream(_logSink.get());
_hasStarted = NO;
_logSink.reset();

View File

@ -336,7 +336,7 @@ cricket::CaptureState AVFoundationVideoCapturer::Start(
// Keep track of which thread capture started on. This is the thread that
// frames need to be sent to.
DCHECK(!_startThread);
RTC_DCHECK(!_startThread);
_startThread = rtc::Thread::Current();
SetCaptureFormat(&format);
@ -412,7 +412,8 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
// Sanity check assumption that planar bytes are contiguous.
uint8_t* uvPlaneAddress =
(uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, kUVPlaneIndex);
DCHECK(uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow);
RTC_DCHECK(
uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow);
// Stuff data into a cricket::CapturedFrame.
int64 currentTime = rtc::TimeNanos();
@ -439,7 +440,7 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
void AVFoundationVideoCapturer::SignalFrameCapturedOnStartThread(
const cricket::CapturedFrame* frame) {
DCHECK(_startThread->IsCurrent());
RTC_DCHECK(_startThread->IsCurrent());
// This will call a superclass method that will perform the frame conversion
// to I420.
SignalFrameCaptured(this, frame);

View File

@ -55,7 +55,7 @@ class DtlsIdentityStoreWrapper : public DtlsIdentityStoreInterface {
DtlsIdentityStoreWrapper(
const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store)
: store_(store) {
DCHECK(store_);
RTC_DCHECK(store_);
}
void RequestIdentity(
@ -151,7 +151,7 @@ PeerConnectionFactory::PeerConnectionFactory(
}
PeerConnectionFactory::~PeerConnectionFactory() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
channel_manager_.reset(nullptr);
default_allocator_factory_ = nullptr;
@ -167,7 +167,7 @@ PeerConnectionFactory::~PeerConnectionFactory() {
}
bool PeerConnectionFactory::Initialize() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::InitRandom(rtc::Time());
default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_);
@ -200,7 +200,7 @@ bool PeerConnectionFactory::Initialize() {
rtc::scoped_refptr<AudioSourceInterface>
PeerConnectionFactory::CreateAudioSource(
const MediaConstraintsInterface* constraints) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::scoped_refptr<LocalAudioSource> source(
LocalAudioSource::Create(options_, constraints));
return source;
@ -210,14 +210,14 @@ rtc::scoped_refptr<VideoSourceInterface>
PeerConnectionFactory::CreateVideoSource(
cricket::VideoCapturer* capturer,
const MediaConstraintsInterface* constraints) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::scoped_refptr<VideoSource> source(
VideoSource::Create(channel_manager_.get(), capturer, constraints));
return VideoSourceProxy::Create(signaling_thread_, source);
}
bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
return channel_manager_->StartAecDump(file);
}
@ -228,8 +228,8 @@ PeerConnectionFactory::CreatePeerConnection(
PortAllocatorFactoryInterface* allocator_factory,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
PeerConnectionObserver* observer) {
DCHECK(signaling_thread_->IsCurrent());
DCHECK(allocator_factory || default_allocator_factory_);
RTC_DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(allocator_factory || default_allocator_factory_);
if (!dtls_identity_store.get()) {
// Because |pc|->Initialize takes ownership of the store we need a new
@ -258,7 +258,7 @@ PeerConnectionFactory::CreatePeerConnection(
rtc::scoped_refptr<MediaStreamInterface>
PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
return MediaStreamProxy::Create(signaling_thread_,
MediaStream::Create(label));
}
@ -267,7 +267,7 @@ rtc::scoped_refptr<VideoTrackInterface>
PeerConnectionFactory::CreateVideoTrack(
const std::string& id,
VideoSourceInterface* source) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::scoped_refptr<VideoTrackInterface> track(
VideoTrack::Create(id, source));
return VideoTrackProxy::Create(signaling_thread_, track);
@ -276,14 +276,14 @@ PeerConnectionFactory::CreateVideoTrack(
rtc::scoped_refptr<AudioTrackInterface>
PeerConnectionFactory::CreateAudioTrack(const std::string& id,
AudioSourceInterface* source) {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::scoped_refptr<AudioTrackInterface> track(
AudioTrack::Create(id, source));
return AudioTrackProxy::Create(signaling_thread_, track);
}
cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
return channel_manager_.get();
}
@ -294,7 +294,7 @@ rtc::Thread* PeerConnectionFactory::signaling_thread() {
}
rtc::Thread* PeerConnectionFactory::worker_thread() {
DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
return worker_thread_;
}

View File

@ -71,7 +71,7 @@ typedef TypeForAdd<int> IntForAdd;
StatsReport::Id GetTransportIdFromProxy(const cricket::ProxyTransportMap& map,
const std::string& proxy) {
DCHECK(!proxy.empty());
RTC_DCHECK(!proxy.empty());
cricket::ProxyTransportMap::const_iterator found = map.find(proxy);
if (found == map.end())
return StatsReport::Id();
@ -96,7 +96,7 @@ void CreateTrackReports(const TrackVector& tracks, StatsCollection* reports,
for (const auto& track : tracks) {
const std::string& track_id = track->id();
StatsReport* report = AddTrackReport(reports, track_id);
DCHECK(report != nullptr);
RTC_DCHECK(report != nullptr);
track_ids[track_id] = report;
}
}
@ -261,7 +261,7 @@ void ExtractStats(const cricket::BandwidthEstimationInfo& info,
double stats_gathering_started,
PeerConnectionInterface::StatsOutputLevel level,
StatsReport* report) {
DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
report->set_timestamp(stats_gathering_started);
const IntForAdd ints[] = {
@ -332,7 +332,7 @@ const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
if (candidate_type == cricket::RELAY_PORT_TYPE) {
return STATSREPORT_RELAY_PORT_TYPE;
}
DCHECK(false);
RTC_DCHECK(false);
return "unknown";
}
@ -351,7 +351,7 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
case rtc::ADAPTER_TYPE_LOOPBACK:
return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
default:
DCHECK(false);
RTC_DCHECK(false);
return "";
}
}
@ -359,11 +359,11 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
StatsCollector::StatsCollector(WebRtcSession* session)
: session_(session),
stats_gathering_started_(0) {
DCHECK(session_);
RTC_DCHECK(session_);
}
StatsCollector::~StatsCollector() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
}
double StatsCollector::GetTimeNow() {
@ -373,8 +373,8 @@ double StatsCollector::GetTimeNow() {
// Adds a MediaStream with tracks that can be used as a |selector| in a call
// to GetStats.
void StatsCollector::AddStream(MediaStreamInterface* stream) {
DCHECK(session_->signaling_thread()->IsCurrent());
DCHECK(stream != NULL);
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(stream != NULL);
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
&reports_, track_ids_);
@ -384,11 +384,11 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32 ssrc) {
DCHECK(session_->signaling_thread()->IsCurrent());
DCHECK(audio_track != NULL);
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(audio_track != NULL);
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
for (const auto& track : local_audio_tracks_)
DCHECK(track.first != audio_track || track.second != ssrc);
RTC_DCHECK(track.first != audio_track || track.second != ssrc);
#endif
local_audio_tracks_.push_back(std::make_pair(audio_track, ssrc));
@ -406,7 +406,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
uint32 ssrc) {
DCHECK(audio_track != NULL);
RTC_DCHECK(audio_track != NULL);
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
local_audio_tracks_.end(),
[audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
@ -416,9 +416,9 @@ void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
StatsReports* reports) {
DCHECK(session_->signaling_thread()->IsCurrent());
DCHECK(reports != NULL);
DCHECK(reports->empty());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(reports != NULL);
RTC_DCHECK(reports->empty());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@ -456,7 +456,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
void
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
double time_now = GetTimeNow();
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
// ms apart will be ignored.
@ -487,7 +487,7 @@ StatsReport* StatsCollector::PrepareReport(
uint32 ssrc,
const StatsReport::Id& transport_id,
StatsReport::Direction direction) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
StatsReport::Id id(StatsReport::NewIdWithDirection(
local ? StatsReport::kStatsReportTypeSsrc :
StatsReport::kStatsReportTypeRemoteSsrc,
@ -526,7 +526,7 @@ StatsReport* StatsCollector::PrepareReport(
StatsReport* StatsCollector::AddOneCertificateReport(
const rtc::SSLCertificate* cert, const StatsReport* issuer) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
// TODO(bemasc): Move this computation to a helper class that caches these
// values to reduce CPU use in GetStats. This will require adding a fast
@ -569,13 +569,13 @@ StatsReport* StatsCollector::AddOneCertificateReport(
StatsReport* StatsCollector::AddCertificateReports(
const rtc::SSLCertificate* cert) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
// Produces a chain of StatsReports representing this certificate and the rest
// of its chain, and adds those reports to |reports_|. The return value is
// the id of the leaf report. The provided cert must be non-null, so at least
// one report will always be provided and the returned string will never be
// empty.
DCHECK(cert != NULL);
RTC_DCHECK(cert != NULL);
StatsReport* issuer = nullptr;
rtc::scoped_ptr<rtc::SSLCertChain> chain;
@ -669,7 +669,7 @@ StatsReport* StatsCollector::AddCandidateReport(
}
void StatsCollector::ExtractSessionInfo() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
// Extract information from the base session.
StatsReport::Id id(StatsReport::NewTypedId(
@ -763,7 +763,7 @@ void StatsCollector::ExtractSessionInfo() {
}
void StatsCollector::ExtractVoiceInfo() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
if (!session_->voice_channel()) {
return;
@ -796,7 +796,7 @@ void StatsCollector::ExtractVoiceInfo() {
void StatsCollector::ExtractVideoInfo(
PeerConnectionInterface::StatsOutputLevel level) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
if (!session_->video_channel())
return;
@ -833,7 +833,7 @@ void StatsCollector::ExtractVideoInfo(
}
void StatsCollector::ExtractDataInfo() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@ -854,14 +854,14 @@ void StatsCollector::ExtractDataInfo() {
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
const std::string& id,
StatsReport::Direction direction) {
DCHECK(session_->signaling_thread()->IsCurrent());
DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
type == StatsReport::kStatsReportTypeRemoteSsrc);
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
type == StatsReport::kStatsReportTypeRemoteSsrc);
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
}
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
// Loop through the existing local audio tracks.
for (const auto& it : local_audio_tracks_) {
AudioTrackInterface* track = it.first;
@ -889,8 +889,8 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
StatsReport* report) {
DCHECK(session_->signaling_thread()->IsCurrent());
DCHECK(track != NULL);
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(track != NULL);
int signal_level = 0;
if (!track->GetSignalLevel(&signal_level))
@ -911,7 +911,7 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
StatsReport::Direction direction) {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
if (direction == StatsReport::kSend) {
if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
@ -919,7 +919,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
return false;
}
} else {
DCHECK(direction == StatsReport::kReceive);
RTC_DCHECK(direction == StatsReport::kReceive);
if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a receiving track";
@ -931,7 +931,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
}
void StatsCollector::UpdateTrackReports() {
DCHECK(session_->signaling_thread()->IsCurrent());
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;

View File

@ -32,7 +32,7 @@
#include "webrtc/base/checks.h"
// TODO(tommi): Could we have a static map of value name -> expected type
// and use this to DCHECK on correct usage (somewhat strongly typed values)?
// and use this to RTC_DCHECK on correct usage (somewhat strongly typed values)?
// Alternatively, we could define the names+type in a separate document and
// generate strongly typed inline C++ code that forces the correct type to be
// used for a given name at compile time.
@ -74,7 +74,7 @@ const char* InternalTypeToString(StatsReport::StatsType type) {
case StatsReport::kStatsReportTypeDataChannel:
return "datachannel";
}
DCHECK(false);
RTC_DCHECK(false);
return nullptr;
}
@ -231,7 +231,7 @@ bool StatsReport::IdBase::Equals(const IdBase& other) const {
StatsReport::Value::Value(StatsValueName name, int64 value, Type int_type)
: name(name), type_(int_type) {
DCHECK(type_ == kInt || type_ == kInt64);
RTC_DCHECK(type_ == kInt || type_ == kInt64);
type_ == kInt ? value_.int_ = static_cast<int>(value) : value_.int64_ = value;
}
@ -283,7 +283,7 @@ bool StatsReport::Value::Equals(const Value& other) const {
// There's a 1:1 relation between a name and a type, so we don't have to
// check that.
DCHECK_EQ(type_, other.type_);
RTC_DCHECK_EQ(type_, other.type_);
switch (type_) {
case kInt:
@ -295,7 +295,8 @@ bool StatsReport::Value::Equals(const Value& other) const {
case kStaticString: {
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
if (value_.static_string_ != other.value_.static_string_) {
DCHECK(strcmp(value_.static_string_, other.value_.static_string_) != 0)
RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) !=
0)
<< "Duplicate global?";
}
#endif
@ -324,7 +325,8 @@ bool StatsReport::Value::operator==(const char* value) const {
return false;
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
if (value_.static_string_ != value)
DCHECK(strcmp(value_.static_string_, value) != 0) << "Duplicate global?";
RTC_DCHECK(strcmp(value_.static_string_, value) != 0)
<< "Duplicate global?";
#endif
return value == value_.static_string_;
}
@ -347,32 +349,32 @@ bool StatsReport::Value::operator==(const Id& value) const {
}
int StatsReport::Value::int_val() const {
DCHECK(type_ == kInt);
RTC_DCHECK(type_ == kInt);
return value_.int_;
}
int64 StatsReport::Value::int64_val() const {
DCHECK(type_ == kInt64);
RTC_DCHECK(type_ == kInt64);
return value_.int64_;
}
float StatsReport::Value::float_val() const {
DCHECK(type_ == kFloat);
RTC_DCHECK(type_ == kFloat);
return value_.float_;
}
const char* StatsReport::Value::static_string_val() const {
DCHECK(type_ == kStaticString);
RTC_DCHECK(type_ == kStaticString);
return value_.static_string_;
}
const std::string& StatsReport::Value::string_val() const {
DCHECK(type_ == kString);
RTC_DCHECK(type_ == kString);
return *value_.string_;
}
bool StatsReport::Value::bool_val() const {
DCHECK(type_ == kBool);
RTC_DCHECK(type_ == kBool);
return value_.bool_;
}
@ -591,7 +593,7 @@ const char* StatsReport::Value::display_name() const {
case kStatsValueNameWritable:
return "googWritable";
default:
DCHECK(false);
RTC_DCHECK(false);
break;
}
@ -620,7 +622,7 @@ std::string StatsReport::Value::ToString() const {
}
StatsReport::StatsReport(const Id& id) : id_(id), timestamp_(0.0) {
DCHECK(id_.get());
RTC_DCHECK(id_.get());
}
// static
@ -720,43 +722,43 @@ StatsCollection::StatsCollection() {
}
StatsCollection::~StatsCollection() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
for (auto* r : list_)
delete r;
}
StatsCollection::const_iterator StatsCollection::begin() const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return list_.begin();
}
StatsCollection::const_iterator StatsCollection::end() const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return list_.end();
}
size_t StatsCollection::size() const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return list_.size();
}
StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(Find(id) == nullptr);
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(Find(id) == nullptr);
StatsReport* report = new StatsReport(id);
list_.push_back(report);
return report;
}
StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
StatsReport* ret = Find(id);
return ret ? ret : InsertNew(id);
}
StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(id.get());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(id.get());
Container::iterator it = std::find_if(list_.begin(), list_.end(),
[&id](const StatsReport* r)->bool { return r->id()->Equals(id); });
if (it != end()) {
@ -771,7 +773,7 @@ StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) {
// Looks for a report with the given |id|. If one is not found, NULL
// will be returned.
StatsReport* StatsCollection::Find(const StatsReport::Id& id) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
Container::iterator it = std::find_if(list_.begin(), list_.end(),
[&id](const StatsReport* r)->bool { return r->id()->Equals(id); });
return it == list_.end() ? nullptr : *it;

View File

@ -82,7 +82,7 @@ class FakeDtlsIdentityStore : public webrtc::DtlsIdentityStoreInterface,
const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>&
observer) override {
// TODO(hbos): Should be able to generate KT_ECDSA too.
DCHECK(key_type == rtc::KT_RSA || should_fail_);
RTC_DCHECK(key_type == rtc::KT_RSA || should_fail_);
MessageData* msg = new MessageData(
rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer));
rtc::Thread::Current()->Post(

View File

@ -746,7 +746,7 @@ bool WebRtcSession::Initialize(
// Construct with DTLS enabled.
if (!certificate) {
// Use the |dtls_identity_store| to generate a certificate.
DCHECK(dtls_identity_store);
RTC_DCHECK(dtls_identity_store);
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
signaling_thread(),
channel_manager_,
@ -2006,7 +2006,7 @@ bool WebRtcSession::ReadyToUseRemoteCandidate(
// for IPv4 and IPv6.
void WebRtcSession::ReportBestConnectionState(
const cricket::TransportStats& stats) {
DCHECK(metrics_observer_ != NULL);
RTC_DCHECK(metrics_observer_ != NULL);
for (cricket::TransportChannelStatsList::const_iterator it =
stats.channel_stats.begin();
it != stats.channel_stats.end(); ++it) {
@ -2029,7 +2029,7 @@ void WebRtcSession::ReportBestConnectionState(
} else if (local.protocol() == cricket::UDP_PROTOCOL_NAME) {
type = kEnumCounterIceCandidatePairTypeUdp;
} else {
CHECK(0);
RTC_CHECK(0);
}
metrics_observer_->IncrementEnumCounter(
type, GetIceCandidatePairCounter(local, remote),
@ -2046,7 +2046,7 @@ void WebRtcSession::ReportBestConnectionState(
kEnumCounterAddressFamily, kBestConnections_IPv6,
kPeerConnectionAddressFamilyCounter_Max);
} else {
CHECK(0);
RTC_CHECK(0);
}
return;
@ -2056,7 +2056,7 @@ void WebRtcSession::ReportBestConnectionState(
void WebRtcSession::ReportNegotiatedCiphers(
const cricket::TransportStats& stats) {
DCHECK(metrics_observer_ != NULL);
RTC_DCHECK(metrics_observer_ != NULL);
if (!dtls_enabled_ || stats.channel_stats.empty()) {
return;
}

View File

@ -424,7 +424,7 @@ class WebRtcSessionTest
dtls_identity_store.reset(new FakeDtlsIdentityStore());
dtls_identity_store->set_should_fail(false);
} else {
CHECK(false);
RTC_CHECK(false);
}
Init(dtls_identity_store.Pass(), configuration);
}
@ -1237,7 +1237,7 @@ class WebRtcSessionTest
void VerifyMultipleAsyncCreateDescriptionAfterInit(
bool success, CreateSessionDescriptionRequest::Type type) {
CHECK(session_);
RTC_CHECK(session_);
SetFactoryDtlsSrtp();
if (type == CreateSessionDescriptionRequest::kAnswer) {
cricket::MediaSessionOptions options;

View File

@ -190,7 +190,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
session_id,
dct,
true) {
DCHECK(dtls_identity_store_);
RTC_DCHECK(dtls_identity_store_);
certificate_request_state_ = CERTIFICATE_WAITING;
@ -219,7 +219,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
: WebRtcSessionDescriptionFactory(
signaling_thread, channel_manager, mediastream_signaling, nullptr,
nullptr, session, session_id, dct, true) {
DCHECK(certificate);
RTC_DCHECK(certificate);
certificate_request_state_ = CERTIFICATE_WAITING;
@ -517,7 +517,7 @@ void WebRtcSessionDescriptionFactory::OnIdentityRequestFailed(int error) {
void WebRtcSessionDescriptionFactory::SetCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
DCHECK(certificate);
RTC_DCHECK(certificate);
LOG(LS_VERBOSE) << "Setting new certificate";
certificate_request_state_ = CERTIFICATE_SUCCEEDED;

View File

@ -51,16 +51,16 @@ class VideoCapturerState {
int IncCaptureStartRef();
int DecCaptureStartRef();
CaptureRenderAdapter* adapter() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return adapter_.get();
}
VideoCapturer* GetVideoCapturer() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return adapter()->video_capturer();
}
int start_count() const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return start_count_;
}
@ -98,7 +98,7 @@ VideoCapturerState* VideoCapturerState::Create(VideoCapturer* video_capturer) {
void VideoCapturerState::AddCaptureResolution(
const VideoFormat& desired_format) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
for (CaptureFormats::iterator iter = capture_formats_.begin();
iter != capture_formats_.end(); ++iter) {
if (desired_format == iter->video_format) {
@ -111,7 +111,7 @@ void VideoCapturerState::AddCaptureResolution(
}
bool VideoCapturerState::RemoveCaptureResolution(const VideoFormat& format) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
for (CaptureFormats::iterator iter = capture_formats_.begin();
iter != capture_formats_.end(); ++iter) {
if (format == iter->video_format) {
@ -127,7 +127,7 @@ bool VideoCapturerState::RemoveCaptureResolution(const VideoFormat& format) {
VideoFormat VideoCapturerState::GetHighestFormat(
VideoCapturer* video_capturer) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoFormat highest_format(0, 0, VideoFormat::FpsToInterval(1), FOURCC_ANY);
if (capture_formats_.empty()) {
VideoFormat default_format(kDefaultCaptureFormat);
@ -149,12 +149,12 @@ VideoFormat VideoCapturerState::GetHighestFormat(
}
int VideoCapturerState::IncCaptureStartRef() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return ++start_count_;
}
int VideoCapturerState::DecCaptureStartRef() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (start_count_ > 0) {
// Start count may be 0 if a capturer was added but never started.
--start_count_;
@ -169,20 +169,20 @@ CaptureManager::CaptureManager() {
}
CaptureManager::~CaptureManager() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
// Since we don't own any of the capturers, all capturers should have been
// cleaned up before we get here. In fact, in the normal shutdown sequence,
// all capturers *will* be shut down by now, so trying to stop them here
// will crash. If we're still tracking any, it's a dangling pointer.
// TODO(hbos): DCHECK instead of CHECK until we figure out why capture_states_
// is not always empty here.
DCHECK(capture_states_.empty());
// TODO(hbos): RTC_DCHECK instead of RTC_CHECK until we figure out why
// capture_states_ is not always empty here.
RTC_DCHECK(capture_states_.empty());
}
bool CaptureManager::StartVideoCapture(VideoCapturer* video_capturer,
const VideoFormat& desired_format) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (desired_format.width == 0 || desired_format.height == 0) {
return false;
}
@ -215,7 +215,7 @@ bool CaptureManager::StartVideoCapture(VideoCapturer* video_capturer,
bool CaptureManager::StopVideoCapture(VideoCapturer* video_capturer,
const VideoFormat& format) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoCapturerState* capture_state = GetCaptureState(video_capturer);
if (!capture_state) {
return false;
@ -236,7 +236,7 @@ bool CaptureManager::RestartVideoCapture(
const VideoFormat& previous_format,
const VideoFormat& desired_format,
CaptureManager::RestartOptions options) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!IsCapturerRegistered(video_capturer)) {
LOG(LS_ERROR) << "RestartVideoCapture: video_capturer is not registered.";
return false;
@ -289,7 +289,7 @@ bool CaptureManager::RestartVideoCapture(
bool CaptureManager::AddVideoRenderer(VideoCapturer* video_capturer,
VideoRenderer* video_renderer) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!video_capturer || !video_renderer) {
return false;
}
@ -302,7 +302,7 @@ bool CaptureManager::AddVideoRenderer(VideoCapturer* video_capturer,
bool CaptureManager::RemoveVideoRenderer(VideoCapturer* video_capturer,
VideoRenderer* video_renderer) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!video_capturer || !video_renderer) {
return false;
}
@ -314,12 +314,12 @@ bool CaptureManager::RemoveVideoRenderer(VideoCapturer* video_capturer,
}
bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return GetCaptureState(video_capturer) != NULL;
}
bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoCapturerState* capture_state =
VideoCapturerState::Create(video_capturer);
if (!capture_state) {
@ -332,7 +332,7 @@ bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) {
void CaptureManager::UnregisterVideoCapturer(
VideoCapturerState* capture_state) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoCapturer* video_capturer = capture_state->GetVideoCapturer();
capture_states_.erase(video_capturer);
delete capture_state;
@ -357,7 +357,7 @@ void CaptureManager::UnregisterVideoCapturer(
bool CaptureManager::StartWithBestCaptureFormat(
VideoCapturerState* capture_state, VideoCapturer* video_capturer) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoFormat highest_asked_format =
capture_state->GetHighestFormat(video_capturer);
VideoFormat capture_format;
@ -384,7 +384,7 @@ bool CaptureManager::StartWithBestCaptureFormat(
VideoCapturerState* CaptureManager::GetCaptureState(
VideoCapturer* video_capturer) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
CaptureStates::const_iterator iter = capture_states_.find(video_capturer);
if (iter == capture_states_.end()) {
return NULL;
@ -394,7 +394,7 @@ VideoCapturerState* CaptureManager::GetCaptureState(
CaptureRenderAdapter* CaptureManager::GetAdapter(
VideoCapturer* video_capturer) const {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
VideoCapturerState* capture_state = GetCaptureState(video_capturer);
if (!capture_state) {
return NULL;

View File

@ -377,7 +377,7 @@ SctpDataMediaChannel::~SctpDataMediaChannel() {
}
void SctpDataMediaChannel::OnSendThresholdCallback() {
DCHECK(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
SignalReadyToSend(true);
}
@ -658,7 +658,7 @@ bool SctpDataMediaChannel::SendData(
// Called by network interface when a packet has been received.
void SctpDataMediaChannel::OnPacketReceived(
rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
DCHECK(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
LOG(LS_VERBOSE) << debug_name_ << "->OnPacketReceived(...): "
<< " length=" << packet->size() << ", sending: " << sending_;
// Only give receiving packets to usrsctp after if connected. This enables two

View File

@ -37,7 +37,7 @@ namespace cricket {
FakeAudioReceiveStream::FakeAudioReceiveStream(
const webrtc::AudioReceiveStream::Config& config)
: config_(config), received_packets_(0) {
DCHECK(config.voe_channel_id != -1);
RTC_DCHECK(config.voe_channel_id != -1);
}
webrtc::AudioReceiveStream::Stats FakeAudioReceiveStream::GetStats() const {
@ -60,7 +60,7 @@ FakeVideoSendStream::FakeVideoSendStream(
config_(config),
codec_settings_set_(false),
num_swapped_frames_(0) {
DCHECK(config.encoder_settings.encoder != NULL);
RTC_DCHECK(config.encoder_settings.encoder != NULL);
ReconfigureVideoEncoder(encoder_config);
}
@ -113,7 +113,7 @@ int FakeVideoSendStream::GetLastHeight() const {
}
int64_t FakeVideoSendStream::GetLastTimestamp() const {
DCHECK(last_frame_.ntp_time_ms() == 0);
RTC_DCHECK(last_frame_.ntp_time_ms() == 0);
return last_frame_.render_time_ms();
}

View File

@ -89,7 +89,7 @@ static const webrtc::NetworkStatistics kNetStats = {
if (channels_.find(channel) == channels_.end()) return -1;
#define WEBRTC_ASSERT_CHANNEL(channel) \
DCHECK(channels_.find(channel) != channels_.end());
RTC_DCHECK(channels_.find(channel) != channels_.end());
// Verify the header extension ID, if enabled, is within the bounds specified in
// [RFC5285]: 1-14 inclusive.
@ -383,7 +383,7 @@ class FakeWebRtcVoiceEngine
return channels_[channel]->packets.empty();
}
void TriggerCallbackOnError(int channel_num, int err_code) {
DCHECK(observer_ != NULL);
RTC_DCHECK(observer_ != NULL);
observer_->CallbackOnError(channel_num, err_code);
}
void set_playout_fail_channel(int channel) {

View File

@ -152,7 +152,7 @@ WebRtcVideoCapturer::~WebRtcVideoCapturer() {
}
bool WebRtcVideoCapturer::Init(const Device& device) {
DCHECK(!start_thread_);
RTC_DCHECK(!start_thread_);
if (module_) {
LOG(LS_ERROR) << "The capturer is already initialized";
return false;
@ -226,7 +226,7 @@ bool WebRtcVideoCapturer::Init(const Device& device) {
}
bool WebRtcVideoCapturer::Init(webrtc::VideoCaptureModule* module) {
DCHECK(!start_thread_);
RTC_DCHECK(!start_thread_);
if (module_) {
LOG(LS_ERROR) << "The capturer is already initialized";
return false;
@ -263,7 +263,7 @@ bool WebRtcVideoCapturer::SetApplyRotation(bool enable) {
// Can't take lock here as this will cause deadlock with
// OnIncomingCapturedFrame. In fact, the whole method, including methods it
// calls, can't take lock.
DCHECK(module_);
RTC_DCHECK(module_);
const std::string group_name =
webrtc::field_trial::FindFullName("WebRTC-CVO");
@ -285,13 +285,13 @@ CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) {
}
if (start_thread_) {
LOG(LS_ERROR) << "The capturer is already running";
DCHECK(start_thread_->IsCurrent())
RTC_DCHECK(start_thread_->IsCurrent())
<< "Trying to start capturer on different threads";
return CS_FAILED;
}
start_thread_ = rtc::Thread::Current();
DCHECK(!async_invoker_);
RTC_DCHECK(!async_invoker_);
async_invoker_.reset(new rtc::AsyncInvoker());
captured_frames_ = 0;
@ -327,9 +327,9 @@ void WebRtcVideoCapturer::Stop() {
LOG(LS_ERROR) << "The capturer is already stopped";
return;
}
DCHECK(start_thread_);
DCHECK(start_thread_->IsCurrent());
DCHECK(async_invoker_);
RTC_DCHECK(start_thread_);
RTC_DCHECK(start_thread_->IsCurrent());
RTC_DCHECK(async_invoker_);
if (IsRunning()) {
// The module is responsible for OnIncomingCapturedFrame being called, if
// we stop it we will get no further callbacks.
@ -372,8 +372,8 @@ void WebRtcVideoCapturer::OnIncomingCapturedFrame(
const int32_t id,
const webrtc::VideoFrame& sample) {
// This can only happen between Start() and Stop().
DCHECK(start_thread_);
DCHECK(async_invoker_);
RTC_DCHECK(start_thread_);
RTC_DCHECK(async_invoker_);
if (start_thread_->IsCurrent()) {
SignalFrameCapturedOnStartThread(sample);
} else {
@ -398,9 +398,9 @@ void WebRtcVideoCapturer::OnCaptureDelayChanged(const int32_t id,
void WebRtcVideoCapturer::SignalFrameCapturedOnStartThread(
const webrtc::VideoFrame frame) {
// This can only happen between Start() and Stop().
DCHECK(start_thread_);
DCHECK(start_thread_->IsCurrent());
DCHECK(async_invoker_);
RTC_DCHECK(start_thread_);
RTC_DCHECK(start_thread_->IsCurrent());
RTC_DCHECK(async_invoker_);
++captured_frames_;
// Log the size and pixel aspect ratio of the first captured frame.

View File

@ -106,7 +106,7 @@ class WebRtcSimulcastEncoderFactory
webrtc::VideoEncoder* CreateVideoEncoder(
webrtc::VideoCodecType type) override {
DCHECK(factory_ != NULL);
RTC_DCHECK(factory_ != NULL);
// If it's a codec type we can simulcast, create a wrapped encoder.
if (type == webrtc::kVideoCodecVP8) {
return new webrtc::SimulcastEncoderAdapter(
@ -600,7 +600,7 @@ bool WebRtcVideoEngine2::SetDefaultEncoderConfig(
WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel(
webrtc::Call* call,
const VideoOptions& options) {
DCHECK(initialized_);
RTC_DCHECK(initialized_);
LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString();
WebRtcVideoChannel2* channel = new WebRtcVideoChannel2(call, options,
external_encoder_factory_, external_decoder_factory_);
@ -622,20 +622,20 @@ void WebRtcVideoEngine2::SetLogging(int min_sev, const char* filter) {
LOG(LS_VERBOSE) << "SetLogging: " << min_sev << '"' << filter << '"';
// if min_sev == -1, we keep the current log level.
if (min_sev < 0) {
DCHECK(min_sev == -1);
RTC_DCHECK(min_sev == -1);
return;
}
}
void WebRtcVideoEngine2::SetExternalDecoderFactory(
WebRtcVideoDecoderFactory* decoder_factory) {
DCHECK(!initialized_);
RTC_DCHECK(!initialized_);
external_decoder_factory_ = decoder_factory;
}
void WebRtcVideoEngine2::SetExternalEncoderFactory(
WebRtcVideoEncoderFactory* encoder_factory) {
DCHECK(!initialized_);
RTC_DCHECK(!initialized_);
if (external_encoder_factory_ == encoder_factory)
return;
@ -681,7 +681,7 @@ bool WebRtcVideoEngine2::FindCodec(const VideoCodec& in) {
bool WebRtcVideoEngine2::CanSendCodec(const VideoCodec& requested,
const VideoCodec& current,
VideoCodec* out) {
DCHECK(out != NULL);
RTC_DCHECK(out != NULL);
if (requested.width != requested.height &&
(requested.height == 0 || requested.width == 0)) {
@ -747,7 +747,7 @@ std::vector<VideoCodec> WebRtcVideoEngine2::GetSupportedCodecs() const {
// we only support up to 8 external payload types.
const int kExternalVideoPayloadTypeBase = 120;
size_t payload_type = kExternalVideoPayloadTypeBase + i;
DCHECK(payload_type < 128);
RTC_DCHECK(payload_type < 128);
VideoCodec codec(static_cast<int>(payload_type),
codecs[i].name,
codecs[i].max_width,
@ -770,7 +770,7 @@ WebRtcVideoChannel2::WebRtcVideoChannel2(
unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
external_encoder_factory_(external_encoder_factory),
external_decoder_factory_(external_decoder_factory) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
SetDefaultOptions();
options_.SetAll(options);
options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_);
@ -963,13 +963,13 @@ bool WebRtcVideoChannel2::SetSendCodecs(const std::vector<VideoCodec>& codecs) {
LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different "
"first supported codec.";
for (auto& kv : send_streams_) {
DCHECK(kv.second != nullptr);
RTC_DCHECK(kv.second != nullptr);
kv.second->SetCodec(supported_codecs.front());
}
LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send "
"codec has changed.";
for (auto& kv : receive_streams_) {
DCHECK(kv.second != nullptr);
RTC_DCHECK(kv.second != nullptr);
kv.second->SetNackAndRemb(HasNack(supported_codecs.front().codec),
HasRemb(supported_codecs.front().codec));
}
@ -1108,7 +1108,7 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) {
send_rtp_extensions_);
uint32 ssrc = sp.first_ssrc();
DCHECK(ssrc != 0);
RTC_DCHECK(ssrc != 0);
send_streams_[ssrc] = stream;
if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
@ -1179,7 +1179,7 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp) {
bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp,
bool default_stream) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
LOG(LS_INFO) << "AddRecvStream" << (default_stream ? " (default stream)" : "")
<< ": " << sp.ToString();
@ -1187,7 +1187,7 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp,
return false;
uint32 ssrc = sp.first_ssrc();
DCHECK(ssrc != 0); // TODO(pbos): Is this ever valid?
RTC_DCHECK(ssrc != 0); // TODO(pbos): Is this ever valid?
rtc::CritScope stream_lock(&stream_crit_);
// Remove running stream if this was a default stream.
@ -1376,7 +1376,7 @@ void WebRtcVideoChannel2::FillBandwidthEstimationStats(
bool WebRtcVideoChannel2::SetCapturer(uint32 ssrc, VideoCapturer* capturer) {
LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> "
<< (capturer != NULL ? "(capturer)" : "NULL");
DCHECK(ssrc != 0);
RTC_DCHECK(ssrc != 0);
{
rtc::CritScope stream_lock(&stream_crit_);
if (send_streams_.find(ssrc) == send_streams_.end()) {
@ -1491,7 +1491,7 @@ void WebRtcVideoChannel2::OnReadyToSend(bool ready) {
bool WebRtcVideoChannel2::MuteStream(uint32 ssrc, bool mute) {
LOG(LS_VERBOSE) << "MuteStream: " << ssrc << " -> "
<< (mute ? "mute" : "unmute");
DCHECK(ssrc != 0);
RTC_DCHECK(ssrc != 0);
rtc::CritScope stream_lock(&stream_crit_);
if (send_streams_.find(ssrc) == send_streams_.end()) {
LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc;
@ -1794,7 +1794,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::InputFrame(
return;
if (format_.width == 0) { // Dropping frames.
DCHECK(format_.height == 0);
RTC_DCHECK(format_.height == 0);
LOG(LS_VERBOSE) << "VideoFormat 0x0 set, Dropping frame.";
return;
}
@ -1988,7 +1988,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder(
// This shouldn't happen, we should not be trying to create something we don't
// support.
DCHECK(false);
RTC_DCHECK(false);
return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false);
}
@ -2143,7 +2143,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions(
last_dimensions_.height = height;
last_dimensions_.is_screencast = is_screencast;
DCHECK(!parameters_.encoder_config.streams.empty());
RTC_DCHECK(!parameters_.encoder_config.streams.empty());
VideoCodecSettings codec_settings;
parameters_.codec_settings.Get(&codec_settings);
@ -2169,7 +2169,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions(
void WebRtcVideoChannel2::WebRtcVideoSendStream::Start() {
rtc::CritScope cs(&lock_);
DCHECK(stream_ != NULL);
RTC_DCHECK(stream_ != NULL);
stream_->Start();
sending_ = true;
}
@ -2420,7 +2420,7 @@ WebRtcVideoChannel2::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder(
// This shouldn't happen, we should not be trying to create something we don't
// support.
DCHECK(false);
RTC_DCHECK(false);
return AllocatedDecoder(NULL, webrtc::kVideoCodecUnknown, false);
}
@ -2454,10 +2454,10 @@ void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRecvCodecs(
void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc(
uint32_t local_ssrc) {
// TODO(pbos): Consider turning this sanity check into a DCHECK. You should
// not be able to create a sender with the same SSRC as a receiver, but right
// now this can't be done due to unittests depending on receiving what they
// are sending from the same MediaChannel.
// TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You
// should not be able to create a sender with the same SSRC as a receiver, but
// right now this can't be done due to unittests depending on receiving what
// they are sending from the same MediaChannel.
if (local_ssrc == config_.rtp.remote_ssrc) {
LOG(LS_INFO) << "Ignoring call to SetLocalSsrc because parameters are "
"unchanged; local_ssrc=" << local_ssrc;
@ -2652,7 +2652,7 @@ bool WebRtcVideoChannel2::VideoCodecSettings::operator!=(
std::vector<WebRtcVideoChannel2::VideoCodecSettings>
WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) {
DCHECK(!codecs.empty());
RTC_DCHECK(!codecs.empty());
std::vector<VideoCodecSettings> video_codecs;
std::map<int, bool> payload_used;
@ -2677,14 +2677,14 @@ WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) {
switch (in_codec.GetCodecType()) {
case VideoCodec::CODEC_RED: {
// RED payload type, should not have duplicates.
DCHECK(fec_settings.red_payload_type == -1);
RTC_DCHECK(fec_settings.red_payload_type == -1);
fec_settings.red_payload_type = in_codec.id;
continue;
}
case VideoCodec::CODEC_ULPFEC: {
// ULPFEC payload type, should not have duplicates.
DCHECK(fec_settings.ulpfec_payload_type == -1);
RTC_DCHECK(fec_settings.ulpfec_payload_type == -1);
fec_settings.ulpfec_payload_type = in_codec.id;
continue;
}
@ -2713,7 +2713,7 @@ WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) {
// One of these codecs should have been a video codec. Only having FEC
// parameters into this code is a logic error.
DCHECK(!video_codecs.empty());
RTC_DCHECK(!video_codecs.empty());
for (std::map<int, int>::const_iterator it = rtx_mapping.begin();
it != rtx_mapping.end();

View File

@ -113,7 +113,7 @@ class WebRtcVideoEngine2Test : public ::testing::Test {
: call_(webrtc::Call::Create(webrtc::Call::Config())),
engine_() {
std::vector<VideoCodec> engine_codecs = engine_.codecs();
DCHECK(!engine_codecs.empty());
RTC_DCHECK(!engine_codecs.empty());
bool codec_set = false;
for (size_t i = 0; i < engine_codecs.size(); ++i) {
if (engine_codecs[i].name == "red") {
@ -132,7 +132,7 @@ class WebRtcVideoEngine2Test : public ::testing::Test {
}
}
DCHECK(codec_set);
RTC_DCHECK(codec_set);
}
protected:
@ -2982,7 +2982,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
ASSERT_TRUE(channel_->SetSendCodecs(codecs));
std::vector<uint32> ssrcs = MAKE_VECTOR(kSsrcs3);
DCHECK(num_configured_streams <= ssrcs.size());
RTC_DCHECK(num_configured_streams <= ssrcs.size());
ssrcs.resize(num_configured_streams);
FakeVideoSendStream* stream =

View File

@ -177,7 +177,7 @@ VideoFrame* WebRtcVideoFrame::Copy() const {
}
bool WebRtcVideoFrame::MakeExclusive() {
DCHECK(video_frame_buffer_->native_handle() == nullptr);
RTC_DCHECK(video_frame_buffer_->native_handle() == nullptr);
if (IsExclusive())
return true;
@ -202,8 +202,8 @@ bool WebRtcVideoFrame::MakeExclusive() {
size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer,
size_t size, int stride_rgb) const {
CHECK(video_frame_buffer_);
CHECK(video_frame_buffer_->native_handle() == nullptr);
RTC_CHECK(video_frame_buffer_);
RTC_CHECK(video_frame_buffer_->native_handle() == nullptr);
return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb);
}
@ -296,7 +296,7 @@ const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const {
// If the video frame is backed up by a native handle, it resides in the GPU
// memory which we can't rotate here. The assumption is that the renderers
// which uses GPU to render should be able to rotate themselves.
DCHECK(!GetNativeHandle());
RTC_DCHECK(!GetNativeHandle());
if (rotated_frame_) {
return rotated_frame_.get();

View File

@ -331,7 +331,7 @@ static void MaybeFixupG722(webrtc::CodecInst* voe_codec, int new_plfreq) {
if (IsCodec(*voe_codec, kG722CodecName)) {
// If the ASSERT triggers, the codec definition in WebRTC VoiceEngine
// has changed, and this special case is no longer needed.
DCHECK(voe_codec->plfreq != new_plfreq);
RTC_DCHECK(voe_codec->plfreq != new_plfreq);
voe_codec->plfreq = new_plfreq;
}
}
@ -493,14 +493,14 @@ WebRtcVoiceEngine::~WebRtcVoiceEngine() {
}
// Test to see if the media processor was deregistered properly
DCHECK(SignalRxMediaFrame.is_empty());
DCHECK(SignalTxMediaFrame.is_empty());
RTC_DCHECK(SignalRxMediaFrame.is_empty());
RTC_DCHECK(SignalTxMediaFrame.is_empty());
tracing_->SetTraceCallback(NULL);
}
bool WebRtcVoiceEngine::Init(rtc::Thread* worker_thread) {
DCHECK(worker_thread == rtc::Thread::Current());
RTC_DCHECK(worker_thread == rtc::Thread::Current());
LOG(LS_INFO) << "WebRtcVoiceEngine::Init";
bool res = InitInternal();
if (res) {
@ -1071,7 +1071,7 @@ bool WebRtcVoiceEngine::GetOutputVolume(int* level) {
}
bool WebRtcVoiceEngine::SetOutputVolume(int level) {
DCHECK(level >= 0 && level <= 255);
RTC_DCHECK(level >= 0 && level <= 255);
if (voe_wrapper_->volume()->SetSpeakerVolume(level) == -1) {
LOG_RTCERR1(SetSpeakerVolume, level);
return false;
@ -1304,7 +1304,7 @@ void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) {
LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel "
<< channel_num << ".";
if (FindChannelAndSsrc(channel_num, &channel, &ssrc)) {
DCHECK(channel != NULL);
RTC_DCHECK(channel != NULL);
channel->OnError(ssrc, err_code);
} else {
LOG(LS_ERROR) << "VoiceEngine channel " << channel_num
@ -1314,13 +1314,13 @@ void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) {
bool WebRtcVoiceEngine::FindChannelAndSsrc(
int channel_num, WebRtcVoiceMediaChannel** channel, uint32* ssrc) const {
DCHECK(channel != NULL && ssrc != NULL);
RTC_DCHECK(channel != NULL && ssrc != NULL);
*channel = NULL;
*ssrc = 0;
// Find corresponding channel and ssrc
for (WebRtcVoiceMediaChannel* ch : channels_) {
DCHECK(ch != NULL);
RTC_DCHECK(ch != NULL);
if (ch->FindSsrc(channel_num, ssrc)) {
*channel = ch;
return true;
@ -1334,13 +1334,13 @@ bool WebRtcVoiceEngine::FindChannelAndSsrc(
// obtain the voice engine's channel number.
bool WebRtcVoiceEngine::FindChannelNumFromSsrc(
uint32 ssrc, MediaProcessorDirection direction, int* channel_num) {
DCHECK(channel_num != NULL);
DCHECK(direction == MPD_RX || direction == MPD_TX);
RTC_DCHECK(channel_num != NULL);
RTC_DCHECK(direction == MPD_RX || direction == MPD_TX);
*channel_num = -1;
// Find corresponding channel for ssrc.
for (const WebRtcVoiceMediaChannel* ch : channels_) {
DCHECK(ch != NULL);
RTC_DCHECK(ch != NULL);
if (direction & MPD_RX) {
*channel_num = ch->GetReceiveChannelNum(ssrc);
}
@ -1622,9 +1622,9 @@ class WebRtcVoiceMediaChannel::WebRtcVoiceChannelRenderer
// TODO(xians): Make sure Start() is called only once.
void Start(AudioRenderer* renderer) {
rtc::CritScope lock(&lock_);
DCHECK(renderer != NULL);
RTC_DCHECK(renderer != NULL);
if (renderer_ != NULL) {
DCHECK(renderer_ == renderer);
RTC_DCHECK(renderer_ == renderer);
return;
}
@ -1708,7 +1708,7 @@ WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
engine->RegisterChannel(this);
LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel "
<< voe_channel();
DCHECK(nullptr != call);
RTC_DCHECK(nullptr != call);
ConfigureSendChannel(voe_channel());
}
@ -1727,7 +1727,7 @@ WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() {
while (!receive_channels_.empty()) {
RemoveRecvStream(receive_channels_.begin()->first);
}
DCHECK(receive_streams_.empty());
RTC_DCHECK(receive_streams_.empty());
// Delete the default channel.
DeleteChannel(voe_channel());
@ -2365,7 +2365,7 @@ bool WebRtcVoiceMediaChannel::ChangeSend(int channel, SendFlags send) {
return false;
}
} else { // SEND_NOTHING
DCHECK(send == SEND_NOTHING);
RTC_DCHECK(send == SEND_NOTHING);
if (engine()->voe()->base()->StopSend(channel) == -1) {
LOG_RTCERR1(StopSend, channel);
return false;
@ -2532,7 +2532,7 @@ bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32 ssrc) {
}
bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
rtc::CritScope lock(&receive_channels_cs_);
if (!VERIFY(sp.ssrcs.size() == 1))
@ -2549,7 +2549,7 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
return false;
}
DCHECK(receive_stream_params_.find(ssrc) == receive_stream_params_.end());
RTC_DCHECK(receive_stream_params_.find(ssrc) == receive_stream_params_.end());
// Reuse default channel for recv stream in non-conference mode call
// when the default channel is not being used.
@ -2662,7 +2662,7 @@ bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) {
}
bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
rtc::CritScope lock(&receive_channels_cs_);
ChannelMap::iterator it = receive_channels_.find(ssrc);
if (it == receive_channels_.end()) {
@ -2682,7 +2682,7 @@ bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) {
receive_channels_.erase(it);
if (ssrc == default_receive_ssrc_) {
DCHECK(IsDefaultChannel(channel));
RTC_DCHECK(IsDefaultChannel(channel));
// Recycle the default channel is for recv stream.
if (playout_)
SetPlayout(voe_channel(), false);
@ -2963,7 +2963,7 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event,
void WebRtcVoiceMediaChannel::OnPacketReceived(
rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
// Forward packet to Call as well.
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
@ -3005,7 +3005,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
void WebRtcVoiceMediaChannel::OnRtcpReceived(
rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
// Forward packet to Call as well.
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
@ -3325,15 +3325,15 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
void WebRtcVoiceMediaChannel::GetLastMediaError(
uint32* ssrc, VoiceMediaChannel::Error* error) {
DCHECK(ssrc != NULL);
DCHECK(error != NULL);
RTC_DCHECK(ssrc != NULL);
RTC_DCHECK(error != NULL);
FindSsrc(voe_channel(), ssrc);
*error = WebRtcErrorToChannelError(GetLastEngineError());
}
bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32* ssrc) {
rtc::CritScope lock(&receive_channels_cs_);
DCHECK(ssrc != NULL);
RTC_DCHECK(ssrc != NULL);
if (channel_num == -1 && send_ != SEND_NOTHING) {
// Sometimes the VoiceEngine core will throw error with channel_num = -1.
// This means the error is not limited to a specific channel. Signal the
@ -3544,7 +3544,7 @@ bool WebRtcVoiceMediaChannel::SetHeaderExtension(ExtensionSetterFunction setter,
}
void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
for (const auto& it : receive_channels_) {
RemoveAudioReceiveStream(it.first);
}
@ -3554,10 +3554,10 @@ void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() {
}
void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc];
DCHECK(channel != nullptr);
DCHECK(receive_streams_.find(ssrc) == receive_streams_.end());
RTC_DCHECK(channel != nullptr);
RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end());
webrtc::AudioReceiveStream::Config config;
config.rtp.remote_ssrc = ssrc;
// Only add RTP extensions if we support combined A/V BWE.
@ -3571,7 +3571,7 @@ void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) {
}
void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
auto stream_it = receive_streams_.find(ssrc);
if (stream_it != receive_streams_.end()) {
call_->DestroyAudioReceiveStream(stream_it->second);

View File

@ -97,7 +97,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
public:
explicit ChannelErrorListener(cricket::VoiceMediaChannel* channel)
: ssrc_(0), error_(cricket::VoiceMediaChannel::ERROR_NONE) {
DCHECK(channel != NULL);
RTC_DCHECK(channel != NULL);
channel->SignalMediaError.connect(
this, &ChannelErrorListener::OnVoiceChannelError);
}

View File

@ -54,7 +54,7 @@ static const VideoCodec kVideoCodecs[] = {
class FakeMediaController : public webrtc::MediaControllerInterface {
public:
explicit FakeMediaController(webrtc::Call* call) : call_(call) {
DCHECK(nullptr != call);
RTC_DCHECK(nullptr != call);
}
~FakeMediaController() override {}
webrtc::Call* call_w() override { return call_; }

View File

@ -96,7 +96,7 @@ bool GuardedAsyncInvoker::Flush(uint32 id) {
void GuardedAsyncInvoker::ThreadDestroyed() {
rtc::CritScope cs(&crit_);
// We should never get more than one notification about the thread dying.
DCHECK(thread_ != nullptr);
RTC_DCHECK(thread_ != nullptr);
thread_ = nullptr;
}

View File

@ -19,14 +19,14 @@ namespace {
// Returns the lowest (right-most) |bit_count| bits in |byte|.
uint8_t LowestBits(uint8_t byte, size_t bit_count) {
DCHECK_LE(bit_count, 8u);
RTC_DCHECK_LE(bit_count, 8u);
return byte & ((1 << bit_count) - 1);
}
// Returns the highest (left-most) |bit_count| bits in |byte|, shifted to the
// lowest bits (to the right).
uint8_t HighestBits(uint8_t byte, size_t bit_count) {
DCHECK_LE(bit_count, 8u);
RTC_DCHECK_LE(bit_count, 8u);
uint8_t shift = 8 - static_cast<uint8_t>(bit_count);
uint8_t mask = 0xFF << shift;
return (byte & mask) >> shift;
@ -44,9 +44,9 @@ uint8_t WritePartialByte(uint8_t source,
size_t source_bit_count,
uint8_t target,
size_t target_bit_offset) {
DCHECK(target_bit_offset < 8);
DCHECK(source_bit_count < 9);
DCHECK(source_bit_count <= (8 - target_bit_offset));
RTC_DCHECK(target_bit_offset < 8);
RTC_DCHECK(source_bit_count < 9);
RTC_DCHECK(source_bit_count <= (8 - target_bit_offset));
// Generate a mask for just the bits we're going to overwrite, so:
uint8_t mask =
// The number of bits we want, in the most significant bits...
@ -75,8 +75,8 @@ namespace rtc {
BitBuffer::BitBuffer(const uint8_t* bytes, size_t byte_count)
: bytes_(bytes), byte_count_(byte_count), byte_offset_(), bit_offset_() {
DCHECK(static_cast<uint64_t>(byte_count_) <=
std::numeric_limits<uint32_t>::max());
RTC_DCHECK(static_cast<uint64_t>(byte_count_) <=
std::numeric_limits<uint32_t>::max());
}
uint64_t BitBuffer::RemainingBitCount() const {
@ -88,7 +88,7 @@ bool BitBuffer::ReadUInt8(uint8_t* val) {
if (!ReadBits(&bit_val, sizeof(uint8_t) * 8)) {
return false;
}
DCHECK(bit_val <= std::numeric_limits<uint8_t>::max());
RTC_DCHECK(bit_val <= std::numeric_limits<uint8_t>::max());
*val = static_cast<uint8_t>(bit_val);
return true;
}
@ -98,7 +98,7 @@ bool BitBuffer::ReadUInt16(uint16_t* val) {
if (!ReadBits(&bit_val, sizeof(uint16_t) * 8)) {
return false;
}
DCHECK(bit_val <= std::numeric_limits<uint16_t>::max());
RTC_DCHECK(bit_val <= std::numeric_limits<uint16_t>::max());
*val = static_cast<uint16_t>(bit_val);
return true;
}
@ -173,14 +173,14 @@ bool BitBuffer::ReadExponentialGolomb(uint32_t* val) {
}
// We should either be at the end of the stream, or the next bit should be 1.
DCHECK(!PeekBits(&peeked_bit, 1) || peeked_bit == 1);
RTC_DCHECK(!PeekBits(&peeked_bit, 1) || peeked_bit == 1);
// The bit count of the value is the number of zeros + 1. Make sure that many
// bits fits in a uint32_t and that we have enough bits left for it, and then
// read the value.
size_t value_bit_count = zero_bit_count + 1;
if (value_bit_count > 32 || !ReadBits(val, value_bit_count)) {
CHECK(Seek(original_byte_offset, original_bit_offset));
RTC_CHECK(Seek(original_byte_offset, original_bit_offset));
return false;
}
*val -= 1;
@ -189,8 +189,8 @@ bool BitBuffer::ReadExponentialGolomb(uint32_t* val) {
void BitBuffer::GetCurrentOffset(
size_t* out_byte_offset, size_t* out_bit_offset) {
CHECK(out_byte_offset != NULL);
CHECK(out_bit_offset != NULL);
RTC_CHECK(out_byte_offset != NULL);
RTC_CHECK(out_bit_offset != NULL);
*out_byte_offset = byte_offset_;
*out_bit_offset = bit_offset_;
}

View File

@ -109,9 +109,6 @@ void FatalMessage::Init(const char* file, int line) {
<< file << ", line " << line << std::endl << "# ";
}
// Refer to comments in checks.h.
#ifndef WEBRTC_CHROMIUM_BUILD
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
// Explicit instantiations for commonly used comparisons.
@ -127,6 +124,4 @@ template std::string* MakeCheckOpString<std::string, std::string>(
const std::string&, const std::string&, const char* name);
#endif
#endif // WEBRTC_CHROMIUM_BUILD
} // namespace rtc

View File

@ -25,50 +25,46 @@
// The macros here print a message to stderr and abort under various
// conditions. All will accept additional stream messages. For example:
// DCHECK_EQ(foo, bar) << "I'm printed when foo != bar.";
// RTC_DCHECK_EQ(foo, bar) << "I'm printed when foo != bar.";
//
// - CHECK(x) is an assertion that x is always true, and that if it isn't, it's
// better to terminate the process than to continue. During development, the
// reason that it's better to terminate might simply be that the error
// - RTC_CHECK(x) is an assertion that x is always true, and that if it isn't,
// it's better to terminate the process than to continue. During development,
// the reason that it's better to terminate might simply be that the error
// handling code isn't in place yet; in production, the reason might be that
// the author of the code truly believes that x will always be true, but that
// she recognizes that if she is wrong, abrupt and unpleasant process
// termination is still better than carrying on with the assumption violated.
//
// CHECK always evaluates its argument, so it's OK for x to have side
// RTC_CHECK always evaluates its argument, so it's OK for x to have side
// effects.
//
// - DCHECK(x) is the same as CHECK(x)---an assertion that x is always
// - RTC_DCHECK(x) is the same as RTC_CHECK(x)---an assertion that x is always
// true---except that x will only be evaluated in debug builds; in production
// builds, x is simply assumed to be true. This is useful if evaluating x is
// expensive and the expected cost of failing to detect the violated
// assumption is acceptable. You should not handle cases where a production
// build fails to spot a violated condition, even those that would result in
// crashes. If the code needs to cope with the error, make it cope, but don't
// call DCHECK; if the condition really can't occur, but you'd sleep better
// at night knowing that the process will suicide instead of carrying on in
// case you were wrong, use CHECK instead of DCHECK.
// call RTC_DCHECK; if the condition really can't occur, but you'd sleep
// better at night knowing that the process will suicide instead of carrying
// on in case you were wrong, use RTC_CHECK instead of RTC_DCHECK.
//
// DCHECK only evaluates its argument in debug builds, so if x has visible
// RTC_DCHECK only evaluates its argument in debug builds, so if x has visible
// side effects, you need to write e.g.
// bool w = x; DCHECK(w);
// bool w = x; RTC_DCHECK(w);
//
// - CHECK_EQ, _NE, _GT, ..., and DCHECK_EQ, _NE, _GT, ... are specialized
// variants of CHECK and DCHECK that print prettier messages if the condition
// doesn't hold. Prefer them to raw CHECK and DCHECK.
// - RTC_CHECK_EQ, _NE, _GT, ..., and RTC_DCHECK_EQ, _NE, _GT, ... are
// specialized variants of RTC_CHECK and RTC_DCHECK that print prettier
// messages if the condition doesn't hold. Prefer them to raw RTC_CHECK and
// RTC_DCHECK.
//
// - FATAL() aborts unconditionally.
namespace rtc {
// The use of overrides/webrtc/base/logging.h in a Chromium build results in
// redefined macro errors. Fortunately, Chromium's macros can be used as drop-in
// replacements for the standalone versions.
#ifndef WEBRTC_CHROMIUM_BUILD
// Helper macro which avoids evaluating the arguments to a stream if
// the condition doesn't hold.
#define LAZY_STREAM(stream, condition) \
#define RTC_LAZY_STREAM(stream, condition) \
!(condition) ? static_cast<void>(0) : rtc::FatalMessageVoidify() & (stream)
// The actual stream used isn't important. We reference condition in the code
@ -76,30 +72,30 @@ namespace rtc {
// in a particularly convoluted way with an extra ?: because that appears to be
// the simplest construct that keeps Visual Studio from complaining about
// condition being unused).
#define EAT_STREAM_PARAMETERS(condition) \
(true ? true : !(condition)) \
? static_cast<void>(0) \
#define RTC_EAT_STREAM_PARAMETERS(condition) \
(true ? true : !(condition)) \
? static_cast<void>(0) \
: rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
// CHECK dies with a fatal error if condition is not true. It is *not*
// RTC_CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by NDEBUG, so the check will be executed regardless of
// compilation mode.
//
// We make sure CHECK et al. always evaluates their arguments, as
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
#define CHECK(condition) \
LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), !(condition)) \
<< "Check failed: " #condition << std::endl << "# "
// We make sure RTC_CHECK et al. always evaluates their arguments, as
// doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom.
#define RTC_CHECK(condition) \
RTC_LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), \
!(condition)) \
<< "Check failed: " #condition << std::endl << "# "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use CHECK_EQ et al below.
// Don't use this macro directly in your code, use RTC_CHECK_EQ et al below.
//
// TODO(akalin): Rewrite this so that constructs like if (...)
// CHECK_EQ(...) else { ... } work properly.
#define CHECK_OP(name, op, val1, val2) \
if (std::string* _result = \
rtc::Check##name##Impl((val1), (val2), \
#val1 " " #op " " #val2)) \
// RTC_CHECK_EQ(...) else { ... } work properly.
#define RTC_CHECK_OP(name, op, val1, val2) \
if (std::string* _result = \
rtc::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
rtc::FatalMessage(__FILE__, __LINE__, _result).stream()
// Build the error message string. This is separate from the "Impl"
@ -134,55 +130,59 @@ std::string* MakeCheckOpString<std::string, std::string>(
const std::string&, const std::string&, const char* name);
#endif
// Helper functions for CHECK_OP macro.
// Helper functions for RTC_CHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
#define DEFINE_CHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
if (v1 op v2) return NULL; \
else return rtc::MakeCheckOpString(v1, v2, names); \
} \
#define DEFINE_RTC_CHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
if (v1 op v2) \
return NULL; \
else \
return rtc::MakeCheckOpString(v1, v2, names); \
} \
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
if (v1 op v2) return NULL; \
else return rtc::MakeCheckOpString(v1, v2, names); \
if (v1 op v2) \
return NULL; \
else \
return rtc::MakeCheckOpString(v1, v2, names); \
}
DEFINE_CHECK_OP_IMPL(EQ, ==)
DEFINE_CHECK_OP_IMPL(NE, !=)
DEFINE_CHECK_OP_IMPL(LE, <=)
DEFINE_CHECK_OP_IMPL(LT, < )
DEFINE_CHECK_OP_IMPL(GE, >=)
DEFINE_CHECK_OP_IMPL(GT, > )
#undef DEFINE_CHECK_OP_IMPL
DEFINE_RTC_CHECK_OP_IMPL(EQ, ==)
DEFINE_RTC_CHECK_OP_IMPL(NE, !=)
DEFINE_RTC_CHECK_OP_IMPL(LE, <=)
DEFINE_RTC_CHECK_OP_IMPL(LT, < )
DEFINE_RTC_CHECK_OP_IMPL(GE, >=)
DEFINE_RTC_CHECK_OP_IMPL(GT, > )
#undef DEFINE_RTC_CHECK_OP_IMPL
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
#define RTC_CHECK_EQ(val1, val2) RTC_CHECK_OP(EQ, ==, val1, val2)
#define RTC_CHECK_NE(val1, val2) RTC_CHECK_OP(NE, !=, val1, val2)
#define RTC_CHECK_LE(val1, val2) RTC_CHECK_OP(LE, <=, val1, val2)
#define RTC_CHECK_LT(val1, val2) RTC_CHECK_OP(LT, < , val1, val2)
#define RTC_CHECK_GE(val1, val2) RTC_CHECK_OP(GE, >=, val1, val2)
#define RTC_CHECK_GT(val1, val2) RTC_CHECK_OP(GT, > , val1, val2)
// The DCHECK macro is equivalent to CHECK except that it only generates code
// in debug builds. It does reference the condition parameter in all cases,
// The RTC_DCHECK macro is equivalent to RTC_CHECK except that it only generates
// code in debug builds. It does reference the condition parameter in all cases,
// though, so callers won't risk getting warnings about unused variables.
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
#define DCHECK(condition) CHECK(condition)
#define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2)
#define DCHECK_NE(v1, v2) CHECK_NE(v1, v2)
#define DCHECK_LE(v1, v2) CHECK_LE(v1, v2)
#define DCHECK_LT(v1, v2) CHECK_LT(v1, v2)
#define DCHECK_GE(v1, v2) CHECK_GE(v1, v2)
#define DCHECK_GT(v1, v2) CHECK_GT(v1, v2)
#define RTC_DCHECK(condition) RTC_CHECK(condition)
#define RTC_DCHECK_EQ(v1, v2) RTC_CHECK_EQ(v1, v2)
#define RTC_DCHECK_NE(v1, v2) RTC_CHECK_NE(v1, v2)
#define RTC_DCHECK_LE(v1, v2) RTC_CHECK_LE(v1, v2)
#define RTC_DCHECK_LT(v1, v2) RTC_CHECK_LT(v1, v2)
#define RTC_DCHECK_GE(v1, v2) RTC_CHECK_GE(v1, v2)
#define RTC_DCHECK_GT(v1, v2) RTC_CHECK_GT(v1, v2)
#else
#define DCHECK(condition) EAT_STREAM_PARAMETERS(condition)
#define DCHECK_EQ(v1, v2) EAT_STREAM_PARAMETERS((v1) == (v2))
#define DCHECK_NE(v1, v2) EAT_STREAM_PARAMETERS((v1) != (v2))
#define DCHECK_LE(v1, v2) EAT_STREAM_PARAMETERS((v1) <= (v2))
#define DCHECK_LT(v1, v2) EAT_STREAM_PARAMETERS((v1) < (v2))
#define DCHECK_GE(v1, v2) EAT_STREAM_PARAMETERS((v1) >= (v2))
#define DCHECK_GT(v1, v2) EAT_STREAM_PARAMETERS((v1) > (v2))
#define RTC_DCHECK(condition) RTC_EAT_STREAM_PARAMETERS(condition)
#define RTC_DCHECK_EQ(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) == (v2))
#define RTC_DCHECK_NE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) != (v2))
#define RTC_DCHECK_LE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) <= (v2))
#define RTC_DCHECK_LT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) < (v2))
#define RTC_DCHECK_GE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) >= (v2))
#define RTC_DCHECK_GT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) > (v2))
#endif
// This is identical to LogMessageVoidify but in name.
@ -194,13 +194,11 @@ class FatalMessageVoidify {
void operator&(std::ostream&) { }
};
#endif // WEBRTC_CHROMIUM_BUILD
#define RTC_UNREACHABLE_CODE_HIT false
#define RTC_NOTREACHED() DCHECK(RTC_UNREACHABLE_CODE_HIT)
#define RTC_NOTREACHED() RTC_DCHECK(RTC_UNREACHABLE_CODE_HIT)
#define FATAL() rtc::FatalMessage(__FILE__, __LINE__).stream()
// TODO(ajm): Consider adding NOTIMPLEMENTED and NOTREACHED macros when
// TODO(ajm): Consider adding RTC_NOTIMPLEMENTED macro when
// base/logging.h and system_wrappers/logging.h are consolidated such that we
// can match the Chromium behavior.
@ -208,7 +206,7 @@ class FatalMessageVoidify {
class FatalMessage {
public:
FatalMessage(const char* file, int line);
// Used for CHECK_EQ(), etc. Takes ownership of the given string.
// Used for RTC_CHECK_EQ(), etc. Takes ownership of the given string.
FatalMessage(const char* file, int line, std::string* result);
NO_RETURN ~FatalMessage();
@ -224,7 +222,7 @@ class FatalMessage {
// remainder is zero.
template <typename T>
inline T CheckedDivExact(T a, T b) {
CHECK_EQ(a % b, static_cast<T>(0));
RTC_CHECK_EQ(a % b, static_cast<T>(0));
return a / b;
}

View File

@ -43,10 +43,10 @@ void CriticalSection::Enter() EXCLUSIVE_LOCK_FUNCTION() {
pthread_mutex_lock(&mutex_);
#if CS_DEBUG_CHECKS
if (!recursion_count_) {
DCHECK(!thread_);
RTC_DCHECK(!thread_);
thread_ = pthread_self();
} else {
DCHECK(CurrentThreadIsOwner());
RTC_DCHECK(CurrentThreadIsOwner());
}
++recursion_count_;
#endif
@ -61,10 +61,10 @@ bool CriticalSection::TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return false;
#if CS_DEBUG_CHECKS
if (!recursion_count_) {
DCHECK(!thread_);
RTC_DCHECK(!thread_);
thread_ = pthread_self();
} else {
DCHECK(CurrentThreadIsOwner());
RTC_DCHECK(CurrentThreadIsOwner());
}
++recursion_count_;
#endif
@ -72,13 +72,13 @@ bool CriticalSection::TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
#endif
}
void CriticalSection::Leave() UNLOCK_FUNCTION() {
DCHECK(CurrentThreadIsOwner());
RTC_DCHECK(CurrentThreadIsOwner());
#if defined(WEBRTC_WIN)
LeaveCriticalSection(&crit_);
#else
#if CS_DEBUG_CHECKS
--recursion_count_;
DCHECK(recursion_count_ >= 0);
RTC_DCHECK(recursion_count_ >= 0);
if (!recursion_count_)
thread_ = 0;
#endif
@ -119,7 +119,7 @@ TryCritScope::TryCritScope(CriticalSection* cs)
}
TryCritScope::~TryCritScope() {
CS_DEBUG_CODE(DCHECK(lock_was_called_));
CS_DEBUG_CODE(RTC_DCHECK(lock_was_called_));
if (locked_)
cs_->Leave();
}
@ -145,7 +145,7 @@ void GlobalLockPod::Lock() {
void GlobalLockPod::Unlock() {
int old_value = AtomicOps::CompareAndSwap(&lock_acquired, 1, 0);
DCHECK_EQ(1, old_value) << "Unlock called without calling Lock first";
RTC_DCHECK_EQ(1, old_value) << "Unlock called without calling Lock first";
}
GlobalLock::GlobalLock() {

View File

@ -50,9 +50,9 @@ class LOCKABLE CriticalSection {
bool TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true);
void Leave() UNLOCK_FUNCTION();
// Use only for DCHECKing.
// Use only for RTC_DCHECKing.
bool CurrentThreadIsOwner() const;
// Use only for DCHECKing.
// Use only for RTC_DCHECKing.
bool IsLocked() const;
private:

View File

@ -31,7 +31,7 @@ Event::Event(bool manual_reset, bool initially_signaled) {
manual_reset,
initially_signaled,
NULL); // Name.
CHECK(event_handle_);
RTC_CHECK(event_handle_);
}
Event::~Event() {
@ -56,8 +56,8 @@ bool Event::Wait(int milliseconds) {
Event::Event(bool manual_reset, bool initially_signaled)
: is_manual_reset_(manual_reset),
event_status_(initially_signaled) {
CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0);
CHECK(pthread_cond_init(&event_cond_, NULL) == 0);
RTC_CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0);
RTC_CHECK(pthread_cond_init(&event_cond_, NULL) == 0);
}
Event::~Event() {

View File

@ -37,8 +37,8 @@ FileRotatingStream::FileRotatingStream(const std::string& dir_path,
max_file_size,
num_files,
kWrite) {
DCHECK_GT(max_file_size, 0u);
DCHECK_GT(num_files, 1u);
RTC_DCHECK_GT(max_file_size, 0u);
RTC_DCHECK_GT(num_files, 1u);
}
FileRotatingStream::FileRotatingStream(const std::string& dir_path,
@ -55,7 +55,7 @@ FileRotatingStream::FileRotatingStream(const std::string& dir_path,
rotation_index_(0),
current_bytes_written_(0),
disable_buffering_(false) {
DCHECK(Filesystem::IsFolder(dir_path));
RTC_DCHECK(Filesystem::IsFolder(dir_path));
switch (mode) {
case kWrite: {
file_names_.clear();
@ -94,7 +94,7 @@ StreamResult FileRotatingStream::Read(void* buffer,
size_t buffer_len,
size_t* read,
int* error) {
DCHECK(buffer);
RTC_DCHECK(buffer);
if (mode_ != kRead) {
return SR_EOS;
}
@ -152,7 +152,7 @@ StreamResult FileRotatingStream::Write(const void* data,
return SR_ERROR;
}
// Write as much as will fit in to the current file.
DCHECK_LT(current_bytes_written_, max_file_size_);
RTC_DCHECK_LT(current_bytes_written_, max_file_size_);
size_t remaining_bytes = max_file_size_ - current_bytes_written_;
size_t write_length = std::min(data_len, remaining_bytes);
size_t local_written = 0;
@ -164,7 +164,7 @@ StreamResult FileRotatingStream::Write(const void* data,
// If we're done with this file, rotate it out.
if (current_bytes_written_ >= max_file_size_) {
DCHECK_EQ(current_bytes_written_, max_file_size_);
RTC_DCHECK_EQ(current_bytes_written_, max_file_size_);
RotateFiles();
}
return result;
@ -183,7 +183,7 @@ bool FileRotatingStream::GetSize(size_t* size) const {
// potential buffering.
return false;
}
DCHECK(size);
RTC_DCHECK(size);
*size = 0;
size_t total_size = 0;
for (auto file_name : file_names_) {
@ -232,7 +232,7 @@ bool FileRotatingStream::DisableBuffering() {
}
std::string FileRotatingStream::GetFilePath(size_t index) const {
DCHECK_LT(index, file_names_.size());
RTC_DCHECK_LT(index, file_names_.size());
return file_names_[index];
}
@ -240,7 +240,7 @@ bool FileRotatingStream::OpenCurrentFile() {
CloseCurrentFile();
// Opens the appropriate file in the appropriate mode.
DCHECK_LT(current_file_index_, file_names_.size());
RTC_DCHECK_LT(current_file_index_, file_names_.size());
std::string file_path = file_names_[current_file_index_];
file_stream_.reset(new FileStream());
const char* mode = nullptr;
@ -248,7 +248,7 @@ bool FileRotatingStream::OpenCurrentFile() {
case kWrite:
mode = "w+";
// We should always we writing to the zero-th file.
DCHECK_EQ(current_file_index_, 0u);
RTC_DCHECK_EQ(current_file_index_, 0u);
break;
case kRead:
mode = "r";
@ -276,12 +276,12 @@ void FileRotatingStream::CloseCurrentFile() {
}
void FileRotatingStream::RotateFiles() {
DCHECK_EQ(mode_, kWrite);
RTC_DCHECK_EQ(mode_, kWrite);
CloseCurrentFile();
// Rotates the files by deleting the file at |rotation_index_|, which is the
// oldest file and then renaming the newer files to have an incremented index.
// See header file comments for example.
DCHECK_LE(rotation_index_, file_names_.size());
RTC_DCHECK_LE(rotation_index_, file_names_.size());
std::string file_to_delete = file_names_[rotation_index_];
if (Filesystem::IsFile(file_to_delete)) {
if (!Filesystem::DeleteFile(file_to_delete)) {
@ -325,13 +325,13 @@ std::vector<std::string> FileRotatingStream::GetFilesWithPrefix() const {
std::string FileRotatingStream::GetFilePath(size_t index,
size_t num_files) const {
DCHECK_LT(index, num_files);
RTC_DCHECK_LT(index, num_files);
std::ostringstream file_name;
// The format will be "_%<num_digits>zu". We want to zero pad the index so
// that it will sort nicely.
size_t max_digits = ((num_files - 1) / 10) + 1;
size_t num_digits = (index / 10) + 1;
DCHECK_LE(num_digits, max_digits);
RTC_DCHECK_LE(num_digits, max_digits);
size_t padding = max_digits - num_digits;
file_name << file_prefix_ << "_";
@ -360,7 +360,7 @@ CallSessionFileRotatingStream::CallSessionFileRotatingStream(
GetNumRotatingLogFiles(max_total_log_size) + 1),
max_total_log_size_(max_total_log_size),
num_rotations_(0) {
DCHECK_GE(max_total_log_size, 4u);
RTC_DCHECK_GE(max_total_log_size, 4u);
}
const char* CallSessionFileRotatingStream::kLogPrefix = "webrtc_log";

View File

@ -163,7 +163,7 @@ void FlagList::SplitArgument(const char* arg,
if (*arg == '=') {
// make a copy so we can NUL-terminate flag name
int n = static_cast<int>(arg - *name);
CHECK_LT(n, buffer_size);
RTC_CHECK_LT(n, buffer_size);
memcpy(buffer, *name, n * sizeof(char));
buffer[n] = '\0';
*name = buffer;
@ -257,7 +257,8 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv,
void FlagList::Register(Flag* flag) {
assert(flag != NULL && strlen(flag->name()) > 0);
CHECK(!Lookup(flag->name())) << "flag " << flag->name() << " declared twice";
RTC_CHECK(!Lookup(flag->name())) << "flag " << flag->name()
<< " declared twice";
flag->next_ = list_;
list_ = flag;
}

View File

@ -29,7 +29,7 @@ FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path,
FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream)
: stream_(stream) {
DCHECK(stream);
RTC_DCHECK(stream);
}
FileRotatingLogSink::~FileRotatingLogSink() {

View File

@ -123,7 +123,7 @@ std::string AdapterTypeToString(AdapterType type) {
case ADAPTER_TYPE_LOOPBACK:
return "Loopback";
default:
DCHECK(false) << "Invalid type " << type;
RTC_DCHECK(false) << "Invalid type " << type;
return std::string();
}
}

View File

@ -37,7 +37,7 @@ PlatformThreadId CurrentThreadId() {
ret = reinterpret_cast<pid_t>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
DCHECK(ret);
RTC_DCHECK(ret);
return ret;
}
@ -58,7 +58,7 @@ bool IsThreadRefEqual(const PlatformThreadRef& a, const PlatformThreadRef& b) {
}
void SetCurrentThreadName(const char* name) {
DCHECK(strlen(name) < 64);
RTC_DCHECK(strlen(name) < 64);
#if defined(WEBRTC_WIN)
struct {
DWORD dwType;

View File

@ -26,8 +26,8 @@ RateTracker::RateTracker(
sample_buckets_(new size_t[bucket_count + 1]),
total_sample_count_(0u),
bucket_start_time_milliseconds_(~0u) {
CHECK(bucket_milliseconds > 0u);
CHECK(bucket_count > 0u);
RTC_CHECK(bucket_milliseconds > 0u);
RTC_CHECK(bucket_count > 0u);
}
RateTracker::~RateTracker() {

View File

@ -22,7 +22,7 @@ scoped_refptr<RTCCertificate> RTCCertificate::Create(
RTCCertificate::RTCCertificate(SSLIdentity* identity)
: identity_(identity) {
DCHECK(identity_);
RTC_DCHECK(identity_);
}
RTCCertificate::~RTCCertificate() {

View File

@ -32,13 +32,13 @@ inline bool IsValueInRangeForNumericType(Src value) {
// overflow or underflow. NaN source will always trigger a CHECK.
template <typename Dst, typename Src>
inline Dst checked_cast(Src value) {
CHECK(IsValueInRangeForNumericType<Dst>(value));
RTC_CHECK(IsValueInRangeForNumericType<Dst>(value));
return static_cast<Dst>(value);
}
// saturated_cast<> is analogous to static_cast<> for numeric types, except
// that the specified numeric conversion will saturate rather than overflow or
// underflow. NaN assignment to an integral will trigger a CHECK condition.
// underflow. NaN assignment to an integral will trigger a RTC_CHECK condition.
template <typename Dst, typename Src>
inline Dst saturated_cast(Src value) {
// Optimization for floating point values, which already saturate.

View File

@ -26,7 +26,7 @@ namespace rtc {
size_t escape(char * buffer, size_t buflen,
const char * source, size_t srclen,
const char * illegal, char escape) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -48,7 +48,7 @@ size_t escape(char * buffer, size_t buflen,
size_t unescape(char * buffer, size_t buflen,
const char * source, size_t srclen,
char escape) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -67,7 +67,7 @@ size_t unescape(char * buffer, size_t buflen,
size_t encode(char * buffer, size_t buflen,
const char * source, size_t srclen,
const char * illegal, char escape) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -119,8 +119,8 @@ const char* unsafe_filename_characters() {
#if defined(WEBRTC_WIN)
return "\\/:*?\"<>|";
#else // !WEBRTC_WIN
// TODO
DCHECK(false);
// TODO(grunell): Should this never be reached?
RTC_DCHECK(false);
return "";
#endif // !WEBRTC_WIN
}
@ -257,7 +257,7 @@ size_t utf8_encode(char* buffer, size_t buflen, unsigned long value) {
size_t html_encode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -275,7 +275,7 @@ size_t html_encode(char * buffer, size_t buflen,
case '\'': escseq = "&#39;"; esclen = 5; break;
case '\"': escseq = "&quot;"; esclen = 6; break;
case '&': escseq = "&amp;"; esclen = 5; break;
default: DCHECK(false);
default: RTC_DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@ -310,13 +310,13 @@ size_t html_encode(char * buffer, size_t buflen,
size_t html_decode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
return xml_decode(buffer, buflen, source, srclen);
}
size_t xml_encode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -332,7 +332,7 @@ size_t xml_encode(char * buffer, size_t buflen,
case '\'': escseq = "&apos;"; esclen = 6; break;
case '\"': escseq = "&quot;"; esclen = 6; break;
case '&': escseq = "&amp;"; esclen = 5; break;
default: DCHECK(false);
default: RTC_DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@ -349,7 +349,7 @@ size_t xml_encode(char * buffer, size_t buflen,
size_t xml_decode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen <= 0)
return 0;
@ -385,7 +385,7 @@ size_t xml_decode(char * buffer, size_t buflen,
srcpos += 1;
}
char * ptr;
// TODO: Fix hack (ptr may go past end of data)
// TODO(grunell): Fix hack (ptr may go past end of data)
unsigned long val = strtoul(source + srcpos + 1, &ptr, int_base);
if ((static_cast<size_t>(ptr - source) < srclen) && (*ptr == ';')) {
srcpos = ptr - source + 1;
@ -411,7 +411,7 @@ size_t xml_decode(char * buffer, size_t buflen,
static const char HEX[] = "0123456789abcdef";
char hex_encode(unsigned char val) {
DCHECK_LT(val, 16);
RTC_DCHECK_LT(val, 16);
return (val < 16) ? HEX[val] : '!';
}
@ -436,7 +436,7 @@ size_t hex_encode(char* buffer, size_t buflen,
size_t hex_encode_with_delimiter(char* buffer, size_t buflen,
const char* csource, size_t srclen,
char delimiter) {
DCHECK(buffer); // TODO: estimate output size
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
if (buflen == 0)
return 0;
@ -480,7 +480,7 @@ std::string hex_encode_with_delimiter(const char* source, size_t srclen,
char* buffer = STACK_ARRAY(char, kBufferSize);
size_t length = hex_encode_with_delimiter(buffer, kBufferSize,
source, srclen, delimiter);
DCHECK(srclen == 0 || length > 0);
RTC_DCHECK(srclen == 0 || length > 0);
return std::string(buffer, length);
}
@ -492,7 +492,7 @@ size_t hex_decode(char * cbuffer, size_t buflen,
size_t hex_decode_with_delimiter(char* cbuffer, size_t buflen,
const char* source, size_t srclen,
char delimiter) {
DCHECK(cbuffer); // TODO: estimate output size
RTC_DCHECK(cbuffer); // TODO(grunell): estimate output size
if (buflen == 0)
return 0;
@ -556,7 +556,7 @@ std::string s_transform(const std::string& source, Transform t) {
size_t tokenize(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
DCHECK(fields);
RTC_DCHECK(fields);
fields->clear();
size_t last = 0;
for (size_t i = 0; i < source.length(); ++i) {
@ -634,7 +634,7 @@ bool tokenize_first(const std::string& source,
size_t split(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
DCHECK(fields);
RTC_DCHECK(fields);
fields->clear();
size_t last = 0;
for (size_t i = 0; i < source.length(); ++i) {

View File

@ -176,7 +176,7 @@ bool tokenize_first(const std::string& source,
template <class T>
static bool ToString(const T &t, std::string* s) {
DCHECK(s);
RTC_DCHECK(s);
std::ostringstream oss;
oss << std::boolalpha << t;
*s = oss.str();
@ -185,7 +185,7 @@ static bool ToString(const T &t, std::string* s) {
template <class T>
static bool FromString(const std::string& s, T* t) {
DCHECK(t);
RTC_DCHECK(t);
std::istringstream iss(s);
iss >> std::boolalpha >> *t;
return !iss.fail();

View File

@ -57,7 +57,7 @@ int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n,
if (n-- == 0) return 0;
c1 = transformation(*s1);
// Double check that characters are not UTF-8
DCHECK_LT(static_cast<unsigned char>(*s2), 128);
RTC_DCHECK_LT(static_cast<unsigned char>(*s2), 128);
// Note: *s2 gets implicitly promoted to wchar_t
c2 = transformation(*s2);
if (c1 != c2) return (c1 < c2) ? -1 : 1;
@ -80,7 +80,7 @@ size_t asccpyn(wchar_t* buffer, size_t buflen,
#if _DEBUG
// Double check that characters are not UTF-8
for (size_t pos = 0; pos < srclen; ++pos)
DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);
RTC_DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);
#endif // _DEBUG
std::copy(source, source + srclen, buffer);
buffer[srclen] = 0;

View File

@ -18,10 +18,10 @@
// with this define will get the same level of thread checking as
// debug bots.
//
// Note that this does not perfectly match situations where DCHECK is
// Note that this does not perfectly match situations where RTC_DCHECK is
// enabled. For example a non-official release build may have
// DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be
// disabled) but have DCHECKs enabled at runtime.
// disabled) but have RTC_DCHECKs enabled at runtime.
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
#define ENABLE_THREAD_CHECKER 1
#else
@ -67,7 +67,7 @@ class ThreadCheckerDoNothing {
// class MyClass {
// public:
// void Foo() {
// DCHECK(thread_checker_.CalledOnValidThread());
// RTC_DCHECK(thread_checker_.CalledOnValidThread());
// ... (do stuff) ...
// }
//

View File

@ -19,7 +19,7 @@
namespace rtc {
// Real implementation of ThreadChecker, for use in debug mode, or
// for temporary use in release mode (e.g. to CHECK on a threading issue
// for temporary use in release mode (e.g. to RTC_CHECK on a threading issue
// seen only in the wild).
//
// Note: You should almost always use the ThreadChecker class to get the

View File

@ -37,9 +37,7 @@ class ThreadCheckerClass : public ThreadChecker {
ThreadCheckerClass() {}
// Verifies that it was called on the same thread as the constructor.
void DoStuff() {
DCHECK(CalledOnValidThread());
}
void DoStuff() { RTC_DCHECK(CalledOnValidThread()); }
void DetachFromThread() {
ThreadChecker::DetachFromThread();

View File

@ -42,7 +42,7 @@ uint64 TimeNanos() {
// Get the timebase if this is the first time we run.
// Recommended by Apple's QA1398.
if (mach_timebase_info(&timebase) != KERN_SUCCESS) {
DCHECK(false);
RTC_DCHECK(false);
}
}
// Use timebase to convert absolute time tick units into nanoseconds.
@ -136,8 +136,8 @@ void CurrentTmTime(struct tm *tm, int *microseconds) {
}
uint32 TimeAfter(int32 elapsed) {
DCHECK_GE(elapsed, 0);
DCHECK_LT(static_cast<uint32>(elapsed), HALF);
RTC_DCHECK_GE(elapsed, 0);
RTC_DCHECK_LT(static_cast<uint32>(elapsed), HALF);
return Time() + elapsed;
}

View File

@ -1115,7 +1115,7 @@ IPAddress VirtualSocketServer::GetDefaultRoute(int family) {
return IPAddress();
}
void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) {
DCHECK(!IPIsAny(from_addr));
RTC_DCHECK(!IPIsAny(from_addr));
if (from_addr.family() == AF_INET) {
default_route_v4_ = from_addr;
} else if (from_addr.family() == AF_INET6) {

View File

@ -106,7 +106,7 @@ class CompositionConverter : public AudioConverter {
public:
CompositionConverter(ScopedVector<AudioConverter> converters)
: converters_(converters.Pass()) {
CHECK_GE(converters_.size(), 2u);
RTC_CHECK_GE(converters_.size(), 2u);
// We need an intermediate buffer after every converter.
for (auto it = converters_.begin(); it != converters_.end() - 1; ++it)
buffers_.push_back(new ChannelBuffer<float>((*it)->dst_frames(),
@ -188,12 +188,13 @@ AudioConverter::AudioConverter(int src_channels, size_t src_frames,
src_frames_(src_frames),
dst_channels_(dst_channels),
dst_frames_(dst_frames) {
CHECK(dst_channels == src_channels || dst_channels == 1 || src_channels == 1);
RTC_CHECK(dst_channels == src_channels || dst_channels == 1 ||
src_channels == 1);
}
void AudioConverter::CheckSizes(size_t src_size, size_t dst_capacity) const {
CHECK_EQ(src_size, src_channels() * src_frames());
CHECK_GE(dst_capacity, dst_channels() * dst_frames());
RTC_CHECK_EQ(src_size, src_channels() * src_frames());
RTC_CHECK_GE(dst_capacity, dst_channels() * dst_frames());
}
} // namespace webrtc

View File

@ -49,7 +49,7 @@ class AudioConverter {
AudioConverter(int src_channels, size_t src_frames, int dst_channels,
size_t dst_frames);
// Helper to CHECK that inputs are correctly sized.
// Helper to RTC_CHECK that inputs are correctly sized.
void CheckSizes(size_t src_size, size_t dst_capacity) const;
private:

View File

@ -30,19 +30,19 @@ AudioRingBuffer::~AudioRingBuffer() {
void AudioRingBuffer::Write(const float* const* data, size_t channels,
size_t frames) {
DCHECK_EQ(buffers_.size(), channels);
RTC_DCHECK_EQ(buffers_.size(), channels);
for (size_t i = 0; i < channels; ++i) {
const size_t written = WebRtc_WriteBuffer(buffers_[i], data[i], frames);
CHECK_EQ(written, frames);
RTC_CHECK_EQ(written, frames);
}
}
void AudioRingBuffer::Read(float* const* data, size_t channels, size_t frames) {
DCHECK_EQ(buffers_.size(), channels);
RTC_DCHECK_EQ(buffers_.size(), channels);
for (size_t i = 0; i < channels; ++i) {
const size_t read =
WebRtc_ReadBuffer(buffers_[i], nullptr, data[i], frames);
CHECK_EQ(read, frames);
RTC_CHECK_EQ(read, frames);
}
}
@ -60,7 +60,7 @@ void AudioRingBuffer::MoveReadPositionForward(size_t frames) {
for (auto buf : buffers_) {
const size_t moved =
static_cast<size_t>(WebRtc_MoveReadPtr(buf, static_cast<int>(frames)));
CHECK_EQ(moved, frames);
RTC_CHECK_EQ(moved, frames);
}
}
@ -68,7 +68,7 @@ void AudioRingBuffer::MoveReadPositionBackward(size_t frames) {
for (auto buf : buffers_) {
const size_t moved = static_cast<size_t>(
-WebRtc_MoveReadPtr(buf, -static_cast<int>(frames)));
CHECK_EQ(moved, frames);
RTC_CHECK_EQ(moved, frames);
}
}

View File

@ -118,8 +118,8 @@ Blocker::Blocker(size_t chunk_size,
window_(new float[block_size_]),
shift_amount_(shift_amount),
callback_(callback) {
CHECK_LE(num_output_channels_, num_input_channels_);
CHECK_LE(shift_amount_, block_size_);
RTC_CHECK_LE(num_output_channels_, num_input_channels_);
RTC_CHECK_LE(shift_amount_, block_size_);
memcpy(window_.get(), window, block_size_ * sizeof(*window_.get()));
input_buffer_.MoveReadPositionBackward(initial_delay_);
@ -169,9 +169,9 @@ void Blocker::ProcessChunk(const float* const* input,
int num_input_channels,
int num_output_channels,
float* const* output) {
CHECK_EQ(chunk_size, chunk_size_);
CHECK_EQ(num_input_channels, num_input_channels_);
CHECK_EQ(num_output_channels, num_output_channels_);
RTC_CHECK_EQ(chunk_size, chunk_size_);
RTC_CHECK_EQ(num_input_channels, num_input_channels_);
RTC_CHECK_EQ(num_output_channels, num_output_channels_);
input_buffer_.Write(input, num_input_channels, chunk_size_);
size_t first_frame_in_block = frame_offset_;

View File

@ -75,7 +75,7 @@ class ChannelBuffer {
// 0 <= channel < |num_channels_|
// 0 <= sample < |num_frames_per_band_|
const T* const* channels(size_t band) const {
DCHECK_LT(band, num_bands_);
RTC_DCHECK_LT(band, num_bands_);
return &channels_[band * num_channels_];
}
T* const* channels(size_t band) {
@ -91,8 +91,8 @@ class ChannelBuffer {
// 0 <= band < |num_bands_|
// 0 <= sample < |num_frames_per_band_|
const T* const* bands(int channel) const {
DCHECK_LT(channel, num_channels_);
DCHECK_GE(channel, 0);
RTC_DCHECK_LT(channel, num_channels_);
RTC_DCHECK_GE(channel, 0);
return &bands_[channel * num_bands_];
}
T* const* bands(int channel) {
@ -103,7 +103,7 @@ class ChannelBuffer {
// Sets the |slice| pointers to the |start_frame| position for each channel.
// Returns |slice| for convenience.
const T* const* Slice(T** slice, size_t start_frame) const {
DCHECK_LT(start_frame, num_frames_);
RTC_DCHECK_LT(start_frame, num_frames_);
for (int i = 0; i < num_channels_; ++i)
slice[i] = &channels_[i][start_frame];
return slice;
@ -120,7 +120,7 @@ class ChannelBuffer {
size_t size() const {return num_frames_ * num_channels_; }
void SetDataForTesting(const T* data, size_t size) {
CHECK_EQ(size, this->size());
RTC_CHECK_EQ(size, this->size());
memcpy(data_.get(), data, size * sizeof(*data));
}

View File

@ -154,8 +154,8 @@ void DownmixInterleavedToMonoImpl(const T* interleaved,
size_t num_frames,
int num_channels,
T* deinterleaved) {
DCHECK_GT(num_channels, 0);
DCHECK_GT(num_frames, 0u);
RTC_DCHECK_GT(num_channels, 0);
RTC_DCHECK_GT(num_frames, 0u);
const T* const end = interleaved + num_frames * num_channels;

View File

@ -24,9 +24,9 @@ void LappedTransform::BlockThunk::ProcessBlock(const float* const* input,
int num_input_channels,
int num_output_channels,
float* const* output) {
CHECK_EQ(num_input_channels, parent_->num_in_channels_);
CHECK_EQ(num_output_channels, parent_->num_out_channels_);
CHECK_EQ(parent_->block_length_, num_frames);
RTC_CHECK_EQ(num_input_channels, parent_->num_in_channels_);
RTC_CHECK_EQ(num_output_channels, parent_->num_out_channels_);
RTC_CHECK_EQ(parent_->block_length_, num_frames);
for (int i = 0; i < num_input_channels; ++i) {
memcpy(parent_->real_buf_.Row(i), input[i],
@ -37,7 +37,7 @@ void LappedTransform::BlockThunk::ProcessBlock(const float* const* input,
size_t block_length = RealFourier::ComplexLength(
RealFourier::FftOrder(num_frames));
CHECK_EQ(parent_->cplx_length_, block_length);
RTC_CHECK_EQ(parent_->cplx_length_, block_length);
parent_->block_processor_->ProcessAudioBlock(parent_->cplx_pre_.Array(),
num_input_channels,
parent_->cplx_length_,
@ -83,13 +83,13 @@ LappedTransform::LappedTransform(int num_in_channels,
cplx_post_(num_out_channels,
cplx_length_,
RealFourier::kFftBufferAlignment) {
CHECK(num_in_channels_ > 0 && num_out_channels_ > 0);
CHECK_GT(block_length_, 0u);
CHECK_GT(chunk_length_, 0u);
CHECK(block_processor_);
RTC_CHECK(num_in_channels_ > 0 && num_out_channels_ > 0);
RTC_CHECK_GT(block_length_, 0u);
RTC_CHECK_GT(chunk_length_, 0u);
RTC_CHECK(block_processor_);
// block_length_ power of 2?
CHECK_EQ(0u, block_length_ & (block_length_ - 1));
RTC_CHECK_EQ(0u, block_length_ & (block_length_ - 1));
}
void LappedTransform::ProcessChunk(const float* const* in_chunk,

View File

@ -29,7 +29,7 @@ class NoopCallback : public webrtc::LappedTransform::Callback {
size_t frames,
int out_channels,
complex<float>* const* out_block) {
CHECK_EQ(in_channels, out_channels);
RTC_CHECK_EQ(in_channels, out_channels);
for (int i = 0; i < out_channels; ++i) {
memcpy(out_block[i], in_block[i], sizeof(**in_block) * frames);
}
@ -53,7 +53,7 @@ class FftCheckerCallback : public webrtc::LappedTransform::Callback {
size_t frames,
int out_channels,
complex<float>* const* out_block) {
CHECK_EQ(in_channels, out_channels);
RTC_CHECK_EQ(in_channels, out_channels);
size_t full_length = (frames - 1) * 2;
++block_num_;

View File

@ -30,12 +30,12 @@ rtc::scoped_ptr<RealFourier> RealFourier::Create(int fft_order) {
}
int RealFourier::FftOrder(size_t length) {
CHECK_GT(length, 0U);
RTC_CHECK_GT(length, 0U);
return WebRtcSpl_GetSizeInBits(static_cast<uint32_t>(length - 1));
}
size_t RealFourier::FftLength(int order) {
CHECK_GE(order, 0);
RTC_CHECK_GE(order, 0);
return static_cast<size_t>(1 << order);
}

View File

@ -42,7 +42,7 @@ RealFourierOoura::RealFourierOoura(int fft_order)
// arrays on the first call.
work_ip_(new size_t[ComputeWorkIpSize(length_)]()),
work_w_(new float[complex_length_]()) {
CHECK_GE(fft_order, 1);
RTC_CHECK_GE(fft_order, 1);
}
void RealFourierOoura::Forward(const float* src, complex<float>* dest) const {

View File

@ -23,19 +23,19 @@ namespace {
// Creates and initializes the Openmax state. Transfers ownership to caller.
OMXFFTSpec_R_F32* CreateOpenmaxState(int order) {
CHECK_GE(order, 1);
RTC_CHECK_GE(order, 1);
// The omx implementation uses this macro to check order validity.
CHECK_LE(order, TWIDDLE_TABLE_ORDER);
RTC_CHECK_LE(order, TWIDDLE_TABLE_ORDER);
OMX_INT buffer_size;
OMXResult r = omxSP_FFTGetBufSize_R_F32(order, &buffer_size);
CHECK_EQ(r, OMX_Sts_NoErr);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
OMXFFTSpec_R_F32* omx_spec = malloc(buffer_size);
DCHECK(omx_spec);
RTC_DCHECK(omx_spec);
r = omxSP_FFTInit_R_F32(omx_spec, order);
CHECK_EQ(r, OMX_Sts_NoErr);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
return omx_spec;
}
@ -55,14 +55,14 @@ void RealFourierOpenmax::Forward(const float* src, complex<float>* dest) const {
// http://en.cppreference.com/w/cpp/numeric/complex
OMXResult r =
omxSP_FFTFwd_RToCCS_F32(src, reinterpret_cast<OMX_F32*>(dest), omx_spec_);
CHECK_EQ(r, OMX_Sts_NoErr);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
}
void RealFourierOpenmax::Inverse(const complex<float>* src, float* dest) const {
OMXResult r =
omxSP_FFTInv_CCSToR_F32(reinterpret_cast<const OMX_F32*>(src), dest,
omx_spec_);
CHECK_EQ(r, OMX_Sts_NoErr);
RTC_CHECK_EQ(r, OMX_Sts_NoErr);
}
} // namespace webrtc

View File

@ -50,8 +50,8 @@ size_t PushSincResampler::Resample(const float* source,
size_t source_length,
float* destination,
size_t destination_capacity) {
CHECK_EQ(source_length, resampler_->request_frames());
CHECK_GE(destination_capacity, destination_frames_);
RTC_CHECK_EQ(source_length, resampler_->request_frames());
RTC_CHECK_GE(destination_capacity, destination_frames_);
// Cache the source pointer. Calling Resample() will immediately trigger
// the Run() callback whereupon we provide the cached value.
source_ptr_ = source;
@ -81,7 +81,7 @@ size_t PushSincResampler::Resample(const float* source,
void PushSincResampler::Run(size_t frames, float* destination) {
// Ensure we are only asked for the available samples. This would fail if
// Run() was triggered more than once per Resample() call.
CHECK_EQ(source_available_, frames);
RTC_CHECK_EQ(source_available_, frames);
if (first_pass_) {
// Provide dummy input on the first pass, the output of which will be

View File

@ -163,8 +163,8 @@ TEST(SincResamplerTest, Convolve) {
#endif
// Benchmark for the various Convolve() methods. Make sure to build with
// branding=Chrome so that DCHECKs are compiled out when benchmarking. Original
// benchmarks were run with --convolve-iterations=50000000.
// branding=Chrome so that RTC_DCHECKs are compiled out when benchmarking.
// Original benchmarks were run with --convolve-iterations=50000000.
TEST(SincResamplerTest, ConvolveBenchmark) {
// Initialize a dummy resampler.
MockSource mock_source;

View File

@ -22,8 +22,8 @@ SparseFIRFilter::SparseFIRFilter(const float* nonzero_coeffs,
offset_(offset),
nonzero_coeffs_(nonzero_coeffs, nonzero_coeffs + num_nonzero_coeffs),
state_(sparsity_ * (num_nonzero_coeffs - 1) + offset_, 0.f) {
CHECK_GE(num_nonzero_coeffs, 1u);
CHECK_GE(sparsity, 1u);
RTC_CHECK_GE(num_nonzero_coeffs, 1u);
RTC_CHECK_GE(sparsity, 1u);
}
void SparseFIRFilter::Filter(const float* in, size_t length, float* out) {

View File

@ -35,7 +35,7 @@ class VadImpl final : public Vad {
case 1:
return kActive;
default:
DCHECK(false) << "WebRtcVad_Process returned an error.";
RTC_DCHECK(false) << "WebRtcVad_Process returned an error.";
return kError;
}
}
@ -44,9 +44,9 @@ class VadImpl final : public Vad {
if (handle_)
WebRtcVad_Free(handle_);
handle_ = WebRtcVad_Create();
CHECK(handle_);
CHECK_EQ(WebRtcVad_Init(handle_), 0);
CHECK_EQ(WebRtcVad_set_mode(handle_, aggressiveness_), 0);
RTC_CHECK(handle_);
RTC_CHECK_EQ(WebRtcVad_Init(handle_), 0);
RTC_CHECK_EQ(WebRtcVad_set_mode(handle_, aggressiveness_), 0);
}
private:

View File

@ -76,7 +76,7 @@ TEST_F(VadTest, ApiTest) {
WebRtcVad_Process(nullptr, kRates[0], speech, kFrameLengths[0]));
// WebRtcVad_Create()
CHECK(handle);
RTC_CHECK(handle);
// Not initialized tests
EXPECT_EQ(-1, WebRtcVad_Process(handle, kRates[0], speech, kFrameLengths[0]));

View File

@ -39,16 +39,16 @@ class ReadableWavFile : public ReadableWav {
WavReader::WavReader(const std::string& filename)
: file_handle_(fopen(filename.c_str(), "rb")) {
CHECK(file_handle_ && "Could not open wav file for reading.");
RTC_CHECK(file_handle_ && "Could not open wav file for reading.");
ReadableWavFile readable(file_handle_);
WavFormat format;
int bytes_per_sample;
CHECK(ReadWavHeader(&readable, &num_channels_, &sample_rate_, &format,
&bytes_per_sample, &num_samples_));
RTC_CHECK(ReadWavHeader(&readable, &num_channels_, &sample_rate_, &format,
&bytes_per_sample, &num_samples_));
num_samples_remaining_ = num_samples_;
CHECK_EQ(kWavFormat, format);
CHECK_EQ(kBytesPerSample, bytes_per_sample);
RTC_CHECK_EQ(kWavFormat, format);
RTC_CHECK_EQ(kBytesPerSample, bytes_per_sample);
}
WavReader::~WavReader() {
@ -65,8 +65,8 @@ size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
const size_t read =
fread(samples, sizeof(*samples), num_samples, file_handle_);
// If we didn't read what was requested, ensure we've reached the EOF.
CHECK(read == num_samples || feof(file_handle_));
CHECK_LE(read, num_samples_remaining_);
RTC_CHECK(read == num_samples || feof(file_handle_));
RTC_CHECK_LE(read, num_samples_remaining_);
num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
return read;
}
@ -86,7 +86,7 @@ size_t WavReader::ReadSamples(size_t num_samples, float* samples) {
}
void WavReader::Close() {
CHECK_EQ(0, fclose(file_handle_));
RTC_CHECK_EQ(0, fclose(file_handle_));
file_handle_ = NULL;
}
@ -96,17 +96,14 @@ WavWriter::WavWriter(const std::string& filename, int sample_rate,
num_channels_(num_channels),
num_samples_(0),
file_handle_(fopen(filename.c_str(), "wb")) {
CHECK(file_handle_ && "Could not open wav file for writing.");
CHECK(CheckWavParameters(num_channels_,
sample_rate_,
kWavFormat,
kBytesPerSample,
num_samples_));
RTC_CHECK(file_handle_ && "Could not open wav file for writing.");
RTC_CHECK(CheckWavParameters(num_channels_, sample_rate_, kWavFormat,
kBytesPerSample, num_samples_));
// Write a blank placeholder header, since we need to know the total number
// of samples before we can fill in the real data.
static const uint8_t blank_header[kWavHeaderSize] = {0};
CHECK_EQ(1u, fwrite(blank_header, kWavHeaderSize, 1, file_handle_));
RTC_CHECK_EQ(1u, fwrite(blank_header, kWavHeaderSize, 1, file_handle_));
}
WavWriter::~WavWriter() {
@ -119,10 +116,10 @@ void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
#endif
const size_t written =
fwrite(samples, sizeof(*samples), num_samples, file_handle_);
CHECK_EQ(num_samples, written);
RTC_CHECK_EQ(num_samples, written);
num_samples_ += static_cast<uint32_t>(written);
CHECK(written <= std::numeric_limits<uint32_t>::max() ||
num_samples_ >= written); // detect uint32_t overflow
RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
num_samples_ >= written); // detect uint32_t overflow
}
void WavWriter::WriteSamples(const float* samples, size_t num_samples) {
@ -136,12 +133,12 @@ void WavWriter::WriteSamples(const float* samples, size_t num_samples) {
}
void WavWriter::Close() {
CHECK_EQ(0, fseek(file_handle_, 0, SEEK_SET));
RTC_CHECK_EQ(0, fseek(file_handle_, 0, SEEK_SET));
uint8_t header[kWavHeaderSize];
WriteWavHeader(header, num_channels_, sample_rate_, kWavFormat,
kBytesPerSample, num_samples_);
CHECK_EQ(1u, fwrite(header, kWavHeaderSize, 1, file_handle_));
CHECK_EQ(0, fclose(file_handle_));
RTC_CHECK_EQ(1u, fwrite(header, kWavHeaderSize, 1, file_handle_));
RTC_CHECK_EQ(0, fclose(file_handle_));
file_handle_ = NULL;
}

View File

@ -32,7 +32,7 @@ class WavFile {
};
// Simple C++ class for writing 16-bit PCM WAV files. All error handling is
// by calls to CHECK(), making it unsuitable for anything but debug code.
// by calls to RTC_CHECK(), making it unsuitable for anything but debug code.
class WavWriter final : public WavFile {
public:
// Open a new WAV file for writing.

View File

@ -151,8 +151,8 @@ void WriteWavHeader(uint8_t* buf,
WavFormat format,
int bytes_per_sample,
uint32_t num_samples) {
CHECK(CheckWavParameters(num_channels, sample_rate, format,
bytes_per_sample, num_samples));
RTC_CHECK(CheckWavParameters(num_channels, sample_rate, format,
bytes_per_sample, num_samples));
WavHeader header;
const uint32_t bytes_in_payload = bytes_per_sample * num_samples;

View File

@ -38,8 +38,8 @@ complex<float> I0(complex<float> x) {
namespace webrtc {
void WindowGenerator::Hanning(int length, float* window) {
CHECK_GT(length, 1);
CHECK(window != nullptr);
RTC_CHECK_GT(length, 1);
RTC_CHECK(window != nullptr);
for (int i = 0; i < length; ++i) {
window[i] = 0.5f * (1 - cosf(2 * static_cast<float>(M_PI) * i /
(length - 1)));
@ -48,8 +48,8 @@ void WindowGenerator::Hanning(int length, float* window) {
void WindowGenerator::KaiserBesselDerived(float alpha, size_t length,
float* window) {
CHECK_GT(length, 1U);
CHECK(window != nullptr);
RTC_CHECK_GT(length, 1U);
RTC_CHECK(window != nullptr);
const size_t half = (length + 1) / 2;
float sum = 0.0f;

View File

@ -32,7 +32,7 @@ class PooledI420Buffer : public webrtc::VideoFrameBuffer {
uint8_t* MutableData(webrtc::PlaneType type) override {
// Make the HasOneRef() check here instead of in |buffer_|, because the pool
// also has a reference to |buffer_|.
DCHECK(HasOneRef());
RTC_DCHECK(HasOneRef());
return const_cast<uint8_t*>(buffer_->data(type));
}
int stride(webrtc::PlaneType type) const override {
@ -64,7 +64,7 @@ void I420BufferPool::Release() {
rtc::scoped_refptr<VideoFrameBuffer> I420BufferPool::CreateBuffer(int width,
int height) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
// Release buffers with wrong resolution.
for (auto it = buffers_.begin(); it != buffers_.end();) {
if ((*it)->width() != width || (*it)->height() != height)

View File

@ -42,11 +42,11 @@ int VideoFrame::CreateEmptyFrame(int width,
int stride_u,
int stride_v) {
const int half_width = (width + 1) / 2;
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
DCHECK_GE(stride_y, width);
DCHECK_GE(stride_u, half_width);
DCHECK_GE(stride_v, half_width);
RTC_DCHECK_GT(width, 0);
RTC_DCHECK_GT(height, 0);
RTC_DCHECK_GE(stride_y, width);
RTC_DCHECK_GE(stride_u, half_width);
RTC_DCHECK_GE(stride_v, half_width);
// Creating empty frame - reset all values.
timestamp_ = 0;
@ -195,7 +195,7 @@ void VideoFrame::set_video_frame_buffer(
}
VideoFrame VideoFrame::ConvertNativeToI420Frame() const {
DCHECK(native_handle());
RTC_DCHECK(native_handle());
VideoFrame frame;
frame.ShallowCopy(*this);
frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer());

View File

@ -48,11 +48,11 @@ I420Buffer::I420Buffer(int width,
data_(static_cast<uint8_t*>(AlignedMalloc(
stride_y * height + (stride_u + stride_v) * ((height + 1) / 2),
kBufferAlignment))) {
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
DCHECK_GE(stride_y, width);
DCHECK_GE(stride_u, (width + 1) / 2);
DCHECK_GE(stride_v, (width + 1) / 2);
RTC_DCHECK_GT(width, 0);
RTC_DCHECK_GT(height, 0);
RTC_DCHECK_GE(stride_y, width);
RTC_DCHECK_GE(stride_u, (width + 1) / 2);
RTC_DCHECK_GE(stride_v, (width + 1) / 2);
}
I420Buffer::~I420Buffer() {
@ -82,7 +82,7 @@ const uint8_t* I420Buffer::data(PlaneType type) const {
}
uint8_t* I420Buffer::MutableData(PlaneType type) {
DCHECK(HasOneRef());
RTC_DCHECK(HasOneRef());
return const_cast<uint8_t*>(
static_cast<const VideoFrameBuffer*>(this)->data(type));
}
@ -114,9 +114,9 @@ NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
int width,
int height)
: native_handle_(native_handle), width_(width), height_(height) {
DCHECK(native_handle != nullptr);
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
RTC_DCHECK(native_handle != nullptr);
RTC_DCHECK_GT(width, 0);
RTC_DCHECK_GT(height, 0);
}
int NativeHandleBuffer::width() const {
@ -214,9 +214,9 @@ rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop(
const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
int cropped_width,
int cropped_height) {
CHECK(buffer->native_handle() == nullptr);
CHECK_LE(cropped_width, buffer->width());
CHECK_LE(cropped_height, buffer->height());
RTC_CHECK(buffer->native_handle() == nullptr);
RTC_CHECK_LE(cropped_width, buffer->width());
RTC_CHECK_LE(cropped_height, buffer->height());
if (buffer->width() == cropped_width && buffer->height() == cropped_height)
return buffer;

View File

@ -26,11 +26,11 @@ AudioEncoder::EncodedInfo AudioEncoder::Encode(uint32_t rtp_timestamp,
size_t num_samples_per_channel,
size_t max_encoded_bytes,
uint8_t* encoded) {
CHECK_EQ(num_samples_per_channel,
static_cast<size_t>(SampleRateHz() / 100));
RTC_CHECK_EQ(num_samples_per_channel,
static_cast<size_t>(SampleRateHz() / 100));
EncodedInfo info =
EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded);
CHECK_LE(info.encoded_bytes, max_encoded_bytes);
RTC_CHECK_LE(info.encoded_bytes, max_encoded_bytes);
return info;
}

View File

@ -24,9 +24,10 @@ rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> CreateCngInst(
int sid_frame_interval_ms,
int num_cng_coefficients) {
rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> cng_inst;
CHECK_EQ(0, WebRtcCng_CreateEnc(cng_inst.accept()));
CHECK_EQ(0, WebRtcCng_InitEnc(cng_inst.get(), sample_rate_hz,
sid_frame_interval_ms, num_cng_coefficients));
RTC_CHECK_EQ(0, WebRtcCng_CreateEnc(cng_inst.accept()));
RTC_CHECK_EQ(0,
WebRtcCng_InitEnc(cng_inst.get(), sample_rate_hz,
sid_frame_interval_ms, num_cng_coefficients));
return cng_inst;
}
@ -56,7 +57,7 @@ AudioEncoderCng::AudioEncoderCng(const Config& config)
last_frame_active_(true),
vad_(config.vad ? rtc_make_scoped_ptr(config.vad)
: CreateVad(config.vad_mode)) {
CHECK(config.IsOk()) << "Invalid configuration.";
RTC_CHECK(config.IsOk()) << "Invalid configuration.";
cng_inst_ = CreateCngInst(SampleRateHz(), sid_frame_interval_ms_,
num_cng_coefficients_);
}
@ -99,10 +100,11 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal(
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded) {
CHECK_GE(max_encoded_bytes, static_cast<size_t>(num_cng_coefficients_ + 1));
RTC_CHECK_GE(max_encoded_bytes,
static_cast<size_t>(num_cng_coefficients_ + 1));
const size_t samples_per_10ms_frame = SamplesPer10msFrame();
CHECK_EQ(speech_buffer_.size(),
rtp_timestamps_.size() * samples_per_10ms_frame);
RTC_CHECK_EQ(speech_buffer_.size(),
rtp_timestamps_.size() * samples_per_10ms_frame);
rtp_timestamps_.push_back(rtp_timestamp);
for (size_t i = 0; i < samples_per_10ms_frame; ++i) {
speech_buffer_.push_back(audio[i]);
@ -111,7 +113,7 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal(
if (rtp_timestamps_.size() < frames_to_encode) {
return EncodedInfo();
}
CHECK_LE(static_cast<int>(frames_to_encode * 10), kMaxFrameSizeMs)
RTC_CHECK_LE(static_cast<int>(frames_to_encode * 10), kMaxFrameSizeMs)
<< "Frame size cannot be larger than " << kMaxFrameSizeMs
<< " ms when using VAD/CNG.";
@ -123,7 +125,7 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal(
(frames_to_encode > 3 ? 3 : frames_to_encode);
if (frames_to_encode == 4)
blocks_in_first_vad_call = 2;
CHECK_GE(frames_to_encode, blocks_in_first_vad_call);
RTC_CHECK_GE(frames_to_encode, blocks_in_first_vad_call);
const size_t blocks_in_second_vad_call =
frames_to_encode - blocks_in_first_vad_call;
@ -206,7 +208,7 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
bool force_sid = last_frame_active_;
bool output_produced = false;
const size_t samples_per_10ms_frame = SamplesPer10msFrame();
CHECK_GE(max_encoded_bytes, frames_to_encode * samples_per_10ms_frame);
RTC_CHECK_GE(max_encoded_bytes, frames_to_encode * samples_per_10ms_frame);
AudioEncoder::EncodedInfo info;
for (size_t i = 0; i < frames_to_encode; ++i) {
// It's important not to pass &info.encoded_bytes directly to
@ -214,12 +216,13 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
// value, in which case we don't want to overwrite any value from an earlier
// iteration.
size_t encoded_bytes_tmp = 0;
CHECK_GE(WebRtcCng_Encode(cng_inst_.get(),
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame,
encoded, &encoded_bytes_tmp, force_sid), 0);
RTC_CHECK_GE(WebRtcCng_Encode(cng_inst_.get(),
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame, encoded,
&encoded_bytes_tmp, force_sid),
0);
if (encoded_bytes_tmp > 0) {
CHECK(!output_produced);
RTC_CHECK(!output_produced);
info.encoded_bytes = encoded_bytes_tmp;
output_produced = true;
force_sid = false;
@ -243,9 +246,10 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(
rtp_timestamps_.front(), &speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame, max_encoded_bytes, encoded);
if (i + 1 == frames_to_encode) {
CHECK_GT(info.encoded_bytes, 0u) << "Encoder didn't deliver data.";
RTC_CHECK_GT(info.encoded_bytes, 0u) << "Encoder didn't deliver data.";
} else {
CHECK_EQ(info.encoded_bytes, 0u) << "Encoder delivered data too early.";
RTC_CHECK_EQ(info.encoded_bytes, 0u)
<< "Encoder delivered data too early.";
}
}
return info;

View File

@ -24,7 +24,7 @@ int16_t NumSamplesPerFrame(int num_channels,
int frame_size_ms,
int sample_rate_hz) {
int samples_per_frame = num_channels * frame_size_ms * sample_rate_hz / 1000;
CHECK_LE(samples_per_frame, std::numeric_limits<int16_t>::max())
RTC_CHECK_LE(samples_per_frame, std::numeric_limits<int16_t>::max())
<< "Frame size too large.";
return static_cast<int16_t>(samples_per_frame);
}
@ -54,8 +54,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz)
config.frame_size_ms,
sample_rate_hz_)),
first_timestamp_in_buffer_(0) {
CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
CHECK_EQ(config.frame_size_ms % 10, 0)
RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
<< "Frame size must be an integer multiple of 10 ms.";
speech_buffer_.reserve(full_frame_samples_);
}
@ -101,8 +101,8 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal(
if (speech_buffer_.size() < full_frame_samples_) {
return EncodedInfo();
}
CHECK_EQ(speech_buffer_.size(), full_frame_samples_);
CHECK_GE(max_encoded_bytes, full_frame_samples_);
RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_);
RTC_CHECK_GE(max_encoded_bytes, full_frame_samples_);
EncodedInfo info;
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;

View File

@ -45,7 +45,7 @@ AudioEncoderG722::AudioEncoderG722(const Config& config)
first_timestamp_in_buffer_(0),
encoders_(new EncoderState[num_channels_]),
interleave_buffer_(2 * num_channels_) {
CHECK(config.IsOk());
RTC_CHECK(config.IsOk());
const size_t samples_per_channel =
kSampleRateHz / 100 * num_10ms_frames_per_packet_;
for (int i = 0; i < num_channels_; ++i) {
@ -96,7 +96,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded) {
CHECK_GE(max_encoded_bytes, MaxEncodedBytes());
RTC_CHECK_GE(max_encoded_bytes, MaxEncodedBytes());
if (num_10ms_frames_buffered_ == 0)
first_timestamp_in_buffer_ = rtp_timestamp;
@ -113,14 +113,14 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
}
// Encode each channel separately.
CHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
RTC_CHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
num_10ms_frames_buffered_ = 0;
const size_t samples_per_channel = SamplesPerChannel();
for (int i = 0; i < num_channels_; ++i) {
const size_t encoded = WebRtcG722_Encode(
encoders_[i].encoder, encoders_[i].speech_buffer.get(),
samples_per_channel, encoders_[i].encoded_buffer.data());
CHECK_EQ(encoded, samples_per_channel / 2);
RTC_CHECK_EQ(encoded, samples_per_channel / 2);
}
// Interleave the encoded bytes of the different channels. Each separate
@ -146,15 +146,15 @@ AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal(
void AudioEncoderG722::Reset() {
num_10ms_frames_buffered_ = 0;
for (int i = 0; i < num_channels_; ++i)
CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder));
RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder));
}
AudioEncoderG722::EncoderState::EncoderState() {
CHECK_EQ(0, WebRtcG722_CreateEncoder(&encoder));
RTC_CHECK_EQ(0, WebRtcG722_CreateEncoder(&encoder));
}
AudioEncoderG722::EncoderState::~EncoderState() {
CHECK_EQ(0, WebRtcG722_FreeEncoder(encoder));
RTC_CHECK_EQ(0, WebRtcG722_FreeEncoder(encoder));
}
size_t AudioEncoderG722::SamplesPerChannel() const {

View File

@ -33,7 +33,7 @@ int AudioDecoderIlbc::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 8000);
RTC_DCHECK_EQ(sample_rate_hz, 8000);
int16_t temp_type = 1; // Default is speech.
int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, encoded_len, decoded,
&temp_type);

View File

@ -53,7 +53,7 @@ AudioEncoderIlbc::AudioEncoderIlbc(const CodecInst& codec_inst)
: AudioEncoderIlbc(CreateConfig(codec_inst)) {}
AudioEncoderIlbc::~AudioEncoderIlbc() {
CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
}
size_t AudioEncoderIlbc::MaxEncodedBytes() const {
@ -94,7 +94,7 @@ AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal(
const int16_t* audio,
size_t max_encoded_bytes,
uint8_t* encoded) {
DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes());
RTC_DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes());
// Save timestamp if starting a new packet.
if (num_10ms_frames_buffered_ == 0)
@ -112,17 +112,17 @@ AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal(
}
// Encode buffered input.
DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
num_10ms_frames_buffered_ = 0;
const int output_len = WebRtcIlbcfix_Encode(
encoder_,
input_buffer_,
kSampleRateHz / 100 * num_10ms_frames_per_packet_,
encoded);
CHECK_GE(output_len, 0);
RTC_CHECK_GE(output_len, 0);
EncodedInfo info;
info.encoded_bytes = static_cast<size_t>(output_len);
DCHECK_EQ(info.encoded_bytes, RequiredOutputSizeBytes());
RTC_DCHECK_EQ(info.encoded_bytes, RequiredOutputSizeBytes());
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = config_.payload_type;
return info;
@ -130,13 +130,13 @@ AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal(
void AudioEncoderIlbc::Reset() {
if (encoder_)
CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
CHECK(config_.IsOk());
CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
RTC_CHECK(config_.IsOk());
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
const int encoder_frame_size_ms = config_.frame_size_ms > 30
? config_.frame_size_ms / 2
: config_.frame_size_ms;
CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms));
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms));
num_10ms_frames_buffered_ = 0;
}

View File

@ -78,7 +78,7 @@ AudioEncoderIsacT<T>::AudioEncoderIsacT(const CodecInst& codec_inst,
template <typename T>
AudioEncoderIsacT<T>::~AudioEncoderIsacT() {
CHECK_EQ(0, T::Free(isac_state_));
RTC_CHECK_EQ(0, T::Free(isac_state_));
}
template <typename T>
@ -132,12 +132,12 @@ AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal(
T::SetBandwidthInfo(isac_state_, &bwinfo);
}
int r = T::Encode(isac_state_, audio, encoded);
CHECK_GE(r, 0) << "Encode failed (error code " << T::GetErrorCode(isac_state_)
<< ")";
RTC_CHECK_GE(r, 0) << "Encode failed (error code "
<< T::GetErrorCode(isac_state_) << ")";
// T::Encode doesn't allow us to tell it the size of the output
// buffer. All we can do is check for an overrun after the fact.
CHECK_LE(static_cast<size_t>(r), max_encoded_bytes);
RTC_CHECK_LE(static_cast<size_t>(r), max_encoded_bytes);
if (r == 0)
return EncodedInfo();
@ -159,26 +159,26 @@ void AudioEncoderIsacT<T>::Reset() {
template <typename T>
void AudioEncoderIsacT<T>::RecreateEncoderInstance(const Config& config) {
CHECK(config.IsOk());
RTC_CHECK(config.IsOk());
packet_in_progress_ = false;
bwinfo_ = config.bwinfo;
if (isac_state_)
CHECK_EQ(0, T::Free(isac_state_));
CHECK_EQ(0, T::Create(&isac_state_));
CHECK_EQ(0, T::EncoderInit(isac_state_, config.adaptive_mode ? 0 : 1));
CHECK_EQ(0, T::SetEncSampRate(isac_state_, config.sample_rate_hz));
RTC_CHECK_EQ(0, T::Free(isac_state_));
RTC_CHECK_EQ(0, T::Create(&isac_state_));
RTC_CHECK_EQ(0, T::EncoderInit(isac_state_, config.adaptive_mode ? 0 : 1));
RTC_CHECK_EQ(0, T::SetEncSampRate(isac_state_, config.sample_rate_hz));
const int bit_rate = config.bit_rate == 0 ? kDefaultBitRate : config.bit_rate;
if (config.adaptive_mode) {
CHECK_EQ(0, T::ControlBwe(isac_state_, bit_rate, config.frame_size_ms,
config.enforce_frame_size));
RTC_CHECK_EQ(0, T::ControlBwe(isac_state_, bit_rate, config.frame_size_ms,
config.enforce_frame_size));
} else {
CHECK_EQ(0, T::Control(isac_state_, bit_rate, config.frame_size_ms));
RTC_CHECK_EQ(0, T::Control(isac_state_, bit_rate, config.frame_size_ms));
}
if (config.max_payload_size_bytes != -1)
CHECK_EQ(0,
T::SetMaxPayloadSize(isac_state_, config.max_payload_size_bytes));
RTC_CHECK_EQ(
0, T::SetMaxPayloadSize(isac_state_, config.max_payload_size_bytes));
if (config.max_bit_rate != -1)
CHECK_EQ(0, T::SetMaxRate(isac_state_, config.max_bit_rate));
RTC_CHECK_EQ(0, T::SetMaxRate(isac_state_, config.max_bit_rate));
// When config.sample_rate_hz is set to 48000 Hz (iSAC-fb), the decoder is
// still set to 32000 Hz, since there is no full-band mode in the decoder.
@ -188,7 +188,7 @@ void AudioEncoderIsacT<T>::RecreateEncoderInstance(const Config& config) {
// doesn't appear to be necessary to produce a valid encoding, but without it
// we get an encoding that isn't bit-for-bit identical with what a combined
// encoder+decoder object produces.
CHECK_EQ(0, T::SetDecSampRate(isac_state_, decoder_sample_rate_hz));
RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, decoder_sample_rate_hz));
config_ = config;
}
@ -200,7 +200,7 @@ AudioDecoderIsacT<T>::AudioDecoderIsacT()
template <typename T>
AudioDecoderIsacT<T>::AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo)
: bwinfo_(bwinfo), decoder_sample_rate_hz_(-1) {
CHECK_EQ(0, T::Create(&isac_state_));
RTC_CHECK_EQ(0, T::Create(&isac_state_));
T::DecoderInit(isac_state_);
if (bwinfo_) {
IsacBandwidthInfo bi;
@ -211,7 +211,7 @@ AudioDecoderIsacT<T>::AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo)
template <typename T>
AudioDecoderIsacT<T>::~AudioDecoderIsacT() {
CHECK_EQ(0, T::Free(isac_state_));
RTC_CHECK_EQ(0, T::Free(isac_state_));
}
template <typename T>
@ -224,10 +224,10 @@ int AudioDecoderIsacT<T>::DecodeInternal(const uint8_t* encoded,
// in fact it outputs 32000 Hz. This is the iSAC fullband mode.
if (sample_rate_hz == 48000)
sample_rate_hz = 32000;
CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000)
RTC_CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000)
<< "Unsupported sample rate " << sample_rate_hz;
if (sample_rate_hz != decoder_sample_rate_hz_) {
CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
decoder_sample_rate_hz_ = sample_rate_hz;
}
int16_t temp_type = 1; // Default is speech.

View File

@ -84,17 +84,17 @@ struct IsacFix {
}
static inline int16_t SetDecSampRate(instance_type* inst,
uint16_t sample_rate_hz) {
DCHECK_EQ(sample_rate_hz, kFixSampleRate);
RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
return 0;
}
static inline int16_t SetEncSampRate(instance_type* inst,
uint16_t sample_rate_hz) {
DCHECK_EQ(sample_rate_hz, kFixSampleRate);
RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
return 0;
}
static inline void SetEncSampRateInDecoder(instance_type* inst,
uint16_t sample_rate_hz) {
DCHECK_EQ(sample_rate_hz, kFixSampleRate);
RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
}
static inline void SetInitialBweBottleneck(
instance_type* inst,

View File

@ -16,7 +16,7 @@ namespace webrtc {
AudioDecoderOpus::AudioDecoderOpus(size_t num_channels)
: channels_(num_channels) {
DCHECK(num_channels == 1 || num_channels == 2);
RTC_DCHECK(num_channels == 1 || num_channels == 2);
WebRtcOpus_DecoderCreate(&dec_state_, static_cast<int>(channels_));
WebRtcOpus_DecoderInit(dec_state_);
}
@ -30,7 +30,7 @@ int AudioDecoderOpus::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 48000);
RTC_DCHECK_EQ(sample_rate_hz, 48000);
int16_t temp_type = 1; // Default is speech.
int ret =
WebRtcOpus_Decode(dec_state_, encoded, encoded_len, decoded, &temp_type);
@ -51,7 +51,7 @@ int AudioDecoderOpus::DecodeRedundantInternal(const uint8_t* encoded,
speech_type);
}
DCHECK_EQ(sample_rate_hz, 48000);
RTC_DCHECK_EQ(sample_rate_hz, 48000);
int16_t temp_type = 1; // Default is speech.
int ret = WebRtcOpus_DecodeFec(dec_state_, encoded, encoded_len, decoded,
&temp_type);

View File

@ -41,10 +41,10 @@ AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) {
// a loss rate from below, a higher threshold is used than jumping to the same
// level from above.
double OptimizePacketLossRate(double new_loss_rate, double old_loss_rate) {
DCHECK_GE(new_loss_rate, 0.0);
DCHECK_LE(new_loss_rate, 1.0);
DCHECK_GE(old_loss_rate, 0.0);
DCHECK_LE(old_loss_rate, 1.0);
RTC_DCHECK_GE(new_loss_rate, 0.0);
RTC_DCHECK_LE(new_loss_rate, 1.0);
RTC_DCHECK_GE(old_loss_rate, 0.0);
RTC_DCHECK_LE(old_loss_rate, 1.0);
const double kPacketLossRate20 = 0.20;
const double kPacketLossRate10 = 0.10;
const double kPacketLossRate5 = 0.05;
@ -90,14 +90,14 @@ bool AudioEncoderOpus::Config::IsOk() const {
AudioEncoderOpus::AudioEncoderOpus(const Config& config)
: packet_loss_rate_(0.0), inst_(nullptr) {
CHECK(RecreateEncoderInstance(config));
RTC_CHECK(RecreateEncoderInstance(config));
}
AudioEncoderOpus::AudioEncoderOpus(const CodecInst& codec_inst)
: AudioEncoderOpus(CreateConfig(codec_inst)) {}
AudioEncoderOpus::~AudioEncoderOpus() {
CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
}
size_t AudioEncoderOpus::MaxEncodedBytes() const {
@ -143,14 +143,15 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
(static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame())) {
return EncodedInfo();
}
CHECK_EQ(input_buffer_.size(), static_cast<size_t>(Num10msFramesPerPacket()) *
SamplesPer10msFrame());
RTC_CHECK_EQ(
input_buffer_.size(),
static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame());
int status = WebRtcOpus_Encode(
inst_, &input_buffer_[0],
rtc::CheckedDivExact(input_buffer_.size(),
static_cast<size_t>(config_.num_channels)),
rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded);
CHECK_GE(status, 0); // Fails only if fed invalid data.
RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
input_buffer_.clear();
EncodedInfo info;
info.encoded_bytes = static_cast<size_t>(status);
@ -162,7 +163,7 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
}
void AudioEncoderOpus::Reset() {
CHECK(RecreateEncoderInstance(config_));
RTC_CHECK(RecreateEncoderInstance(config_));
}
bool AudioEncoderOpus::SetFec(bool enable) {
@ -193,23 +194,24 @@ bool AudioEncoderOpus::SetApplication(Application application) {
void AudioEncoderOpus::SetMaxPlaybackRate(int frequency_hz) {
auto conf = config_;
conf.max_playback_rate_hz = frequency_hz;
CHECK(RecreateEncoderInstance(conf));
RTC_CHECK(RecreateEncoderInstance(conf));
}
void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) {
double opt_loss_rate = OptimizePacketLossRate(fraction, packet_loss_rate_);
if (packet_loss_rate_ != opt_loss_rate) {
packet_loss_rate_ = opt_loss_rate;
CHECK_EQ(0, WebRtcOpus_SetPacketLossRate(
inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
RTC_CHECK_EQ(
0, WebRtcOpus_SetPacketLossRate(
inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
}
}
void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) {
config_.bitrate_bps =
std::max(std::min(bits_per_second, kMaxBitrateBps), kMinBitrateBps);
DCHECK(config_.IsOk());
CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
RTC_DCHECK(config_.IsOk());
RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
}
int AudioEncoderOpus::Num10msFramesPerPacket() const {
@ -227,27 +229,28 @@ bool AudioEncoderOpus::RecreateEncoderInstance(const Config& config) {
if (!config.IsOk())
return false;
if (inst_)
CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
input_buffer_.clear();
input_buffer_.reserve(Num10msFramesPerPacket() * SamplesPer10msFrame());
CHECK_EQ(0, WebRtcOpus_EncoderCreate(&inst_, config.num_channels,
config.application));
CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config.bitrate_bps));
RTC_CHECK_EQ(0, WebRtcOpus_EncoderCreate(&inst_, config.num_channels,
config.application));
RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config.bitrate_bps));
if (config.fec_enabled) {
CHECK_EQ(0, WebRtcOpus_EnableFec(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_EnableFec(inst_));
} else {
CHECK_EQ(0, WebRtcOpus_DisableFec(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_DisableFec(inst_));
}
CHECK_EQ(0,
WebRtcOpus_SetMaxPlaybackRate(inst_, config.max_playback_rate_hz));
CHECK_EQ(0, WebRtcOpus_SetComplexity(inst_, config.complexity));
RTC_CHECK_EQ(
0, WebRtcOpus_SetMaxPlaybackRate(inst_, config.max_playback_rate_hz));
RTC_CHECK_EQ(0, WebRtcOpus_SetComplexity(inst_, config.complexity));
if (config.dtx_enabled) {
CHECK_EQ(0, WebRtcOpus_EnableDtx(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_EnableDtx(inst_));
} else {
CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_));
RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_));
}
CHECK_EQ(0, WebRtcOpus_SetPacketLossRate(
inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
RTC_CHECK_EQ(0,
WebRtcOpus_SetPacketLossRate(
inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
config_ = config;
return true;
}

View File

@ -104,7 +104,7 @@ namespace {
// Returns a vector with the n evenly-spaced numbers a, a + (b - a)/(n - 1),
// ..., b.
std::vector<double> IntervalSteps(double a, double b, size_t n) {
DCHECK_GT(n, 1u);
RTC_DCHECK_GT(n, 1u);
const double step = (b - a) / (n - 1);
std::vector<double> points;
for (size_t i = 0; i < n; ++i)

View File

@ -28,8 +28,8 @@ int AudioDecoderPcm16B::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
sample_rate_hz == 32000 || sample_rate_hz == 48000)
RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
sample_rate_hz == 32000 || sample_rate_hz == 48000)
<< "Unsupported sample rate " << sample_rate_hz;
size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded);
*speech_type = ConvertSpeechType(1);
@ -44,7 +44,7 @@ int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded,
AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh(size_t num_channels)
: channels_(num_channels) {
DCHECK(num_channels > 0);
RTC_DCHECK(num_channels > 0);
}
size_t AudioDecoderPcm16BMultiCh::Channels() const {

View File

@ -19,7 +19,7 @@ namespace webrtc {
AudioEncoderCopyRed::AudioEncoderCopyRed(const Config& config)
: speech_encoder_(config.speech_encoder),
red_payload_type_(config.payload_type) {
CHECK(speech_encoder_) << "Speech encoder not provided.";
RTC_CHECK(speech_encoder_) << "Speech encoder not provided.";
}
AudioEncoderCopyRed::~AudioEncoderCopyRed() = default;
@ -60,26 +60,26 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal(
EncodedInfo info = speech_encoder_->Encode(
rtp_timestamp, audio, static_cast<size_t>(SampleRateHz() / 100),
max_encoded_bytes, encoded);
CHECK_GE(max_encoded_bytes,
info.encoded_bytes + secondary_info_.encoded_bytes);
CHECK(info.redundant.empty()) << "Cannot use nested redundant encoders.";
RTC_CHECK_GE(max_encoded_bytes,
info.encoded_bytes + secondary_info_.encoded_bytes);
RTC_CHECK(info.redundant.empty()) << "Cannot use nested redundant encoders.";
if (info.encoded_bytes > 0) {
// |info| will be implicitly cast to an EncodedInfoLeaf struct, effectively
// discarding the (empty) vector of redundant information. This is
// intentional.
info.redundant.push_back(info);
DCHECK_EQ(info.redundant.size(), 1u);
RTC_DCHECK_EQ(info.redundant.size(), 1u);
if (secondary_info_.encoded_bytes > 0) {
memcpy(&encoded[info.encoded_bytes], secondary_encoded_.data(),
secondary_info_.encoded_bytes);
info.redundant.push_back(secondary_info_);
DCHECK_EQ(info.redundant.size(), 2u);
RTC_DCHECK_EQ(info.redundant.size(), 2u);
}
// Save primary to secondary.
secondary_encoded_.SetData(encoded, info.encoded_bytes);
secondary_info_ = info;
DCHECK_EQ(info.speech, info.redundant[0].speech);
RTC_DCHECK_EQ(info.speech, info.redundant[0].speech);
}
// Update main EncodedInfo.
info.payload_type = red_payload_type_;

View File

@ -87,8 +87,8 @@ class MockEncodeHelper {
size_t max_encoded_bytes,
uint8_t* encoded) {
if (write_payload_) {
CHECK(encoded);
CHECK_LE(info_.encoded_bytes, max_encoded_bytes);
RTC_CHECK(encoded);
RTC_CHECK_LE(info_.encoded_bytes, max_encoded_bytes);
memcpy(encoded, payload_, info_.encoded_bytes);
}
return info_;

View File

@ -71,7 +71,8 @@ Packet* AcmSendTest::NextPacket() {
// Insert audio and process until one packet is produced.
while (clock_.TimeInMilliseconds() < test_duration_ms_) {
clock_.AdvanceTimeMilliseconds(kBlockSizeMs);
CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.data_));
RTC_CHECK(
audio_source_->Read(input_block_size_samples_, input_frame_.data_));
if (input_frame_.num_channels_ > 1) {
InputAudioFile::DuplicateInterleaved(input_frame_.data_,
input_block_size_samples_,

View File

@ -53,8 +53,8 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
int payload_type,
int frame_size_samples) {
CodecInst codec;
CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec, sampling_freq_hz,
channels));
RTC_CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec,
sampling_freq_hz, channels));
codec.pltype = payload_type;
codec.pacsize = frame_size_samples;
codec_registered_ = (acm_->RegisterSendCodec(codec) == 0);
@ -84,7 +84,8 @@ Packet* AcmSendTestOldApi::NextPacket() {
// Insert audio and process until one packet is produced.
while (clock_.TimeInMilliseconds() < test_duration_ms_) {
clock_.AdvanceTimeMilliseconds(kBlockSizeMs);
CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.data_));
RTC_CHECK(
audio_source_->Read(input_block_size_samples_, input_frame_.data_));
if (input_frame_.num_channels_ > 1) {
InputAudioFile::DuplicateInterleaved(input_frame_.data_,
input_block_size_samples_,
@ -92,7 +93,7 @@ Packet* AcmSendTestOldApi::NextPacket() {
input_frame_.data_);
}
data_to_send_ = false;
CHECK_GE(acm_->Add10MsData(input_frame_), 0);
RTC_CHECK_GE(acm_->Add10MsData(input_frame_), 0);
input_frame_.timestamp_ += static_cast<uint32_t>(input_block_size_samples_);
if (data_to_send_) {
// Encoded packet received.

View File

@ -199,7 +199,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
frame_type = kFrameEmpty;
encoded_info.payload_type = previous_pltype;
} else {
DCHECK_GT(encode_buffer_.size(), 0u);
RTC_DCHECK_GT(encode_buffer_.size(), 0u);
frame_type = encoded_info.speech ? kAudioFrameSpeech : kAudioFrameCN;
}
@ -500,7 +500,7 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
bool enable_vad,
ACMVADMode mode) {
// Note: |enable_vad| is not used; VAD is enabled based on the DTX setting.
DCHECK_EQ(enable_dtx, enable_vad);
RTC_DCHECK_EQ(enable_dtx, enable_vad);
CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.SetVAD(enable_dtx, mode);
}
@ -580,7 +580,7 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
// for codecs, CNG (NB, WB and SWB), DTMF, RED.
int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
CriticalSectionScoped lock(acm_crit_sect_.get());
DCHECK(receiver_initialized_);
RTC_DCHECK(receiver_initialized_);
if (codec.channels > 2 || codec.channels < 0) {
LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
return -1;
@ -612,7 +612,7 @@ int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
int sample_rate_hz,
int num_channels) {
CriticalSectionScoped lock(acm_crit_sect_.get());
DCHECK(receiver_initialized_);
RTC_DCHECK(receiver_initialized_);
if (num_channels > 2 || num_channels < 0) {
LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels;
return -1;

View File

@ -185,7 +185,7 @@ CodecManager::CodecManager()
CodecManager::~CodecManager() = default;
int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
int codec_id = IsValidSendCodec(send_codec, true);
// Check for reported errors from function IsValidSendCodec().
@ -264,7 +264,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
bool new_codec = true;
if (codec_owner_.Encoder()) {
int new_codec_id = ACMCodecDB::CodecNumber(send_codec_inst_);
DCHECK_GE(new_codec_id, 0);
RTC_DCHECK_GE(new_codec_id, 0);
new_codec = new_codec_id != codec_id;
}
@ -276,7 +276,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
if (new_codec) {
// This is a new codec. Register it and return.
DCHECK(CodecSupported(send_codec));
RTC_DCHECK(CodecSupported(send_codec));
if (IsOpus(send_codec)) {
// VAD/DTX not supported.
dtx_enabled_ = false;
@ -284,7 +284,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
codec_owner_.SetEncoders(
send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1);
DCHECK(codec_owner_.Encoder());
RTC_DCHECK(codec_owner_.Encoder());
codec_fec_enabled_ = codec_fec_enabled_ &&
codec_owner_.Encoder()->SetFec(codec_fec_enabled_);
@ -300,7 +300,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
codec_owner_.SetEncoders(
send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1);
DCHECK(codec_owner_.Encoder());
RTC_DCHECK(codec_owner_.Encoder());
}
send_codec_inst_.plfreq = send_codec.plfreq;
send_codec_inst_.pacsize = send_codec.pacsize;
@ -381,8 +381,8 @@ bool CodecManager::SetCopyRed(bool enable) {
int CodecManager::SetVAD(bool enable, ACMVADMode mode) {
// Sanity check of the mode.
DCHECK(mode == VADNormal || mode == VADLowBitrate || mode == VADAggr ||
mode == VADVeryAggr);
RTC_DCHECK(mode == VADNormal || mode == VADLowBitrate || mode == VADAggr ||
mode == VADVeryAggr);
// Check that the send codec is mono. We don't support VAD/DTX for stereo
// sending.
@ -427,7 +427,7 @@ int CodecManager::SetCodecFEC(bool enable_codec_fec) {
return -1;
}
CHECK(codec_owner_.Encoder());
RTC_CHECK(codec_owner_.Encoder());
codec_fec_enabled_ =
codec_owner_.Encoder()->SetFec(enable_codec_fec) && enable_codec_fec;
return codec_fec_enabled_ == enable_codec_fec ? 0 : -1;

View File

@ -202,7 +202,7 @@ void CodecOwner::ChangeCngAndRed(int cng_payload_type,
AudioEncoder* encoder =
CreateRedEncoder(red_payload_type, speech_encoder, &red_encoder_);
CreateCngEncoder(cng_payload_type, vad_mode, encoder, &cng_encoder_);
DCHECK_EQ(!!speech_encoder_ + !!external_speech_encoder_, 1);
RTC_DCHECK_EQ(!!speech_encoder_ + !!external_speech_encoder_, 1);
}
AudioDecoder* CodecOwner::GetIsacDecoder() {
@ -230,7 +230,7 @@ AudioEncoder* CodecOwner::SpeechEncoder() {
}
const AudioEncoder* CodecOwner::SpeechEncoder() const {
DCHECK(!speech_encoder_ || !external_speech_encoder_);
RTC_DCHECK(!speech_encoder_ || !external_speech_encoder_);
return external_speech_encoder_ ? external_speech_encoder_
: speech_encoder_.get();
}

View File

@ -48,7 +48,7 @@ int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 8000);
RTC_DCHECK_EQ(sample_rate_hz, 8000);
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
@ -78,7 +78,7 @@ int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 8000);
RTC_DCHECK_EQ(sample_rate_hz, 8000);
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
@ -115,7 +115,7 @@ int AudioDecoderG722::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 16000);
RTC_DCHECK_EQ(sample_rate_hz, 16000);
int16_t temp_type = 1; // Default is speech.
size_t ret =
WebRtcG722_Decode(dec_state_, encoded, encoded_len, decoded, &temp_type);
@ -154,7 +154,7 @@ int AudioDecoderG722Stereo::DecodeInternal(const uint8_t* encoded,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
DCHECK_EQ(sample_rate_hz, 16000);
RTC_DCHECK_EQ(sample_rate_hz, 16000);
int16_t temp_type = 1; // Default is speech.
// De-interleave the bit-stream into two separate payloads.
uint8_t* encoded_deinterleaved = new uint8_t[encoded_len];
@ -218,7 +218,7 @@ void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,
#endif
AudioDecoderCng::AudioDecoderCng() {
CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_));
RTC_CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_));
WebRtcCng_InitDec(dec_state_);
}

Some files were not shown because too many files have changed in this diff Show More