| 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_THREAD_SAFE_CAPTURE_ORACLE_H_ | 5 #ifndef MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_ |
| 6 #define MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_ | 6 #define MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "media/capture/capture_resolution_chooser.h" | |
| 15 #include "media/capture/video_capture_oracle.h" | 14 #include "media/capture/video_capture_oracle.h" |
| 16 #include "media/video/capture/video_capture_device.h" | 15 #include "media/video/capture/video_capture_device.h" |
| 17 | 16 |
| 18 namespace media { | 17 namespace media { |
| 19 | 18 |
| 20 struct VideoCaptureParams; | 19 struct VideoCaptureParams; |
| 21 class VideoFrame; | 20 class VideoFrame; |
| 22 | 21 |
| 23 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps | 22 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps |
| 24 // the VideoCaptureOracle, which decides which frames to capture, and a | 23 // the VideoCaptureOracle, which decides which frames to capture, and a |
| 25 // VideoCaptureDevice::Client, which allocates and receives the captured | 24 // VideoCaptureDevice::Client, which allocates and receives the captured |
| 26 // frames, in a lock to synchronize state between the two. | 25 // frames, in a lock to synchronize state between the two. |
| 27 class MEDIA_EXPORT ThreadSafeCaptureOracle | 26 class MEDIA_EXPORT ThreadSafeCaptureOracle |
| 28 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> { | 27 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> { |
| 29 public: | 28 public: |
| 30 ThreadSafeCaptureOracle(scoped_ptr<VideoCaptureDevice::Client> client, | 29 ThreadSafeCaptureOracle(scoped_ptr<VideoCaptureDevice::Client> client, |
| 31 const VideoCaptureParams& params); | 30 const VideoCaptureParams& params, |
| 31 bool enable_auto_throttling); |
| 32 | 32 |
| 33 // Called when a captured frame is available or an error has occurred. | 33 // Called when a captured frame is available or an error has occurred. |
| 34 // If |success| is true then |frame| is valid and |timestamp| indicates when | 34 // If |success| is true then |frame| is valid and |timestamp| indicates when |
| 35 // the frame was painted. | 35 // the frame was painted. |
| 36 // If |success| is false, all other parameters are invalid. | 36 // If |success| is false, all other parameters are invalid. |
| 37 typedef base::Callback<void(const scoped_refptr<VideoFrame>& frame, | 37 typedef base::Callback<void(const scoped_refptr<VideoFrame>& frame, |
| 38 base::TimeTicks timestamp, | 38 base::TimeTicks timestamp, |
| 39 bool success)> CaptureFrameCallback; | 39 bool success)> CaptureFrameCallback; |
| 40 | 40 |
| 41 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, | 41 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 mutable base::Lock lock_; | 88 mutable base::Lock lock_; |
| 89 | 89 |
| 90 // Recipient of our capture activity. | 90 // Recipient of our capture activity. |
| 91 scoped_ptr<VideoCaptureDevice::Client> client_; | 91 scoped_ptr<VideoCaptureDevice::Client> client_; |
| 92 | 92 |
| 93 // Makes the decision to capture a frame. | 93 // Makes the decision to capture a frame. |
| 94 VideoCaptureOracle oracle_; | 94 VideoCaptureOracle oracle_; |
| 95 | 95 |
| 96 // The video capture parameters used to construct the oracle proxy. | 96 // The video capture parameters used to construct the oracle proxy. |
| 97 const VideoCaptureParams params_; | 97 const VideoCaptureParams params_; |
| 98 | |
| 99 // Determines video capture frame sizes. | |
| 100 CaptureResolutionChooser resolution_chooser_; | |
| 101 }; | 98 }; |
| 102 | 99 |
| 103 } // namespace media | 100 } // namespace media |
| 104 | 101 |
| 105 #endif // MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_ | 102 #endif // MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_ |
| OLD | NEW |