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_REALTIME_ZSL_REQUEST_PROCESSOR_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_
19 
20 #include "process_block.h"
21 #include "request_processor.h"
22 #include "vendor_tag_types.h"
23 
24 namespace android {
25 namespace google_camera_hal {
26 
27 // RealtimeZslRequestProcessor implements a RequestProcessor that adds
28 // internal raw stream to request and forwards the request to its ProcessBlock.
29 class RealtimeZslRequestProcessor : public RequestProcessor {
30  public:
31   // device_session_hwl is owned by the caller and must be valid during the
32   // lifetime of this RealtimeZslRequestProcessor.
33   static std::unique_ptr<RealtimeZslRequestProcessor> Create(
34       CameraDeviceSessionHwl* device_session_hwl);
35 
36   virtual ~RealtimeZslRequestProcessor() = default;
37 
38   // Override functions of RequestProcessor start.
39   // RealtimeZslRequestProcessor will configure all streams in stream_config.
40   // And register one internal raw stream
41   status_t ConfigureStreams(
42       InternalStreamManager* internal_stream_manager,
43       const StreamConfiguration& stream_config,
44       StreamConfiguration* process_block_stream_config) override;
45 
46   // Set the realtime process block for sending requests later.
47   status_t SetProcessBlock(std::unique_ptr<ProcessBlock> process_block) override;
48 
49   // Add one additional RAW output to capture request
50   // And forwards the capture request to realtime process
51   status_t ProcessRequest(const CaptureRequest& request) override;
52 
53   status_t Flush() override;
54   // Override functions of RequestProcessor end.
55 
56  protected:
57   RealtimeZslRequestProcessor() = default;
58 
59  private:
60   status_t Initialize(CameraDeviceSessionHwl* device_session_hwl);
61   std::mutex process_block_lock_;
62 
63   // Protected by process_block_lock_.
64   std::unique_ptr<ProcessBlock> process_block_;
65 
66   InternalStreamManager* internal_stream_manager_;
67   bool preview_intent_seen_ = false;
68   int32_t raw_stream_id_ = -1;
69   uint32_t active_array_width_ = 0;
70   uint32_t active_array_height_ = 0;
71 
72   HdrMode hdr_mode_ = HdrMode::kHdrplusMode;
73 
74   // If HDR+ ZSL is enabled.
75   bool is_hdrplus_zsl_enabled_ = true;
76 };
77 
78 }  // namespace google_camera_hal
79 }  // namespace android
80 
81 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_REQUEST_PROCESSOR_H_
82