OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file contains abstract classes used for media filter to handle video | 5 // This file contains abstract classes used for media filter to handle video |
6 // capture devices. | 6 // capture devices. |
7 | 7 |
8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ | 8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ | 9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 private: | 38 private: |
39 friend class base::RefCountedThreadSafe<VideoFrameBuffer>; | 39 friend class base::RefCountedThreadSafe<VideoFrameBuffer>; |
40 ~VideoFrameBuffer() {} | 40 ~VideoFrameBuffer() {} |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer); | 42 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer); |
43 }; | 43 }; |
44 | 44 |
45 // TODO(wjia): add error codes. | 45 // TODO(wjia): add error codes. |
46 // Callbacks provided by client for notification of events. | 46 // Callbacks provided by client for notification of events. |
47 class EventHandler { | 47 class MEDIA_EXPORT EventHandler { |
48 public: | 48 public: |
49 // Notify client that video capture has been started. | 49 // Notify client that video capture has been started. |
50 virtual void OnStarted(VideoCapture* capture) = 0; | 50 virtual void OnStarted(VideoCapture* capture) = 0; |
51 | 51 |
52 // Notify client that video capture has been stopped. | 52 // Notify client that video capture has been stopped. |
53 virtual void OnStopped(VideoCapture* capture) = 0; | 53 virtual void OnStopped(VideoCapture* capture) = 0; |
54 | 54 |
55 // Notify client that video capture has been paused. | 55 // Notify client that video capture has been paused. |
56 virtual void OnPaused(VideoCapture* capture) = 0; | 56 virtual void OnPaused(VideoCapture* capture) = 0; |
57 | 57 |
58 // Notify client that video capture has hit some error |error_code|. | 58 // Notify client that video capture has hit some error |error_code|. |
59 virtual void OnError(VideoCapture* capture, int error_code) = 0; | 59 virtual void OnError(VideoCapture* capture, int error_code) = 0; |
60 | 60 |
61 // Notify client that the client has been removed and no more calls will be | 61 // Notify client that the client has been removed and no more calls will be |
62 // received. | 62 // received. |
63 virtual void OnRemoved(VideoCapture* capture) = 0; | 63 virtual void OnRemoved(VideoCapture* capture) = 0; |
64 | 64 |
65 // Notify client that a buffer is available. | 65 // Notify client that a buffer is available. |
66 virtual void OnBufferReady(VideoCapture* capture, | 66 virtual void OnBufferReady(VideoCapture* capture, |
67 scoped_refptr<VideoFrameBuffer> buffer) = 0; | 67 scoped_refptr<VideoFrameBuffer> buffer) = 0; |
68 | 68 |
69 // Notify client about device info. | 69 // Notify client about device info. |
70 virtual void OnDeviceInfoReceived( | 70 virtual void OnDeviceInfoReceived( |
71 VideoCapture* capture, | 71 VideoCapture* capture, |
72 const VideoCaptureParams& device_info) = 0; | 72 const VideoCaptureParams& device_info) = 0; |
| 73 |
| 74 protected: |
| 75 virtual ~EventHandler() {} |
73 }; | 76 }; |
74 | 77 |
75 VideoCapture() {} | 78 VideoCapture() {} |
76 virtual ~VideoCapture() {} | |
77 | 79 |
78 // Request video capture to start capturing with |capability|. | 80 // Request video capture to start capturing with |capability|. |
79 // Also register |handler| with video capture for event handling. | 81 // Also register |handler| with video capture for event handling. |
80 // |handler| must remain valid until it has received |OnRemoved()|. | 82 // |handler| must remain valid until it has received |OnRemoved()|. |
81 virtual void StartCapture(EventHandler* handler, | 83 virtual void StartCapture(EventHandler* handler, |
82 const VideoCaptureCapability& capability) = 0; | 84 const VideoCaptureCapability& capability) = 0; |
83 | 85 |
84 // Request video capture to stop capturing for client |handler|. | 86 // Request video capture to stop capturing for client |handler|. |
85 // |handler| must remain valid until it has received |OnRemoved()|. | 87 // |handler| must remain valid until it has received |OnRemoved()|. |
86 virtual void StopCapture(EventHandler* handler) = 0; | 88 virtual void StopCapture(EventHandler* handler) = 0; |
87 | 89 |
88 // Feed buffer to video capture when done with it. | 90 // Feed buffer to video capture when done with it. |
89 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) = 0; | 91 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) = 0; |
90 | 92 |
91 virtual bool CaptureStarted() = 0; | 93 virtual bool CaptureStarted() = 0; |
92 virtual int CaptureWidth() = 0; | 94 virtual int CaptureWidth() = 0; |
93 virtual int CaptureHeight() = 0; | 95 virtual int CaptureHeight() = 0; |
94 virtual int CaptureFrameRate() = 0; | 96 virtual int CaptureFrameRate() = 0; |
95 | 97 |
| 98 protected: |
| 99 virtual ~VideoCapture() {} |
| 100 |
96 private: | 101 private: |
97 DISALLOW_COPY_AND_ASSIGN(VideoCapture); | 102 DISALLOW_COPY_AND_ASSIGN(VideoCapture); |
98 }; | 103 }; |
99 | 104 |
100 } // namespace media | 105 } // namespace media |
101 | 106 |
102 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ | 107 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
OLD | NEW |