Remove rtc::Location from SendTask test helper

that rtc::Location parameter was used only as extra information for the
RTC_CHECKs directly in the function, thus call stack of the crash should
provide all the information about the caller.

Bug: webrtc:11318
Change-Id: Iec6dd2c5de547f3e1601647a614be7ce57a55734
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270920
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37748}
This commit is contained in:
Danil Chapovalov
2022-08-11 12:26:09 +02:00
committed by WebRTC LUCI CQ
parent e2d829cf77
commit e519f38eaa
37 changed files with 352 additions and 470 deletions

View File

@ -503,7 +503,7 @@ void VideoCodecTestFixtureImpl::ProcessAllFrames(
task_queue->PostTask([this] { processor_->Finalize(); });
// Wait until we know that the last frame has been sent for encode.
task_queue->SendTask([] {}, RTC_FROM_HERE);
task_queue->SendTask([] {});
// Give the VideoProcessor pipeline some time to process the last frame,
// and then release the codecs.
@ -720,11 +720,9 @@ bool VideoCodecTestFixtureImpl::SetUpAndInitObjects(
cpu_process_time_.reset(new CpuProcessTime(config_));
bool is_codec_created = false;
task_queue->SendTask(
[this, &is_codec_created]() {
is_codec_created = CreateEncoderAndDecoder();
},
RTC_FROM_HERE);
task_queue->SendTask([this, &is_codec_created]() {
is_codec_created = CreateEncoderAndDecoder();
});
if (!is_codec_created) {
return false;
@ -778,20 +776,17 @@ bool VideoCodecTestFixtureImpl::SetUpAndInitObjects(
encoder_.get(), &decoders_, source_frame_reader_.get(), config_,
&stats_, &encoded_frame_writers_,
decoded_frame_writers_.empty() ? nullptr : &decoded_frame_writers_);
},
RTC_FROM_HERE);
});
return true;
}
void VideoCodecTestFixtureImpl::ReleaseAndCloseObjects(
TaskQueueForTest* task_queue) {
task_queue->SendTask(
[this]() {
processor_.reset();
// The VideoProcessor must be destroyed before the codecs.
DestroyEncoderAndDecoder();
},
RTC_FROM_HERE);
task_queue->SendTask([this]() {
processor_.reset();
// The VideoProcessor must be destroyed before the codecs.
DestroyEncoderAndDecoder();
});
source_frame_reader_->Close();
@ -810,15 +805,13 @@ std::string VideoCodecTestFixtureImpl::GetCodecName(
TaskQueueForTest* task_queue,
bool is_encoder) const {
std::string codec_name;
task_queue->SendTask(
[this, is_encoder, &codec_name] {
if (is_encoder) {
codec_name = encoder_->GetEncoderInfo().implementation_name;
} else {
codec_name = decoders_.at(0)->ImplementationName();
}
},
RTC_FROM_HERE);
task_queue->SendTask([this, is_encoder, &codec_name] {
if (is_encoder) {
codec_name = encoder_->GetEncoderInfo().implementation_name;
} else {
codec_name = decoders_.at(0)->ImplementationName();
}
});
return codec_name;
}

View File

@ -59,12 +59,11 @@ class VideoProcessorTest : public ::testing::Test {
video_processor_ = std::make_unique<VideoProcessor>(
&encoder_mock_, &decoders_, &frame_reader_mock_, config_, &stats_,
&encoded_frame_writers_, /*decoded_frame_writers=*/nullptr);
},
RTC_FROM_HERE);
});
}
~VideoProcessorTest() {
q_.SendTask([this] { video_processor_.reset(); }, RTC_FROM_HERE);
q_.SendTask([this] { video_processor_.reset(); });
}
void ExpectInit() {
@ -106,8 +105,7 @@ TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kFramerateFps))))
.Times(1);
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); },
RTC_FROM_HERE);
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
EXPECT_CALL(frame_reader_mock_, ReadFrame())
.WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
@ -115,13 +113,13 @@ TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
encoder_mock_,
Encode(Property(&VideoFrame::timestamp, 1 * 90000 / kFramerateFps), _))
.Times(1);
q_.SendTask([this] { video_processor_->ProcessFrame(); }, RTC_FROM_HERE);
q_.SendTask([this] { video_processor_->ProcessFrame(); });
EXPECT_CALL(
encoder_mock_,
Encode(Property(&VideoFrame::timestamp, 2 * 90000 / kFramerateFps), _))
.Times(1);
q_.SendTask([this] { video_processor_->ProcessFrame(); }, RTC_FROM_HERE);
q_.SendTask([this] { video_processor_->ProcessFrame(); });
ExpectRelease();
}
@ -136,15 +134,14 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
static_cast<double>(kStartFramerateFps))))
.Times(1);
q_.SendTask(
[=] { video_processor_->SetRates(kBitrateKbps, kStartFramerateFps); },
RTC_FROM_HERE);
[=] { video_processor_->SetRates(kBitrateKbps, kStartFramerateFps); });
EXPECT_CALL(frame_reader_mock_, ReadFrame())
.WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
EXPECT_CALL(encoder_mock_,
Encode(Property(&VideoFrame::timestamp, kStartTimestamp), _))
.Times(1);
q_.SendTask([this] { video_processor_->ProcessFrame(); }, RTC_FROM_HERE);
q_.SendTask([this] { video_processor_->ProcessFrame(); });
const int kNewFramerateFps = 13;
EXPECT_CALL(
@ -153,15 +150,14 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
static_cast<double>(kNewFramerateFps))))
.Times(1);
q_.SendTask(
[=] { video_processor_->SetRates(kBitrateKbps, kNewFramerateFps); },
RTC_FROM_HERE);
[=] { video_processor_->SetRates(kBitrateKbps, kNewFramerateFps); });
EXPECT_CALL(encoder_mock_,
Encode(Property(&VideoFrame::timestamp,
kStartTimestamp + 90000 / kNewFramerateFps),
_))
.Times(1);
q_.SendTask([this] { video_processor_->ProcessFrame(); }, RTC_FROM_HERE);
q_.SendTask([this] { video_processor_->ProcessFrame(); });
ExpectRelease();
}
@ -180,8 +176,7 @@ TEST_F(VideoProcessorTest, SetRates) {
Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kFramerateFps)))))
.Times(1);
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); },
RTC_FROM_HERE);
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
const uint32_t kNewBitrateKbps = 456;
const int kNewFramerateFps = 34;
@ -196,8 +191,7 @@ TEST_F(VideoProcessorTest, SetRates) {
static_cast<double>(kNewFramerateFps)))))
.Times(1);
q_.SendTask(
[=] { video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps); },
RTC_FROM_HERE);
[=] { video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps); });
ExpectRelease();
}