1 /* 2 * Copyright (C) 2021 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_SNAPSHOT_RESULT_PROCESSOR_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_SNAPSHOT_RESULT_PROCESSOR_H_ 19 20 #include "internal_stream_manager.h" 21 #include "result_processor.h" 22 23 namespace android { 24 namespace google_camera_hal { 25 26 // SnapshotResultProcessor implements a ResultProcessor that return 27 // yuv buffer to internal stream manager and forwards the results without 28 // yuv buffer to its callback functions. 29 class SnapshotResultProcessor : public ResultProcessor { 30 public: 31 static std::unique_ptr<SnapshotResultProcessor> Create( 32 InternalStreamManager* internal_stream_manager, int32_t yuv_stream_id); 33 34 virtual ~SnapshotResultProcessor() = default; 35 36 // Override functions of ResultProcessor start. 37 void SetResultCallback(ProcessCaptureResultFunc process_capture_result, 38 NotifyFunc notify) override; 39 40 status_t AddPendingRequests( 41 const std::vector<ProcessBlockRequest>& process_block_requests, 42 const CaptureRequest& remaining_session_request) override; 43 44 // Return yuv buffer to internal stream manager and forwards the results 45 // without yuv buffer to its callback functions. 46 void ProcessResult(ProcessBlockResult block_result) override; 47 48 void Notify(const ProcessBlockNotifyMessage& block_message) override; 49 50 status_t FlushPendingRequests() override; 51 // Override functions of ResultProcessor end. 52 53 protected: 54 SnapshotResultProcessor(InternalStreamManager* internal_stream_manager, 55 int32_t yuv_stream_id); 56 57 private: 58 std::mutex callback_lock_; 59 60 // The following callbacks must be protected by callback_lock_. 61 ProcessCaptureResultFunc process_capture_result_; 62 NotifyFunc notify_; 63 64 InternalStreamManager* internal_stream_manager_ = nullptr; 65 int32_t yuv_stream_id_ = -1; 66 }; 67 68 } // namespace google_camera_hal 69 } // namespace android 70 71 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_SNAPSHOT_RESULT_PROCESSOR_H_