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 <vector>
23 
24 #include "hal_types.h"
25 #include "internal_stream_manager.h"
26 #include "process_block.h"
27 
28 namespace android {
29 namespace google_camera_hal {
30 
31 // RequestProcessor defines the interface of a request processor. A request
32 // processor may modify the requests before sending the requests to its
33 // ProcessBlock. For example, if the original request contains a depth output
34 // stream, the request processor may request two output streams from dual
35 // cameras (one from each camera) in order to generate the depth stream in
36 // a downstream ProcessBlock.
37 class RequestProcessor {
38  public:
39   virtual ~RequestProcessor() = default;
40 
41   // Configure streams that will be supported by this RequestProcessor.
42   //
43   // internal_stream_manager is owned by the client and can be used by
44   // RequestProcessor to register new internal stream and get buffers for those
45   // internal streams.
46   // stream_config is the desired stream configuration by the client.
47   // process_block_stream_config will be filled with streams that are supported
48   // by this RequestProcessor and should be used to configure the ProcessBlock
49   // it's going to be connected to.
50   // process_block_stream_config may contain additional streams
51   // that are not present in stream_config. Those additional streams are
52   // internal streams that may be produced by this RequestProcessor via
53   // ProcessRequest().
54   virtual status_t ConfigureStreams(
55       InternalStreamManager* internal_stream_manager,
56       const StreamConfiguration& stream_config,
57       StreamConfiguration* process_block_stream_config) = 0;
58 
59   // Set the process block to send requests to. This must be called exactly
60   // once before calling ProcessRequest. SetProcessBlock will return
61   // ALREADY_EXISTS if it's called more than once.
62   virtual status_t SetProcessBlock(
63       std::unique_ptr<ProcessBlock> process_block) = 0;
64 
65   // Process a capture request. The request processor will generate requests
66   // for the process block based on the original request.
67   virtual status_t ProcessRequest(const CaptureRequest& request) = 0;
68 
69   // Flush all pending requests.
70   virtual status_t Flush() = 0;
71 
72   virtual void RepeatingRequestEnd(int32_t frame_number,
73                                    const std::vector<int32_t>& stream_ids) = 0;
74 };
75 
76 }  // namespace google_camera_hal
77 }  // namespace android
78 
79 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REQUEST_PROCESSOR_H_