Remove id from VideoProcessingModule.

Also converts CriticalSectionWrapper to rtc::CriticalSection as a bonus.

BUG=webrtc:1695
R=stefan@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9986}
This commit is contained in:
Peter Boström
2015-09-18 12:24:25 +02:00
parent 3520f9e049
commit f4aa4c2283
5 changed files with 25 additions and 30 deletions

View File

@ -76,7 +76,7 @@ class VideoProcessingModule : public Module {
\return Pointer to a VPM object. \return Pointer to a VPM object.
*/ */
static VideoProcessingModule* Create(int32_t id); static VideoProcessingModule* Create();
/** /**
Destroys a VPM object. Destroys a VPM object.

View File

@ -37,8 +37,8 @@ void SetSubSampling(VideoProcessingModule::FrameStats* stats,
} }
} // namespace } // namespace
VideoProcessingModule* VideoProcessingModule::Create(const int32_t id) { VideoProcessingModule* VideoProcessingModule::Create() {
return new VideoProcessingModuleImpl(id); return new VideoProcessingModuleImpl();
} }
void VideoProcessingModule::Destroy(VideoProcessingModule* module) { void VideoProcessingModule::Destroy(VideoProcessingModule* module) {
@ -46,16 +46,11 @@ void VideoProcessingModule::Destroy(VideoProcessingModule* module) {
delete static_cast<VideoProcessingModuleImpl*>(module); delete static_cast<VideoProcessingModuleImpl*>(module);
} }
VideoProcessingModuleImpl::VideoProcessingModuleImpl(const int32_t id) VideoProcessingModuleImpl::VideoProcessingModuleImpl() {}
: mutex_(*CriticalSectionWrapper::CreateCriticalSection()) { VideoProcessingModuleImpl::~VideoProcessingModuleImpl() {}
}
VideoProcessingModuleImpl::~VideoProcessingModuleImpl() {
delete &mutex_;
}
void VideoProcessingModuleImpl::Reset() { void VideoProcessingModuleImpl::Reset() {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
deflickering_.Reset(); deflickering_.Reset();
brightness_detection_.Reset(); brightness_detection_.Reset();
frame_pre_processor_.Reset(); frame_pre_processor_.Reset();
@ -117,71 +112,71 @@ int32_t VideoProcessingModule::Brighten(VideoFrame* frame, int delta) {
int32_t VideoProcessingModuleImpl::Deflickering(VideoFrame* frame, int32_t VideoProcessingModuleImpl::Deflickering(VideoFrame* frame,
FrameStats* stats) { FrameStats* stats) {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
return deflickering_.ProcessFrame(frame, stats); return deflickering_.ProcessFrame(frame, stats);
} }
int32_t VideoProcessingModuleImpl::BrightnessDetection( int32_t VideoProcessingModuleImpl::BrightnessDetection(
const VideoFrame& frame, const VideoFrame& frame,
const FrameStats& stats) { const FrameStats& stats) {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
return brightness_detection_.ProcessFrame(frame, stats); return brightness_detection_.ProcessFrame(frame, stats);
} }
void VideoProcessingModuleImpl::EnableTemporalDecimation(bool enable) { void VideoProcessingModuleImpl::EnableTemporalDecimation(bool enable) {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
frame_pre_processor_.EnableTemporalDecimation(enable); frame_pre_processor_.EnableTemporalDecimation(enable);
} }
void VideoProcessingModuleImpl::SetInputFrameResampleMode(VideoFrameResampling void VideoProcessingModuleImpl::SetInputFrameResampleMode(VideoFrameResampling
resampling_mode) { resampling_mode) {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
frame_pre_processor_.SetInputFrameResampleMode(resampling_mode); frame_pre_processor_.SetInputFrameResampleMode(resampling_mode);
} }
int32_t VideoProcessingModuleImpl::SetTargetResolution(uint32_t width, int32_t VideoProcessingModuleImpl::SetTargetResolution(uint32_t width,
uint32_t height, uint32_t height,
uint32_t frame_rate) { uint32_t frame_rate) {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
return frame_pre_processor_.SetTargetResolution(width, height, frame_rate); return frame_pre_processor_.SetTargetResolution(width, height, frame_rate);
} }
void VideoProcessingModuleImpl::SetTargetFramerate(int frame_rate) { void VideoProcessingModuleImpl::SetTargetFramerate(int frame_rate) {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
frame_pre_processor_.SetTargetFramerate(frame_rate); frame_pre_processor_.SetTargetFramerate(frame_rate);
} }
uint32_t VideoProcessingModuleImpl::Decimatedframe_rate() { uint32_t VideoProcessingModuleImpl::Decimatedframe_rate() {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
return frame_pre_processor_.Decimatedframe_rate(); return frame_pre_processor_.Decimatedframe_rate();
} }
uint32_t VideoProcessingModuleImpl::DecimatedWidth() const { uint32_t VideoProcessingModuleImpl::DecimatedWidth() const {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
return frame_pre_processor_.DecimatedWidth(); return frame_pre_processor_.DecimatedWidth();
} }
uint32_t VideoProcessingModuleImpl::DecimatedHeight() const { uint32_t VideoProcessingModuleImpl::DecimatedHeight() const {
CriticalSectionScoped cs(&mutex_); rtc::CritScope cs(&mutex_);
return frame_pre_processor_.DecimatedHeight(); return frame_pre_processor_.DecimatedHeight();
} }
int32_t VideoProcessingModuleImpl::PreprocessFrame( int32_t VideoProcessingModuleImpl::PreprocessFrame(
const VideoFrame& frame, const VideoFrame& frame,
VideoFrame** processed_frame) { VideoFrame** processed_frame) {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
return frame_pre_processor_.PreprocessFrame(frame, processed_frame); return frame_pre_processor_.PreprocessFrame(frame, processed_frame);
} }
VideoContentMetrics* VideoProcessingModuleImpl::ContentMetrics() const { VideoContentMetrics* VideoProcessingModuleImpl::ContentMetrics() const {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
return frame_pre_processor_.ContentMetrics(); return frame_pre_processor_.ContentMetrics();
} }
void VideoProcessingModuleImpl::EnableContentAnalysis(bool enable) { void VideoProcessingModuleImpl::EnableContentAnalysis(bool enable) {
CriticalSectionScoped mutex(&mutex_); rtc::CritScope mutex(&mutex_);
frame_pre_processor_.EnableContentAnalysis(enable); frame_pre_processor_.EnableContentAnalysis(enable);
} }

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULE_VIDEO_PROCESSING_IMPL_H #ifndef WEBRTC_MODULE_VIDEO_PROCESSING_IMPL_H
#define WEBRTC_MODULE_VIDEO_PROCESSING_IMPL_H #define WEBRTC_MODULE_VIDEO_PROCESSING_IMPL_H
#include "webrtc/base/criticalsection.h"
#include "webrtc/modules/video_processing/main/interface/video_processing.h" #include "webrtc/modules/video_processing/main/interface/video_processing.h"
#include "webrtc/modules/video_processing/main/source/brighten.h" #include "webrtc/modules/video_processing/main/source/brighten.h"
#include "webrtc/modules/video_processing/main/source/brightness_detection.h" #include "webrtc/modules/video_processing/main/source/brightness_detection.h"
@ -22,9 +23,8 @@ class CriticalSectionWrapper;
class VideoProcessingModuleImpl : public VideoProcessingModule { class VideoProcessingModuleImpl : public VideoProcessingModule {
public: public:
VideoProcessingModuleImpl(int32_t id); VideoProcessingModuleImpl();
~VideoProcessingModuleImpl() override;
virtual ~VideoProcessingModuleImpl();
void Reset() override; void Reset() override;
@ -64,8 +64,8 @@ class VideoProcessingModuleImpl : public VideoProcessingModule {
VideoContentMetrics* ContentMetrics() const override; VideoContentMetrics* ContentMetrics() const override;
private: private:
CriticalSectionWrapper& mutex_; mutable rtc::CriticalSection mutex_;
VPMDeflickering deflickering_; VPMDeflickering deflickering_ GUARDED_BY(mutex_);
VPMBrightnessDetection brightness_detection_; VPMBrightnessDetection brightness_detection_;
VPMFramePreprocessor frame_pre_processor_; VPMFramePreprocessor frame_pre_processor_;
}; };

View File

@ -66,7 +66,7 @@ VideoProcessingModuleTest::VideoProcessingModuleTest()
frame_length_(CalcBufferSize(kI420, width_, height_)) {} frame_length_(CalcBufferSize(kI420, width_, height_)) {}
void VideoProcessingModuleTest::SetUp() { void VideoProcessingModuleTest::SetUp() {
vpm_ = VideoProcessingModule::Create(0); vpm_ = VideoProcessingModule::Create();
ASSERT_TRUE(vpm_ != NULL); ASSERT_TRUE(vpm_ != NULL);
ASSERT_EQ(0, video_frame_.CreateEmptyFrame(width_, height_, width_, ASSERT_EQ(0, video_frame_.CreateEmptyFrame(width_, height_, width_,

View File

@ -109,7 +109,7 @@ ViEEncoder::ViEEncoder(int32_t channel_id,
BitrateAllocator* bitrate_allocator) BitrateAllocator* bitrate_allocator)
: channel_id_(channel_id), : channel_id_(channel_id),
number_of_cores_(number_of_cores), number_of_cores_(number_of_cores),
vpm_(VideoProcessingModule::Create(ViEModuleId(-1, channel_id))), vpm_(VideoProcessingModule::Create()),
qm_callback_(new QMVideoSettingsCallback(vpm_.get())), qm_callback_(new QMVideoSettingsCallback(vpm_.get())),
vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
this, this,