Add OnRemoved() in VideoCapture::EventHandler API
This is to allow client to know when the event handler can be deleted. BUG=none TEST=trybots Review URL: http://codereview.chromium.org/8037055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103016 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
content/renderer/media
capture_video_decoder.cccapture_video_decoder.hvideo_capture_impl.ccvideo_capture_impl_unittest.ccvideo_capture_module_impl.ccvideo_capture_module_impl.h
media/video/capture
webkit/plugins/ppapi
@ -109,6 +109,10 @@ void CaptureVideoDecoder::OnError(media::VideoCapture* capture,
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CaptureVideoDecoder::OnRemoved(media::VideoCapture* capture) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void CaptureVideoDecoder::OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
|
||||
|
@ -51,6 +51,7 @@ class CaptureVideoDecoder
|
||||
virtual void OnStopped(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnPaused(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE;
|
||||
virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) OVERRIDE;
|
||||
|
@ -144,6 +144,7 @@ void VideoCaptureImpl::DoStartCapture(
|
||||
|
||||
if (it != pending_clients_.end()) {
|
||||
handler->OnError(this, 1);
|
||||
handler->OnRemoved(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,6 +158,7 @@ void VideoCaptureImpl::DoStartCapture(
|
||||
capability.height != current_params_.height)) {
|
||||
// Can't have 2 master clients with different resolutions.
|
||||
handler->OnError(this, 1);
|
||||
handler->OnRemoved(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -219,6 +221,7 @@ void VideoCaptureImpl::DoStopCapture(
|
||||
ClientInfo::iterator it = pending_clients_.find(handler);
|
||||
if (it != pending_clients_.end()) {
|
||||
handler->OnStopped(this);
|
||||
handler->OnRemoved(this);
|
||||
pending_clients_.erase(it);
|
||||
return;
|
||||
}
|
||||
@ -227,6 +230,7 @@ void VideoCaptureImpl::DoStopCapture(
|
||||
return;
|
||||
|
||||
handler->OnStopped(this);
|
||||
handler->OnRemoved(this);
|
||||
clients_.erase(handler);
|
||||
master_clients_.remove(handler);
|
||||
|
||||
@ -368,7 +372,12 @@ void VideoCaptureImpl::DoStateChanged(const media::VideoCapture::State& state) {
|
||||
it != clients_.end(); it++) {
|
||||
// TODO(wjia): browser process would send error code.
|
||||
it->first->OnError(this, 1);
|
||||
it->first->OnRemoved(this);
|
||||
}
|
||||
clients_.clear();
|
||||
master_clients_.clear();
|
||||
state_ = kStopped;
|
||||
current_params_.width = current_params_.height = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -34,11 +34,12 @@ class MockVideoCaptureClient : public media::VideoCapture::EventHandler {
|
||||
MockVideoCaptureClient() {}
|
||||
virtual ~MockVideoCaptureClient() {}
|
||||
|
||||
// Filter implementation.
|
||||
// EventHandler implementation.
|
||||
MOCK_METHOD1(OnStarted, void(media::VideoCapture* capture));
|
||||
MOCK_METHOD1(OnStopped, void(media::VideoCapture* capture));
|
||||
MOCK_METHOD1(OnPaused, void(media::VideoCapture* capture));
|
||||
MOCK_METHOD2(OnError, void(media::VideoCapture* capture, int error_code));
|
||||
MOCK_METHOD1(OnRemoved, void(media::VideoCapture* capture));
|
||||
MOCK_METHOD2(OnBufferReady,
|
||||
void(media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf));
|
||||
|
@ -105,6 +105,10 @@ void VideoCaptureModuleImpl::OnError(media::VideoCapture* capture,
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void VideoCaptureModuleImpl::OnRemoved(media::VideoCapture* capture) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void VideoCaptureModuleImpl::OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
|
||||
|
@ -40,6 +40,7 @@ class VideoCaptureModuleImpl
|
||||
virtual void OnStopped(media::VideoCapture* capture);
|
||||
virtual void OnPaused(media::VideoCapture* capture);
|
||||
virtual void OnError(media::VideoCapture* capture, int error_code);
|
||||
virtual void OnRemoved(media::VideoCapture* capture);
|
||||
virtual void OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf);
|
||||
|
@ -66,6 +66,10 @@ class VideoCapture {
|
||||
// Notify client that video capture has hit some error |error_code|.
|
||||
virtual void OnError(VideoCapture* capture, int error_code) = 0;
|
||||
|
||||
// Notify client that the client has been removed and no more calls will be
|
||||
// received.
|
||||
virtual void OnRemoved(VideoCapture* capture) = 0;
|
||||
|
||||
// Notify client that a buffer is available.
|
||||
virtual void OnBufferReady(VideoCapture* capture,
|
||||
scoped_refptr<VideoFrameBuffer> buffer) = 0;
|
||||
@ -93,10 +97,12 @@ class VideoCapture {
|
||||
|
||||
// Request video capture to start capturing with |capability|.
|
||||
// Also register |handler| with video capture for event handling.
|
||||
// |handler| must remain valid until it has received |OnRemoved()|.
|
||||
virtual void StartCapture(EventHandler* handler,
|
||||
const VideoCaptureCapability& capability) = 0;
|
||||
|
||||
// Request video capture to stop capturing for client |handler|.
|
||||
// |handler| must remain valid until it has received |OnRemoved()|.
|
||||
virtual void StopCapture(EventHandler* handler) = 0;
|
||||
|
||||
// Feed buffer to video capture when done with it.
|
||||
|
@ -68,6 +68,10 @@ void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
|
||||
error_code));
|
||||
}
|
||||
|
||||
void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
|
||||
// TODO(vtl): add logic when this event handler is removed.
|
||||
}
|
||||
|
||||
void VideoCaptureHandlerProxy::OnBufferReady(
|
||||
VideoCapture* capture,
|
||||
scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) {
|
||||
|
@ -51,6 +51,7 @@ class MEDIA_EXPORT VideoCaptureHandlerProxy
|
||||
virtual void OnStopped(VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnPaused(VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE;
|
||||
virtual void OnRemoved(VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnBufferReady(
|
||||
VideoCapture* capture,
|
||||
scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) OVERRIDE;
|
||||
|
@ -167,6 +167,10 @@ void PPB_VideoCapture_Impl::OnError(media::VideoCapture* capture,
|
||||
ppp_videocapture_->OnError(pp_instance(), pp_resource(), PP_ERROR_FAILED);
|
||||
}
|
||||
|
||||
void PPB_VideoCapture_Impl::OnRemoved(media::VideoCapture* capture) {
|
||||
// TODO(vtl): add logic when this event handler is removed.
|
||||
}
|
||||
|
||||
void PPB_VideoCapture_Impl::OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) {
|
||||
|
@ -48,6 +48,7 @@ class PPB_VideoCapture_Impl : public ::ppapi::Resource,
|
||||
virtual void OnStopped(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnPaused(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE;
|
||||
virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE;
|
||||
virtual void OnBufferReady(
|
||||
media::VideoCapture* capture,
|
||||
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE;
|
||||
|
Reference in New Issue
Block a user