• 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_CAPTURE_SESSION_UTILS_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAPTURE_SESSION_UTILS_H_
19 
20 #include <utils/Errors.h>
21 
22 #include "camera_buffer_allocator_hwl.h"
23 #include "camera_device_session_hwl.h"
24 #include "capture_session.h"
25 #include "hal_types.h"
26 #include "hwl_types.h"
27 
28 namespace android {
29 namespace google_camera_hal {
30 
31 // Session function invoked to query if particular stream config supported
32 using StreamConfigSupportedFunc =
33     std::function<bool(CameraDeviceSessionHwl* device_session_hwl,
34                        const StreamConfiguration& stream_config)>;
35 
36 // Session function invoked to create session instance
37 using CaptureSessionCreateFunc = std::function<std::unique_ptr<CaptureSession>(
38     CameraDeviceSessionHwl* device_session_hwl,
39     const StreamConfiguration& stream_config,
40     ProcessCaptureResultFunc process_capture_result,
41     ProcessBatchCaptureResultFunc process_capture_batch_result,
42     NotifyFunc notify, HwlSessionCallback session_callback,
43     std::vector<HalStream>* hal_configured_streams,
44     CameraBufferAllocatorHwl* camera_allocator_hwl)>;
45 
46 // define entry points to capture session
47 struct CaptureSessionEntryFuncs {
48   StreamConfigSupportedFunc IsStreamConfigurationSupported;
49   CaptureSessionCreateFunc CreateSession;
50 };
51 
52 // Session function invoked to create wrapper capture session instance
53 using WrapperCaptureSessionCreateFunc =
54     std::function<std::unique_ptr<CaptureSession>(
55         const StreamConfiguration& stream_config,
56         const std::vector<ExternalCaptureSessionFactory*>&
57             external_capture_session_entries,
58         const std::vector<CaptureSessionEntryFuncs>& capture_session_entries,
59         HwlSessionCallback hwl_session_callback,
60         CameraBufferAllocatorHwl* camera_buffer_allocator_hwl,
61         CameraDeviceSessionHwl* camera_device_session_hwl,
62         std::vector<HalStream>* hal_configured_streams,
63         ProcessCaptureResultFunc process_capture_result, NotifyFunc notify)>;
64 
65 // define entry points to capture session
66 struct WrapperCaptureSessionEntryFuncs {
67   StreamConfigSupportedFunc IsStreamConfigurationSupported;
68   WrapperCaptureSessionCreateFunc CreateSession;
69 };
70 
71 // Select and create capture session.
72 // When consider_zsl_capture_session is enabled, we will first consider using
73 // ZslCaptureSession as a wrapper capture session when it supports the given
74 // configurations.
75 std::unique_ptr<CaptureSession> CreateCaptureSession(
76     const StreamConfiguration& stream_config,
77     const std::vector<WrapperCaptureSessionEntryFuncs>&
78         wrapper_capture_session_entries,
79     const std::vector<ExternalCaptureSessionFactory*>&
80         external_capture_session_entries,
81     const std::vector<CaptureSessionEntryFuncs>& capture_session_entries,
82     HwlSessionCallback hwl_session_callback,
83     CameraBufferAllocatorHwl* camera_buffer_allocator_hwl,
84     CameraDeviceSessionHwl* camera_device_session_hwl,
85     std::vector<HalStream>* hal_config,
86     ProcessCaptureResultFunc process_capture_result, NotifyFunc notify,
87     ProcessBatchCaptureResultFunc process_batch_capture_result = nullptr);
88 
89 }  // namespace google_camera_hal
90 }  // namespace android
91 
92 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAPTURE_SESSION_UTILS_H_