OLD | NEW |
(Empty) | |
| 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. |
| 7 |
| 8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
| 9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/time/time.h" |
| 14 #include "media/base/media_export.h" |
| 15 #include "media/video/capture/video_capture_types.h" |
| 16 |
| 17 namespace media { |
| 18 |
| 19 class VideoFrame; |
| 20 |
| 21 class MEDIA_EXPORT VideoCapture { |
| 22 public: |
| 23 // TODO(wjia): add error codes. |
| 24 // TODO(wjia): support weak ptr. |
| 25 // Callbacks provided by client for notification of events. |
| 26 class MEDIA_EXPORT EventHandler { |
| 27 public: |
| 28 // Notify client that video capture has been started. |
| 29 virtual void OnStarted(VideoCapture* capture) = 0; |
| 30 |
| 31 // Notify client that video capture has been stopped. |
| 32 virtual void OnStopped(VideoCapture* capture) = 0; |
| 33 |
| 34 // Notify client that video capture has been paused. |
| 35 virtual void OnPaused(VideoCapture* capture) = 0; |
| 36 |
| 37 // Notify client that video capture has hit some error |error_code|. |
| 38 virtual void OnError(VideoCapture* capture, int error_code) = 0; |
| 39 |
| 40 // Notify client that the client has been removed and no more calls will be |
| 41 // received. |
| 42 virtual void OnRemoved(VideoCapture* capture) = 0; |
| 43 |
| 44 // Notify client that a buffer is available. |
| 45 virtual void OnFrameReady( |
| 46 VideoCapture* capture, |
| 47 const scoped_refptr<media::VideoFrame>& frame) = 0; |
| 48 |
| 49 protected: |
| 50 virtual ~EventHandler() {} |
| 51 }; |
| 52 |
| 53 typedef base::Callback<void(const media::VideoCaptureFormats&)> |
| 54 DeviceFormatsCallback; |
| 55 |
| 56 typedef base::Callback<void(const media::VideoCaptureFormats&)> |
| 57 DeviceFormatsInUseCallback; |
| 58 |
| 59 VideoCapture() {} |
| 60 |
| 61 // Request video capture to start capturing with |params|. |
| 62 // Also register |handler| with video capture for event handling. |
| 63 // |handler| must remain valid until it has received |OnRemoved()|. |
| 64 virtual void StartCapture(EventHandler* handler, |
| 65 const VideoCaptureParams& params) = 0; |
| 66 |
| 67 // Request video capture to stop capturing for client |handler|. |
| 68 // |handler| must remain valid until it has received |OnRemoved()|. |
| 69 virtual void StopCapture(EventHandler* handler) = 0; |
| 70 |
| 71 virtual bool CaptureStarted() = 0; |
| 72 virtual int CaptureFrameRate() = 0; |
| 73 |
| 74 // Request the device capture supported formats. This method can be called |
| 75 // before startCapture() and/or after stopCapture() so a |callback| is used |
| 76 // instead of replying via EventHandler. |
| 77 virtual void GetDeviceSupportedFormats( |
| 78 const DeviceFormatsCallback& callback) = 0; |
| 79 |
| 80 // Request the device capture in-use format(s), possibly by other user(s) in |
| 81 // other renderer(s). If there is no format in use, the vector returned in |
| 82 // the callback will be empty. |
| 83 virtual void GetDeviceFormatsInUse( |
| 84 const DeviceFormatsInUseCallback& callback) = 0; |
| 85 |
| 86 protected: |
| 87 virtual ~VideoCapture() {} |
| 88 |
| 89 private: |
| 90 DISALLOW_COPY_AND_ASSIGN(VideoCapture); |
| 91 }; |
| 92 |
| 93 } // namespace media |
| 94 |
| 95 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |
OLD | NEW |