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,NotifyBatchFunc notify_batch)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 NotifyBatchFunc notify_batch) {
38 // first pass: check predefined wrapper capture session
39 for (auto sessionEntry : wrapper_capture_session_entries) {
40 if (sessionEntry.IsStreamConfigurationSupported(camera_device_session_hwl,
41 stream_config)) {
42 return sessionEntry.CreateSession(
43 stream_config, external_capture_session_entries,
44 capture_session_entries, hwl_session_callback,
45 camera_buffer_allocator_hwl, camera_device_session_hwl, hal_config,
46 process_capture_result, notify);
47 }
48 }
49
50 // second pass: check loaded external capture sessions
51 for (auto externalSession : external_capture_session_entries) {
52 if (externalSession->IsStreamConfigurationSupported(
53 camera_device_session_hwl, stream_config)) {
54 return externalSession->CreateSession(
55 camera_device_session_hwl, stream_config, process_capture_result,
56 notify, hwl_session_callback, hal_config, camera_buffer_allocator_hwl);
57 }
58 }
59
60 // third pass: check predefined capture sessions
61 for (auto sessionEntry : capture_session_entries) {
62 if (sessionEntry.IsStreamConfigurationSupported(camera_device_session_hwl,
63 stream_config)) {
64 return sessionEntry.CreateSession(
65 camera_device_session_hwl, stream_config,
66 std::move(process_capture_result),
67 std::move(process_batch_capture_result), std::move(notify),
68 std::move(notify_batch), hwl_session_callback, hal_config,
69 camera_buffer_allocator_hwl);
70 }
71 }
72 return nullptr;
73 }
74
75 } // namespace google_camera_hal
76 } // namespace android