Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.cc

Issue 2741953002: Step #4: Run VideoProcessor integration test batch mode on task queue. (Closed)
Patch Set: tommi comments 1: Add thread safety annotations. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/test/videoprocessor.cc
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
index 0bb04a99df03d7a193411ab829832e3092343e1a..9822a76dc82007085a2ebaebdd0bdca7da70c53d 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
@@ -114,7 +114,7 @@ TestConfig::TestConfig()
codec_settings(nullptr),
verbose(true) {}
-TestConfig::~TestConfig() {}
+TestConfig::~TestConfig() = default;
VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
webrtc::VideoDecoder* decoder,
@@ -156,9 +156,14 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
RTC_DCHECK(stats);
frame_infos_.reserve(num_frames_);
+
+ task_checker_.Detach();
}
+VideoProcessorImpl::~VideoProcessorImpl() = default;
sprang_webrtc 2017/03/20 19:36:17 nit: Could you declare ~VideoProcessor and ~Video
brandtr 2017/03/21 09:40:54 Done.
+
bool VideoProcessorImpl::Init() {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
RTC_DCHECK(!initialized_)
<< "This VideoProcessor has already been initialized.";
@@ -203,12 +208,14 @@ bool VideoProcessorImpl::Init() {
return true;
}
-VideoProcessorImpl::~VideoProcessorImpl() {
+void VideoProcessorImpl::DeregisterCallbacks() {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
encoder_->RegisterEncodeCompleteCallback(nullptr);
decoder_->RegisterDecodeCompleteCallback(nullptr);
}
void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
int set_rates_result = encoder_->SetRateAllocation(
bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate),
frame_rate);
@@ -219,24 +226,29 @@ void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) {
}
size_t VideoProcessorImpl::EncodedFrameSize(int frame_number) {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
RTC_DCHECK_LT(frame_number, frame_infos_.size());
return frame_infos_[frame_number].encoded_frame_size;
}
FrameType VideoProcessorImpl::EncodedFrameType(int frame_number) {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
RTC_DCHECK_LT(frame_number, frame_infos_.size());
return frame_infos_[frame_number].encoded_frame_type;
}
int VideoProcessorImpl::NumberDroppedFrames() {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
return num_dropped_frames_;
}
int VideoProcessorImpl::NumberSpatialResizes() {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
return num_spatial_resizes_;
}
bool VideoProcessorImpl::ProcessFrame(int frame_number) {
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
RTC_DCHECK_GE(frame_number, 0);
RTC_DCHECK_LE(frame_number, frame_infos_.size())
<< "Must process frames without gaps.";
@@ -299,6 +311,8 @@ void VideoProcessorImpl::FrameEncoded(
// time recordings should wrap the Encode call as tightly as possible.
int64_t encode_stop_ns = rtc::TimeNanos();
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
+
if (encoded_frame_writer_) {
RTC_CHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec));
}
@@ -423,6 +437,8 @@ void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) {
// time recordings should wrap the Decode call as tightly as possible.
int64_t decode_stop_ns = rtc::TimeNanos();
+ RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
+
// Update frame information and statistics.
int frame_number = TimestampToFrameNumber(image.timestamp());
RTC_DCHECK_LT(frame_number, frame_infos_.size());

Powered by Google App Engine
This is Rietveld 408576698