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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 #include "media/capture/content/thread_safe_capture_oracle.h" | 14 #include "media/capture/content/thread_safe_capture_oracle.h" |
15 #include "media/capture/video/video_capture_device.h" | 15 #include "media/capture/video/video_capture_device.h" |
16 | 16 |
| 17 namespace tracked_objects { |
| 18 class Location; |
| 19 } // namespace tracked_objects |
| 20 |
17 namespace media { | 21 namespace media { |
18 | 22 |
19 struct VideoCaptureParams; | 23 struct VideoCaptureParams; |
20 | 24 |
21 class ThreadSafeCaptureOracle; | 25 class ThreadSafeCaptureOracle; |
22 | 26 |
23 // Keeps track of the video capture source frames and executes copying. | 27 // Keeps track of the video capture source frames and executes copying. |
24 class MEDIA_EXPORT VideoCaptureMachine { | 28 class MEDIA_EXPORT VideoCaptureMachine { |
25 public: | 29 public: |
26 VideoCaptureMachine(); | 30 VideoCaptureMachine(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ScreenCaptureDeviceCore(scoped_ptr<VideoCaptureMachine> capture_machine); | 65 ScreenCaptureDeviceCore(scoped_ptr<VideoCaptureMachine> capture_machine); |
62 virtual ~ScreenCaptureDeviceCore(); | 66 virtual ~ScreenCaptureDeviceCore(); |
63 | 67 |
64 // Asynchronous requests to change ScreenCaptureDeviceCore state. | 68 // Asynchronous requests to change ScreenCaptureDeviceCore state. |
65 void AllocateAndStart(const VideoCaptureParams& params, | 69 void AllocateAndStart(const VideoCaptureParams& params, |
66 scoped_ptr<VideoCaptureDevice::Client> client); | 70 scoped_ptr<VideoCaptureDevice::Client> client); |
67 void StopAndDeAllocate(); | 71 void StopAndDeAllocate(); |
68 | 72 |
69 private: | 73 private: |
70 // Flag indicating current state. | 74 // Flag indicating current state. |
71 enum State { kIdle, kCapturing, kError }; | 75 enum State { kIdle, kCapturing, kError, kLastCaptureState }; |
72 | 76 |
73 void TransitionStateTo(State next_state); | 77 void TransitionStateTo(State next_state); |
74 | 78 |
75 // Called back in response to StartCaptureMachine(). |success| is true if | 79 // Called back in response to StartCaptureMachine(). |success| is true if |
76 // capture machine succeeded to start. | 80 // capture machine succeeded to start. |
77 void CaptureStarted(bool success); | 81 void CaptureStarted(bool success); |
78 | 82 |
79 // Stops capturing and notifies client_ of an error state. | 83 // Stops capturing and notifies client_ of an error state. |
80 void Error(const std::string& reason); | 84 void Error(const tracked_objects::Location& from_here, |
| 85 const std::string& reason); |
81 | 86 |
82 // Tracks that all activity occurs on the media stream manager's thread. | 87 // Tracks that all activity occurs on the media stream manager's thread. |
83 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
84 | 89 |
85 // Current lifecycle state. | 90 // Current lifecycle state. |
86 State state_; | 91 State state_; |
87 | 92 |
88 // Tracks the CaptureMachine that's doing work on our behalf | 93 // Tracks the CaptureMachine that's doing work on our behalf |
89 // on the device thread or UI thread. | 94 // on the device thread or UI thread. |
90 // This value should never be dereferenced by this class. | 95 // This value should never be dereferenced by this class. |
91 scoped_ptr<VideoCaptureMachine> capture_machine_; | 96 scoped_ptr<VideoCaptureMachine> capture_machine_; |
92 | 97 |
93 // Our thread-safe capture oracle which serves as the gateway to the video | 98 // Our thread-safe capture oracle which serves as the gateway to the video |
94 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only | 99 // capture pipeline. Besides the VideoCaptureDevice itself, it is the only |
95 // component of the system with direct access to |client_|. | 100 // component of the system with direct access to |client_|. |
96 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 101 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
97 | 102 |
98 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore); | 103 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore); |
99 }; | 104 }; |
100 | 105 |
101 } // namespace media | 106 } // namespace media |
102 | 107 |
103 #endif // MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ | 108 #endif // MEDIA_CAPTURE_SCREEN_CAPTURE_DEVICE_CORE_H_ |
OLD | NEW |