cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / video / capture / video_capture.h
blob47c779064f817a67ef3f266a689b7d2ffd30bb1c
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.
4 //
5 // This file contains abstract classes used for media filter to handle video
6 // capture devices.
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"
17 namespace media {
19 class MEDIA_EXPORT VideoCapture {
20 public:
21 // TODO(wjia): consider merging with media::VideoFrame if possible.
22 class VideoFrameBuffer : public base::RefCountedThreadSafe<VideoFrameBuffer> {
23 public:
24 VideoFrameBuffer()
25 : width(0),
26 height(0),
27 stride(0),
28 buffer_size(0),
29 memory_pointer(NULL) {}
31 int width;
32 int height;
33 int stride;
34 size_t buffer_size;
35 uint8* memory_pointer;
36 base::Time timestamp;
38 private:
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 {
49 public:
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
63 // received.
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) {};
80 protected:
81 virtual ~EventHandler() {}
84 VideoCapture() {}
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;
104 protected:
105 virtual ~VideoCapture() {}
107 private:
108 DISALLOW_COPY_AND_ASSIGN(VideoCapture);
111 } // namespace media
113 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_