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/base/video_frame.h"
15 #include "media/video/capture/video_capture_types.h"
19 class MEDIA_EXPORT VideoCapture
{
21 // TODO(wjia): consider merging with media::VideoFrame if possible.
22 class VideoFrameBuffer
: public base::RefCountedThreadSafe
<VideoFrameBuffer
> {
29 memory_pointer(NULL
) {}
35 uint8
* memory_pointer
;
39 friend class base::RefCountedThreadSafe
<VideoFrameBuffer
>;
40 ~VideoFrameBuffer() {}
42 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer
);
45 // TODO(wjia): add error codes.
46 // TODO(wjia): support weak ptr.
47 // Callbacks provided by client for notification of events.
48 class MEDIA_EXPORT EventHandler
{
50 // Notify client that video capture has been started.
51 virtual void OnStarted(VideoCapture
* capture
) = 0;
53 // Notify client that video capture has been stopped.
54 virtual void OnStopped(VideoCapture
* capture
) = 0;
56 // Notify client that video capture has been paused.
57 virtual void OnPaused(VideoCapture
* capture
) = 0;
59 // Notify client that video capture has hit some error |error_code|.
60 virtual void OnError(VideoCapture
* capture
, int error_code
) = 0;
62 // Notify client that the client has been removed and no more calls will be
64 virtual void OnRemoved(VideoCapture
* capture
) = 0;
66 // Notify client that a buffer is available.
67 virtual void OnBufferReady(VideoCapture
* capture
,
68 scoped_refptr
<VideoFrameBuffer
> buffer
) = 0;
70 // Notify client about device info.
71 virtual void OnDeviceInfoReceived(
72 VideoCapture
* capture
,
73 const VideoCaptureParams
& device_info
) = 0;
75 // Notify client about the newly changed device info.
76 virtual void OnDeviceInfoChanged(
77 VideoCapture
* capture
,
78 const VideoCaptureParams
& device_info
) {};
81 virtual ~EventHandler() {}
86 // Request video capture to start capturing with |capability|.
87 // Also register |handler| with video capture for event handling.
88 // |handler| must remain valid until it has received |OnRemoved()|.
89 virtual void StartCapture(EventHandler
* handler
,
90 const VideoCaptureCapability
& capability
) = 0;
92 // Request video capture to stop capturing for client |handler|.
93 // |handler| must remain valid until it has received |OnRemoved()|.
94 virtual void StopCapture(EventHandler
* handler
) = 0;
96 // Feed buffer to video capture when done with it.
97 virtual void FeedBuffer(scoped_refptr
<VideoFrameBuffer
> buffer
) = 0;
99 virtual bool CaptureStarted() = 0;
100 virtual int CaptureWidth() = 0;
101 virtual int CaptureHeight() = 0;
102 virtual int CaptureFrameRate() = 0;
105 virtual ~VideoCapture() {}
108 DISALLOW_COPY_AND_ASSIGN(VideoCapture
);
113 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_