Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: media/capture/video/chromeos/camera_device_context.h

Issue 2936373002: Revert of media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_DEVICE_CONTEXT_H_
6 #define MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_DEVICE_CONTEXT_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/sequence_checker.h"
12 #include "media/capture/video/video_capture_device.h"
13
14 namespace media {
15
16 // A class storing the context of a running CameraDeviceDelegate.
17 class CAPTURE_EXPORT CameraDeviceContext {
18 public:
19 // The internal state of the running CameraDeviceDelegate. The state
20 // transition happens when the corresponding methods are called inside
21 // CameraDeviceDelegate.
22 enum class State {
23 // The camera device is completely stopped. This is the initial state, and
24 // is also set in OnClosed().
25 kStopped,
26
27 // The camera device is starting and waiting to be initialized.
28 //
29 // The kStarting state is set in AllocateAndStart().
30 kStarting,
31
32 // The camera device is initialized and can accept stream configuration
33 // requests.
34 //
35 // The state is transitioned to kInitialized through:
36 //
37 // |hal_delegate_|->GetCameraInfo() -> OnGotCameraInfo() ->
38 // |hal_delegate_|->OpenDevice() -> OnOpenedDevice() ->
39 // Initialize() -> OnInitialized()
40 kInitialized,
41
42 // The various capture streams are configured and the camera device is ready
43 // to process capture requests.
44 //
45 // The state is transitioned to kStreamConfigured through:
46 //
47 // ConfigureStreams() -> OnConfiguredStreams()
48 kStreamConfigured,
49
50 // The camera device is capturing video streams.
51 //
52 // The state is transitioned to kCapturing through:
53 //
54 // ConstructDefaultRequestSettings() ->
55 // OnConstructedDefaultRequestSettings() ->
56 // |stream_buffer_manager_|->StartCapture()
57 //
58 // In the kCapturing state the |stream_buffer_manager_| runs the capture
59 // loop to send capture requests and process capture results.
60 kCapturing,
61
62 // When the camera device is in the kCapturing state, a capture loop is
63 // constantly running in |stream_buffer_manager_|:
64 //
65 // On the StreamBufferManager side, we register and submit a capture
66 // request whenever a free buffer is available:
67 //
68 // RegisterBuffer() -> OnRegisteredBuffer() ->
69 // ProcessCaptureRequest() -> OnProcessedCaptureRequest()
70 //
71 // We get various capture metadata and error notifications from the camera
72 // HAL through the following callbacks:
73 //
74 // ProcessCaptureResult()
75 // Notify()
76
77 // The camera device is going through the shut down process; in order to
78 // avoid race conditions, no new Mojo messages may be sent to camera HAL in
79 // the kStopping state.
80 //
81 // The kStopping state is set in StopAndDeAllocate().
82 kStopping,
83
84 // The camera device encountered an unrecoverable error and needs to be
85 // StopAndDeAllocate()'d.
86 //
87 // The kError state is set in SetErrorState().
88 kError,
89 };
90
91 explicit CameraDeviceContext(
92 std::unique_ptr<VideoCaptureDevice::Client> client);
93
94 ~CameraDeviceContext();
95
96 void SetState(State state);
97
98 State GetState();
99
100 // Sets state to kError and call |client_->OnError| to tear down the
101 // VideoCaptureDevice.
102 void SetErrorState(const tracked_objects::Location& from_here,
103 const std::string& reason);
104
105 // Logs |message| to |client_|.
106 void LogToClient(std::string message);
107
108 // Submits the capture data to |client_->OnIncomingCapturedData|.
109 void SubmitCapturedData(const uint8_t* data,
110 int length,
111 const VideoCaptureFormat& frame_format,
112 base::TimeTicks reference_time,
113 base::TimeDelta timestamp);
114
115 void SetRotation(int rotation);
116
117 private:
118 friend class StreamBufferManagerTest;
119
120 SEQUENCE_CHECKER(sequence_checker_);
121
122 // The state the CameraDeviceDelegate currently is in.
123 State state_;
124
125 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270.
126 int rotation_;
127
128 std::unique_ptr<VideoCaptureDevice::Client> client_;
129
130 DISALLOW_IMPLICIT_CONSTRUCTORS(CameraDeviceContext);
131 };
132
133 } // namespace media
134
135 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_DEVICE_CONTEXT_CHROMEOS_H_
OLDNEW
« no previous file with comments | « media/capture/video/chromeos/OWNERS ('k') | media/capture/video/chromeos/camera_device_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698