Chromium Code Reviews| Index: webrtc/modules/video_capture/video_capture_impl.cc |
| diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc |
| index 90ac26713a2cd9ccd8ec1911bb5bce0c17fe2e23..4c6b5b88564fff8ff80c692ad21c13206ffaf0a7 100644 |
| --- a/webrtc/modules/video_capture/video_capture_impl.cc |
| +++ b/webrtc/modules/video_capture/video_capture_impl.cc |
| @@ -25,10 +25,9 @@ |
| namespace webrtc { |
| namespace videocapturemodule { |
| rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( |
| - const int32_t id, |
| VideoCaptureExternal*& externalCapture) { |
| rtc::scoped_refptr<VideoCaptureImpl> implementation( |
| - new rtc::RefCountedObject<VideoCaptureImpl>(id)); |
| + new rtc::RefCountedObject<VideoCaptureImpl>()); |
| externalCapture = implementation.get(); |
| return implementation; |
| } |
| @@ -94,64 +93,20 @@ void VideoCaptureImpl::Process() |
| { |
| CriticalSectionScoped cs(&_callBackCs); |
|
nisse-webrtc
2016/11/29 13:58:17
And it seems _callBackCs can also be deleted? In a
perkj_webrtc
2016/11/30 06:28:48
You can use GUARDED_BY().. But yes, there is no re
|
| - const int64_t now_ns = rtc::TimeNanos(); |
| _lastProcessTimeNanos = rtc::TimeNanos(); |
| - // Handle No picture alarm |
| - |
| - if (_lastProcessFrameTimeNanos == _incomingFrameTimesNanos[0] && |
| - _captureAlarm != Raised) |
| - { |
| - if (_noPictureAlarmCallBack && _captureCallBack) |
| - { |
| - _captureAlarm = Raised; |
| - _captureCallBack->OnNoPictureAlarm(_id, _captureAlarm); |
| - } |
| - } |
| - else if (_lastProcessFrameTimeNanos != _incomingFrameTimesNanos[0] && |
| - _captureAlarm != Cleared) |
| - { |
| - if (_noPictureAlarmCallBack && _captureCallBack) |
| - { |
| - _captureAlarm = Cleared; |
| - _captureCallBack->OnNoPictureAlarm(_id, _captureAlarm); |
| - |
| - } |
| - } |
| - |
| - // Handle frame rate callback |
| - if ((now_ns - _lastFrameRateCallbackTimeNanos) / |
| - rtc::kNumNanosecsPerMillisec |
| - > kFrameRateCallbackInterval) |
| - { |
| - if (_frameRateCallBack && _captureCallBack) |
| - { |
| - const uint32_t frameRate = CalculateFrameRate(now_ns); |
| - _captureCallBack->OnCaptureFrameRate(_id, frameRate); |
| - } |
| - // Can be set by EnableFrameRateCallback |
| - _lastFrameRateCallbackTimeNanos = now_ns; |
| - |
| - } |
| - |
| _lastProcessFrameTimeNanos = _incomingFrameTimesNanos[0]; |
| } |
| -VideoCaptureImpl::VideoCaptureImpl(const int32_t id) |
| - : _id(id), |
| - _deviceUniqueId(NULL), |
| +VideoCaptureImpl::VideoCaptureImpl() |
| + : _deviceUniqueId(NULL), |
| _apiCs(*CriticalSectionWrapper::CreateCriticalSection()), |
| _captureDelay(0), |
| _requestedCapability(), |
| _callBackCs(*CriticalSectionWrapper::CreateCriticalSection()), |
| _lastProcessTimeNanos(rtc::TimeNanos()), |
| _lastFrameRateCallbackTimeNanos(rtc::TimeNanos()), |
| - _frameRateCallBack(false), |
| - _noPictureAlarmCallBack(false), |
| - _captureAlarm(Cleared), |
| - _setCaptureDelay(0), |
| _dataCallBack(NULL), |
| - _captureCallBack(NULL), |
| _lastProcessFrameTimeNanos(rtc::TimeNanos()), |
| _rotateFrame(kVideoRotation_0), |
| apply_rotation_(false) { |
| @@ -166,7 +121,6 @@ VideoCaptureImpl::VideoCaptureImpl(const int32_t id) |
| VideoCaptureImpl::~VideoCaptureImpl() |
| { |
| DeRegisterCaptureDataCallback(); |
| - DeRegisterCaptureCallback(); |
| delete &_callBackCs; |
| delete &_apiCs; |
| @@ -175,10 +129,10 @@ VideoCaptureImpl::~VideoCaptureImpl() |
| } |
| void VideoCaptureImpl::RegisterCaptureDataCallback( |
| - VideoCaptureDataCallback& dataCallBack) { |
| + rtc::VideoSinkInterface<VideoFrame>* dataCallBack) { |
| CriticalSectionScoped cs(&_apiCs); |
| CriticalSectionScoped cs2(&_callBackCs); |
| - _dataCallBack = &dataCallBack; |
| + _dataCallBack = dataCallBack; |
| } |
| void VideoCaptureImpl::DeRegisterCaptureDataCallback() { |
| @@ -186,42 +140,11 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback() { |
| CriticalSectionScoped cs2(&_callBackCs); |
| _dataCallBack = NULL; |
| } |
| -void VideoCaptureImpl::RegisterCaptureCallback(VideoCaptureFeedBack& callBack) { |
| - |
| - CriticalSectionScoped cs(&_apiCs); |
| - CriticalSectionScoped cs2(&_callBackCs); |
| - _captureCallBack = &callBack; |
| -} |
| -void VideoCaptureImpl::DeRegisterCaptureCallback() { |
| - |
| - CriticalSectionScoped cs(&_apiCs); |
| - CriticalSectionScoped cs2(&_callBackCs); |
| - _captureCallBack = NULL; |
| -} |
| -void VideoCaptureImpl::SetCaptureDelay(int32_t delayMS) { |
| - CriticalSectionScoped cs(&_apiCs); |
| - _captureDelay = delayMS; |
| -} |
| -int32_t VideoCaptureImpl::CaptureDelay() |
| -{ |
| - CriticalSectionScoped cs(&_apiCs); |
| - return _setCaptureDelay; |
| -} |
| - |
| int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { |
| UpdateFrameCount(); // frame count used for local frame rate callback. |
| - const bool callOnCaptureDelayChanged = _setCaptureDelay != _captureDelay; |
| - // Capture delay changed |
| - if (_setCaptureDelay != _captureDelay) { |
| - _setCaptureDelay = _captureDelay; |
| - } |
| - |
| if (_dataCallBack) { |
| - if (callOnCaptureDelayChanged) { |
| - _dataCallBack->OnCaptureDelayChanged(_id, _captureDelay); |
| - } |
| - _dataCallBack->OnIncomingCapturedFrame(_id, captureFrame); |
| + _dataCallBack->OnFrame(captureFrame); |
| } |
| return 0; |
| @@ -313,16 +236,6 @@ int32_t VideoCaptureImpl::SetCaptureRotation(VideoRotation rotation) { |
| return 0; |
| } |
| -void VideoCaptureImpl::EnableFrameRateCallback(const bool enable) { |
| - CriticalSectionScoped cs(&_apiCs); |
| - CriticalSectionScoped cs2(&_callBackCs); |
| - _frameRateCallBack = enable; |
| - if (enable) |
| - { |
| - _lastFrameRateCallbackTimeNanos = rtc::TimeNanos(); |
| - } |
| -} |
| - |
| bool VideoCaptureImpl::SetApplyRotation(bool enable) { |
| // We can't take any lock here as it'll cause deadlock with IncomingFrame. |
| @@ -331,12 +244,6 @@ bool VideoCaptureImpl::SetApplyRotation(bool enable) { |
| return true; |
| } |
| -void VideoCaptureImpl::EnableNoPictureAlarm(const bool enable) { |
| - CriticalSectionScoped cs(&_apiCs); |
| - CriticalSectionScoped cs2(&_callBackCs); |
| - _noPictureAlarmCallBack = enable; |
| -} |
| - |
| void VideoCaptureImpl::UpdateFrameCount() |
| { |
| if (_incomingFrameTimesNanos[0] / rtc::kNumNanosecsPerMicrosec == 0) |