| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ | 5 #ifndef MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ |
| 6 #define MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ | 6 #define MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // Stops capturing. | 40 // Stops capturing. |
| 41 // |callback| is invoked after the capturing has stopped. | 41 // |callback| is invoked after the capturing has stopped. |
| 42 virtual void Stop(const base::Closure& callback) = 0; | 42 virtual void Stop(const base::Closure& callback) = 0; |
| 43 | 43 |
| 44 // Returns true if the video capture is configured to monitor end-to-end | 44 // Returns true if the video capture is configured to monitor end-to-end |
| 45 // system utilization, and alter frame sizes and/or frame rates to mitigate | 45 // system utilization, and alter frame sizes and/or frame rates to mitigate |
| 46 // overloading or under-utilization. | 46 // overloading or under-utilization. |
| 47 virtual bool IsAutoThrottlingEnabled() const; | 47 virtual bool IsAutoThrottlingEnabled() const; |
| 48 | 48 |
| 49 // Called by ScreenCaptureDeviceCore when it failed to satisfy a "refresh | |
| 50 // frame" request by attempting to resurrect the last video frame from the | |
| 51 // buffer pool (this is referred to as the "passive" refresh approach). The | |
| 52 // failure can happen for a number of reasons (e.g., the oracle decided to | |
| 53 // change resolution, or consumers of the last video frame are not yet | |
| 54 // finished with it). | |
| 55 // | |
| 56 // The implementation of this method should consult the oracle, using the | |
| 57 // kActiveRefreshRequest event type, to decide whether to initiate a new frame | |
| 58 // capture, and then do so if the oracle agrees. | |
| 59 virtual void MaybeCaptureForRefresh() = 0; | |
| 60 | |
| 61 private: | 49 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine); | 50 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine); |
| 63 }; | 51 }; |
| 64 | 52 |
| 65 // The "meat" of a content video capturer. | 53 // The "meat" of a content video capturer. |
| 66 // | 54 // |
| 67 // Separating this from the "shell classes" WebContentsVideoCaptureDevice and | 55 // Separating this from the "shell classes" WebContentsVideoCaptureDevice and |
| 68 // DesktopCaptureDeviceAura allows safe destruction without needing to block any | 56 // DesktopCaptureDeviceAura allows safe destruction without needing to block any |
| 69 // threads, as well as code sharing. | 57 // threads, as well as code sharing. |
| 70 // | 58 // |
| 71 // ScreenCaptureDeviceCore manages a simple state machine and the pipeline | 59 // ScreenCaptureDeviceCore manages a simple state machine and the pipeline |
| 72 // (see notes at top of this file). It times the start of successive captures | 60 // (see notes at top of this file). It times the start of successive captures |
| 73 // and facilitates the processing of each through the stages of the | 61 // and facilitates the processing of each through the stages of the |
| 74 // pipeline. | 62 // pipeline. |
| 75 class MEDIA_EXPORT ScreenCaptureDeviceCore | 63 class MEDIA_EXPORT ScreenCaptureDeviceCore |
| 76 : public base::SupportsWeakPtr<ScreenCaptureDeviceCore> { | 64 : public base::SupportsWeakPtr<ScreenCaptureDeviceCore> { |
| 77 public: | 65 public: |
| 78 ScreenCaptureDeviceCore(scoped_ptr<VideoCaptureMachine> capture_machine); | 66 ScreenCaptureDeviceCore(scoped_ptr<VideoCaptureMachine> capture_machine); |
| 79 virtual ~ScreenCaptureDeviceCore(); | 67 virtual ~ScreenCaptureDeviceCore(); |
| 80 | 68 |
| 81 // Asynchronous requests to change ScreenCaptureDeviceCore state. | 69 // Asynchronous requests to change ScreenCaptureDeviceCore state. |
| 82 void AllocateAndStart(const VideoCaptureParams& params, | 70 void AllocateAndStart(const VideoCaptureParams& params, |
| 83 scoped_ptr<VideoCaptureDevice::Client> client); | 71 scoped_ptr<VideoCaptureDevice::Client> client); |
| 84 void RequestRefreshFrame(); | |
| 85 void StopAndDeAllocate(); | 72 void StopAndDeAllocate(); |
| 86 | 73 |
| 87 private: | 74 private: |
| 88 // Flag indicating current state. | 75 // Flag indicating current state. |
| 89 enum State { kIdle, kCapturing, kError, kLastCaptureState }; | 76 enum State { kIdle, kCapturing, kError, kLastCaptureState }; |
| 90 | 77 |
| 91 void TransitionStateTo(State next_state); | 78 void TransitionStateTo(State next_state); |
| 92 | 79 |
| 93 // Called back in response to StartCaptureMachine(). |success| is true if | 80 // Called back in response to StartCaptureMachine(). |success| is true if |
| 94 // capture machine succeeded to start. | 81 // capture machine succeeded to start. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only | 100 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only |
| 114 // component of the system with direct access to |client_|. | 101 // component of the system with direct access to |client_|. |
| 115 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 102 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
| 116 | 103 |
| 117 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore); | 104 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore); |
| 118 }; | 105 }; |
| 119 | 106 |
| 120 } // namespace media | 107 } // namespace media |
| 121 | 108 |
| 122 #endif // MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ | 109 #endif // MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ |
| OLD | NEW |