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 #include "capture_session_utils.h"
18
19 #include "zsl_snapshot_capture_session.h"
20
21 namespace android {
22 namespace google_camera_hal {
23
CreateCaptureSession(const StreamConfiguration & stream_config,const std::vector<WrapperCaptureSessionEntryFuncs> & wrapper_capture_session_entries,const std::vector<ExternalCaptureSessionFactory * > & external_capture_session_entries,const std::vector<CaptureSessionEntryFuncs> & capture_session_entries,HwlSessionCallback hwl_session_callback,CameraBufferAllocatorHwl * camera_buffer_allocator_hwl,CameraDeviceSessionHwl * camera_device_session_hwl,std::vector<HalStream> * hal_config,ProcessCaptureResultFunc process_capture_result,NotifyFunc notify,ProcessBatchCaptureResultFunc process_batch_capture_result)24 std::unique_ptr<CaptureSession> CreateCaptureSession(
25 const StreamConfiguration& stream_config,
26 const std::vector<WrapperCaptureSessionEntryFuncs>&
27 wrapper_capture_session_entries,
28 const std::vector<ExternalCaptureSessionFactory*>&
29 external_capture_session_entries,
30 const std::vector<CaptureSessionEntryFuncs>& capture_session_entries,
31 HwlSessionCallback hwl_session_callback,
32 CameraBufferAllocatorHwl* camera_buffer_allocator_hwl,
33 CameraDeviceSessionHwl* camera_device_session_hwl,
34 std::vector<HalStream>* hal_config,
35 ProcessCaptureResultFunc process_capture_result, NotifyFunc notify,
36 ProcessBatchCaptureResultFunc process_batch_capture_result) {
37 // first pass: check predefined wrapper capture session
38 for (auto sessionEntry : wrapper_capture_session_entries) {
39 if (sessionEntry.IsStreamConfigurationSupported(camera_device_session_hwl,
40 stream_config)) {
41 return sessionEntry.CreateSession(
42 stream_config, external_capture_session_entries,
43 capture_session_entries, hwl_session_callback,
44 camera_buffer_allocator_hwl, camera_device_session_hwl, hal_config,
45 process_capture_result, notify);
46 }
47 }
48
49 // second pass: check loaded external capture sessions
50 for (auto externalSession : external_capture_session_entries) {
51 if (externalSession->IsStreamConfigurationSupported(
52 camera_device_session_hwl, stream_config)) {
53 return externalSession->CreateSession(
54 camera_device_session_hwl, stream_config, process_capture_result,
55 notify, hwl_session_callback, hal_config, camera_buffer_allocator_hwl);
56 }
57 }
58
59 // third pass: check predefined capture sessions
60 for (auto sessionEntry : capture_session_entries) {
61 if (sessionEntry.IsStreamConfigurationSupported(camera_device_session_hwl,
62 stream_config)) {
63 return sessionEntry.CreateSession(
64 camera_device_session_hwl, stream_config, process_capture_result,
65 process_batch_capture_result, notify, hwl_session_callback,
66 hal_config, camera_buffer_allocator_hwl);
67 }
68 }
69 return nullptr;
70 }
71
72 } // namespace google_camera_hal
73 } // namespace android