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

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

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: address chfremer's comments 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 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()
chfremer 2017/06/08 21:58:37 As much as I appreciate the detailed documentation
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 void SetState(State state);
95
96 State GetState();
97
98 // Sets state to kError and call |client_->OnError| to tear down the
99 // VideoCaptureDevice.
100 void SetErrorState(const tracked_objects::Location& from_here,
101 const std::string& reason);
102
103 // Logs |message| to |client_|.
104 void LogToClient(std::string message);
105
106 // Submits the capture data to |client_->OnIncomingCapturedData|.
107 void SubmitCapturedData(const uint8_t* data,
108 int length,
109 const VideoCaptureFormat& frame_format,
110 base::TimeTicks reference_time,
111 base::TimeDelta timestamp);
112
113 void SetRotation(int rotation);
114
115 private:
116 SEQUENCE_CHECKER(sequence_checker_);
117
118 // The state the CameraDeviceDelegate currently is in.
119 State state_;
120
121 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270.
122 int rotation_;
123
124 std::unique_ptr<VideoCaptureDevice::Client> client_;
125
126 DISALLOW_IMPLICIT_CONSTRUCTORS(CameraDeviceContext);
127 };
128
129 } // namespace media
130
131 #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_DEVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698