1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REQUEST_PROCESSOR_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REQUEST_PROCESSOR_H_
19 
20 #include <utils/Errors.h>
21 
22 #include "hal_types.h"
23 #include "internal_stream_manager.h"
24 #include "process_block.h"
25 
26 namespace android {
27 namespace google_camera_hal {
28 
29 // RequestProcessor defines the interface of a request processor. A request
30 // processor may modify the requests before sending the requests to its
31 // ProcessBlock. For example, if the original request contains a depth output
32 // stream, the request processor may request two output streams from dual
33 // cameras (one from each camera) in order to generate the depth stream in
34 // a downstream ProcessBlock.
35 class RequestProcessor {
36  public:
37   virtual ~RequestProcessor() = default;
38 
39   // Configure streams that will be supported by this RequestProcessor.
40   //
41   // internal_stream_manager is owned by the client and can be used by
42   // RequestProcessor to register new internal stream and get buffers for those
43   // internal streams.
44   // stream_config is the desired stream configuration by the client.
45   // process_block_stream_config will be filled with streams that are supported
46   // by this RequestProcessor and should be used to configure the ProcessBlock
47   // it's going to be connected to.
48   // process_block_stream_config may contain additional streams
49   // that are not present in stream_config. Those additional streams are
50   // internal streams that may be produced by this RequestProcessor via
51   // ProcessRequest().
52   virtual status_t ConfigureStreams(
53       InternalStreamManager* internal_stream_manager,
54       const StreamConfiguration& stream_config,
55       StreamConfiguration* process_block_stream_config) = 0;
56 
57   // Set the process block to send requests to. This must be called exactly
58   // once before calling ProcessRequest. SetProcessBlock will return
59   // ALREADY_EXISTS if it's called more than once.
60   virtual status_t SetProcessBlock(
61       std::unique_ptr<ProcessBlock> process_block) = 0;
62 
63   // Process a capture request. The request processor will generate requests
64   // for the process block based on the original request.
65   virtual status_t ProcessRequest(const CaptureRequest& request) = 0;
66 
67   // Flush all pending requests.
68   virtual status_t Flush() = 0;
69 };
70 
71 }  // namespace google_camera_hal
72 }  // namespace android
73 
74 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REQUEST_PROCESSOR_H_