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_RESULT_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_RESULT_PROCESSOR_H_ 19 20 #include <utils/Errors.h> 21 22 #include "hal_types.h" 23 #include "process_block.h" 24 25 namespace android { 26 namespace google_camera_hal { 27 28 // ResultProcessor defines the interface of a result processor. A result 29 // processor receives results from a ProcessBlock. It can return the finished 30 // results to the specified callback functions. If a class inherits both 31 // ResultProcessor and RequestProcessor interfaces, it can convert the results 32 // to requests to send to the next ProcessBlock. 33 class ResultProcessor { 34 public: 35 virtual ~ResultProcessor() = default; 36 37 // Set the callbacks to send the finished results. Must be called before 38 // calling ProcessResult. 39 virtual void SetResultCallback( 40 ProcessCaptureResultFunc process_capture_result, NotifyFunc notify, 41 ProcessBatchCaptureResultFunc process_batch_capture_result, 42 NotifyBatchFunc notify_batch) = 0; 43 44 // Add pending requests to the result processor. 45 // 46 // process_block_requests are the requests that will be completed by the 47 // preceding process block. 48 // 49 // remaining_session_request is the remaining request that was sent to the 50 // capture session. It contains all remaining output buffers that have not 51 // been completed by the process chain yet. For the last result process in a 52 // process chain, remaining_session_request should contain only the output 53 // buffers that are present in process_block_requests. 54 // remaining_session_request doesn't contain any internal buffers. 55 virtual status_t AddPendingRequests( 56 const std::vector<ProcessBlockRequest>& process_block_requests, 57 const CaptureRequest& remaining_session_request) = 0; 58 59 // Called by a ProcessBlock to send the capture results. 60 virtual void ProcessResult(ProcessBlockResult block_result) = 0; 61 62 // Called by a ProcessBlock to send the batched capture results. ProcessBatchResult(std::vector<ProcessBlockResult> block_results)63 virtual void ProcessBatchResult(std::vector<ProcessBlockResult> block_results) { 64 for (auto& result : block_results) { 65 ProcessResult(std::move(result)); 66 } 67 } 68 69 // Called by a ProcessBlock to notify a message. 70 virtual void Notify(const ProcessBlockNotifyMessage& block_message) = 0; 71 72 // Called by a ProcessBlock to notify multiple notify messages. NotifyBatch(const std::vector<ProcessBlockNotifyMessage> & block_messages)73 virtual void NotifyBatch( 74 const std::vector<ProcessBlockNotifyMessage>& block_messages) { 75 for (const auto& message : block_messages) { 76 Notify(message); 77 }; 78 } 79 80 // Flush all pending workload. 81 virtual status_t FlushPendingRequests() = 0; 82 }; 83 84 } // namespace google_camera_hal 85 } // namespace android 86 87 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_RESULT_PROCESSOR_H_