Reland of Switch to use SequencedTaskChecker instead of ThreadChecker where needed.

(patchset #1 id:1 of https://codereview.webrtc.org/2149553002/ )"
This reverts commit efd902cb1d9bbd81247a3e168f2080beae761d78.

Originally reviewed in https://codereview.webrtc.org/2149553002

The uptream problem should be fixed by https://codereview.webrtc.org/2145393003/

BUG=webrtc:5687
TBR=tommi@webrtc.org

Review-Url: https://codereview.webrtc.org/2152013002
Cr-Commit-Position: refs/heads/master@{#13483}
This commit is contained in:
perkj
2016-07-14 23:35:55 -07:00
committed by Commit bot
parent 32012f8c3a
commit 4e417b242a
11 changed files with 19 additions and 14 deletions

View File

@ -58,6 +58,7 @@ source_set("common_video") {
deps = [ deps = [
"..:webrtc_common", "..:webrtc_common",
"../base:rtc_task_queue",
"../system_wrappers", "../system_wrappers",
] ]

View File

@ -18,6 +18,7 @@
'libyuv/include', 'libyuv/include',
], ],
'dependencies': [ 'dependencies': [
'<(webrtc_root)/base/base.gyp:rtc_task_queue',
'<(webrtc_root)/common.gyp:webrtc_common', '<(webrtc_root)/common.gyp:webrtc_common',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
], ],

View File

@ -16,17 +16,17 @@ namespace webrtc {
I420BufferPool::I420BufferPool(bool zero_initialize) I420BufferPool::I420BufferPool(bool zero_initialize)
: zero_initialize_(zero_initialize) { : zero_initialize_(zero_initialize) {
thread_checker_.DetachFromThread(); sequenced_checker_.Detach();
} }
void I420BufferPool::Release() { void I420BufferPool::Release() {
thread_checker_.DetachFromThread(); sequenced_checker_.Detach();
buffers_.clear(); buffers_.clear();
} }
rtc::scoped_refptr<I420Buffer> I420BufferPool::CreateBuffer(int width, rtc::scoped_refptr<I420Buffer> I420BufferPool::CreateBuffer(int width,
int height) { int height) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(sequenced_checker_.CalledSequentially());
// Release buffers with wrong resolution. // Release buffers with wrong resolution.
for (auto it = buffers_.begin(); it != buffers_.end();) { for (auto it = buffers_.begin(); it != buffers_.end();) {
if ((*it)->width() != width || (*it)->height() != height) if ((*it)->width() != width || (*it)->height() != height)

View File

@ -13,7 +13,7 @@
#include <list> #include <list>
#include "webrtc/base/thread_checker.h" #include "webrtc/base/sequenced_task_checker.h"
#include "webrtc/common_video/include/video_frame_buffer.h" #include "webrtc/common_video/include/video_frame_buffer.h"
namespace webrtc { namespace webrtc {
@ -40,7 +40,7 @@ class I420BufferPool {
// needed by the pool to check exclusive access. // needed by the pool to check exclusive access.
using PooledI420Buffer = rtc::RefCountedObject<I420Buffer>; using PooledI420Buffer = rtc::RefCountedObject<I420Buffer>;
rtc::ThreadChecker thread_checker_; rtc::SequencedTaskChecker sequenced_checker_;
std::list<rtc::scoped_refptr<PooledI420Buffer>> buffers_; std::list<rtc::scoped_refptr<PooledI420Buffer>> buffers_;
// If true, newly allocated buffers are zero-initialized. Note that recycled // If true, newly allocated buffers are zero-initialized. Note that recycled
// buffers are not zero'd before reuse. This is required of buffers used by // buffers are not zero'd before reuse. This is required of buffers used by

View File

@ -199,6 +199,7 @@
'<(DEPTH)/testing/gmock.gyp:gmock', '<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/testing/gtest.gyp:gtest',
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/media/media.gyp:rtc_media',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [
@ -250,7 +251,6 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/media/media.gyp:rtc_media',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
'<(webrtc_root)/test/test.gyp:test_support', '<(webrtc_root)/test/test.gyp:test_support',
'rtc_unittest_main', 'rtc_unittest_main',

View File

@ -125,6 +125,7 @@ source_set("video_coding_utility") {
} }
deps = [ deps = [
"../../common_video",
"../../system_wrappers", "../../system_wrappers",
] ]
} }

View File

@ -15,6 +15,7 @@
'target_name': 'video_coding_utility', 'target_name': 'video_coding_utility',
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/common_video/common_video.gyp:common_video',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
], ],
'sources': [ 'sources': [

View File

@ -14,6 +14,7 @@
'dependencies': [ 'dependencies': [
'webrtc_h264', 'webrtc_h264',
'webrtc_i420', 'webrtc_i420',
'../base/base.gyp:rtc_task_queue',
'<(webrtc_root)/common_video/common_video.gyp:common_video', '<(webrtc_root)/common_video/common_video.gyp:common_video',
'<(webrtc_root)/modules/video_coding/utility/video_coding_utility.gyp:video_coding_utility', '<(webrtc_root)/modules/video_coding/utility/video_coding_utility.gyp:video_coding_utility',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',

View File

@ -19,7 +19,7 @@
#include "webrtc/base/onetimeevent.h" #include "webrtc/base/onetimeevent.h"
#include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_annotations.h"
#include "webrtc/base/thread_checker.h" #include "webrtc/base/sequenced_task_checker.h"
#include "webrtc/common_video/include/frame_callback.h" #include "webrtc/common_video/include/frame_callback.h"
#include "webrtc/modules/video_coding/codec_database.h" #include "webrtc/modules/video_coding/codec_database.h"
#include "webrtc/modules/video_coding/frame_buffer.h" #include "webrtc/modules/video_coding/frame_buffer.h"
@ -108,8 +108,7 @@ class VideoSender : public Module {
// Must be accessed on the construction thread of VideoSender. // Must be accessed on the construction thread of VideoSender.
VideoCodec current_codec_; VideoCodec current_codec_;
rtc::ThreadChecker main_thread_; rtc::SequencedTaskChecker sequenced_checker_;
rtc::CriticalSection params_crit_; rtc::CriticalSection params_crit_;
EncoderParameters encoder_params_ GUARDED_BY(params_crit_); EncoderParameters encoder_params_ GUARDED_BY(params_crit_);

View File

@ -43,7 +43,7 @@ VideoSender::VideoSender(Clock* clock,
// Allow VideoSender to be created on one thread but used on another, post // Allow VideoSender to be created on one thread but used on another, post
// construction. This is currently how this class is being used by at least // construction. This is currently how this class is being used by at least
// one external project (diffractor). // one external project (diffractor).
main_thread_.DetachFromThread(); sequenced_checker_.Detach();
} }
VideoSender::~VideoSender() {} VideoSender::~VideoSender() {}
@ -82,7 +82,7 @@ int64_t VideoSender::TimeUntilNextProcess() {
int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec, int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
uint32_t numberOfCores, uint32_t numberOfCores,
uint32_t maxPayloadSize) { uint32_t maxPayloadSize) {
RTC_DCHECK(main_thread_.CalledOnValidThread()); RTC_DCHECK(sequenced_checker_.CalledSequentially());
rtc::CritScope lock(&encoder_crit_); rtc::CritScope lock(&encoder_crit_);
if (sendCodec == nullptr) { if (sendCodec == nullptr) {
return VCM_PARAMETER_ERROR; return VCM_PARAMETER_ERROR;
@ -150,7 +150,7 @@ int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder,
uint8_t payloadType, uint8_t payloadType,
bool internalSource /*= false*/) { bool internalSource /*= false*/) {
RTC_DCHECK(main_thread_.CalledOnValidThread()); RTC_DCHECK(sequenced_checker_.CalledSequentially());
rtc::CritScope lock(&encoder_crit_); rtc::CritScope lock(&encoder_crit_);
@ -172,7 +172,7 @@ void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder,
// Get encode bitrate // Get encode bitrate
int VideoSender::Bitrate(unsigned int* bitrate) const { int VideoSender::Bitrate(unsigned int* bitrate) const {
RTC_DCHECK(main_thread_.CalledOnValidThread()); RTC_DCHECK(sequenced_checker_.CalledSequentially());
// Since we're running on the thread that's the only thread known to modify // Since we're running on the thread that's the only thread known to modify
// the value of _encoder, we don't need to grab the lock here. // the value of _encoder, we don't need to grab the lock here.
@ -184,7 +184,7 @@ int VideoSender::Bitrate(unsigned int* bitrate) const {
// Get encode frame rate // Get encode frame rate
int VideoSender::FrameRate(unsigned int* framerate) const { int VideoSender::FrameRate(unsigned int* framerate) const {
RTC_DCHECK(main_thread_.CalledOnValidThread()); RTC_DCHECK(sequenced_checker_.CalledSequentially());
// Since we're running on the thread that's the only thread known to modify // Since we're running on the thread that's the only thread known to modify
// the value of _encoder, we don't need to grab the lock here. // the value of _encoder, we don't need to grab the lock here.

View File

@ -100,6 +100,7 @@ if (rtc_include_tests) {
"video_send_stream_tests.cc", "video_send_stream_tests.cc",
"vie_remb_unittest.cc", "vie_remb_unittest.cc",
] ]
configs += [ "..:common_config" ]
deps = [ deps = [
":video", ":video",
"//testing/gmock", "//testing/gmock",