1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file contains abstract classes used for media filter to handle video
8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "media/base/media_export.h"
14 #include "media/video/capture/video_capture_types.h"
20 class MEDIA_EXPORT VideoCapture
{
22 // TODO(wjia): add error codes.
23 // TODO(wjia): support weak ptr.
24 // Callbacks provided by client for notification of events.
25 class MEDIA_EXPORT EventHandler
{
27 // Notify client that video capture has been started.
28 virtual void OnStarted(VideoCapture
* capture
) = 0;
30 // Notify client that video capture has been stopped.
31 virtual void OnStopped(VideoCapture
* capture
) = 0;
33 // Notify client that video capture has been paused.
34 virtual void OnPaused(VideoCapture
* capture
) = 0;
36 // Notify client that video capture has hit some error |error_code|.
37 virtual void OnError(VideoCapture
* capture
, int error_code
) = 0;
39 // Notify client that the client has been removed and no more calls will be
41 virtual void OnRemoved(VideoCapture
* capture
) = 0;
43 // Notify client that a buffer is available.
44 virtual void OnFrameReady(
45 VideoCapture
* capture
,
46 const scoped_refptr
<media::VideoFrame
>& frame
) = 0;
49 virtual ~EventHandler() {}
54 // Request video capture to start capturing with |params|.
55 // Also register |handler| with video capture for event handling.
56 // |handler| must remain valid until it has received |OnRemoved()|.
57 virtual void StartCapture(EventHandler
* handler
,
58 const VideoCaptureParams
& params
) = 0;
60 // Request video capture to stop capturing for client |handler|.
61 // |handler| must remain valid until it has received |OnRemoved()|.
62 virtual void StopCapture(EventHandler
* handler
) = 0;
64 virtual bool CaptureStarted() = 0;
65 virtual int CaptureFrameRate() = 0;
68 virtual ~VideoCapture() {}
71 DISALLOW_COPY_AND_ASSIGN(VideoCapture
);
76 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_