• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RESULT_PROCESSOR_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_PROCESSOR_H_
19 
20 #include <shared_mutex>
21 
22 #include "hal_types.h"
23 #include "internal_stream_manager.h"
24 #include "result_processor.h"
25 
26 namespace android {
27 namespace google_camera_hal {
28 
29 // RealtimeZslResultProcessor implements a ResultProcessor that return
30 // filled buffer and metadata to internal stream manager.
31 class RealtimeZslResultProcessor : public ResultProcessor {
32  public:
33   static std::unique_ptr<RealtimeZslResultProcessor> Create(
34       InternalStreamManager* internal_stream_manager, int32_t stream_id,
35       android_pixel_format_t pixel_format, uint32_t partial_result_count = 1);
36 
37   virtual ~RealtimeZslResultProcessor() = default;
38 
39   // Override functions of ResultProcessor start.
40   void SetResultCallback(
41       ProcessCaptureResultFunc process_capture_result, NotifyFunc notify,
42       ProcessBatchCaptureResultFunc process_batch_capture_result,
43       NotifyBatchFunc notify_batch) override;
44 
45   status_t AddPendingRequests(
46       const std::vector<ProcessBlockRequest>& process_block_requests,
47       const CaptureRequest& remaining_session_request) override;
48 
49   // Return filled buffer and metadata to internal stream manager
50   // and forwards the results without buffer to its callback functions.
51   void ProcessResult(ProcessBlockResult block_result) override;
52 
53   void Notify(const ProcessBlockNotifyMessage& block_message) override;
54 
55   status_t FlushPendingRequests() override;
56   // Override functions of ResultProcessor end.
57 
58  protected:
59   RealtimeZslResultProcessor(InternalStreamManager* internal_stream_manager,
60                              int32_t stream_id, uint32_t partial_result_count);
61 
62   InternalStreamManager* internal_stream_manager_;
63   int32_t stream_id_ = -1;
64   // Partial result count reported by HAL
65   uint32_t partial_result_count_;
66 
67   std::mutex callback_lock_;
68 
69   // The following callbacks must be protected by callback_lock_.
70   ProcessCaptureResultFunc process_capture_result_;
71   NotifyFunc notify_;
72 
73  private:
74   std::shared_mutex process_block_shared_lock_;
75 };
76 
77 }  // namespace google_camera_hal
78 }  // namespace android
79 
80 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_REQUEST_PROCESSOR_H_
81