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_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAPTURE_SESSION_H_ 19 20 #include <utils/Errors.h> 21 22 #include "camera_buffer_allocator_hwl.h" 23 #include "camera_device_session_hwl.h" 24 #include "hal_types.h" 25 #include "hwl_types.h" 26 27 namespace android { 28 namespace google_camera_hal { 29 30 // CaptureSession defines the interface of a capture session. Each capture 31 // session is associated with a certain stream configuration. 32 // Classes that inherit this interface class should provide a 33 // 1. IsStreamConfigurationSupported() for the client to query whether a 34 // stream configuration is supported by this capture session. 35 // 2. Create() for the client to create a capture session and get a unique 36 // pointer to the capture session. 37 // 38 // A capture session can use RequestProcessor, ProcessBlock, and ResultProcessor 39 // to form chains of process blocks. A simple capture session can create a 40 // simple chain like 41 // 42 // RequestProcessor -> ProcessBlock -> ResultProcessor 43 // 44 // If additional post-processing is needed, more ProcessBlock can be added to 45 // the process chain like 46 // 47 // RequestProcessor -> ProcessBlock_0 -> Result/RequestProcessor -> 48 // ProcessBlock_1 -> ResultProcessor 49 // 50 // Each implementation of RequestProcess, ProcessBlock, and ResultProcessor must 51 // clearly define their capabilities. 52 class CaptureSession { 53 public: 54 virtual ~CaptureSession() = default; 55 56 // Process a capture request. 57 virtual status_t ProcessRequest(const CaptureRequest& request) = 0; 58 59 // Flush all pending capture requests. 60 virtual status_t Flush() = 0; 61 }; 62 63 // ExternalCaptureSessionFactory defines the interface of an external capture 64 // session, in addition to `class CaptureSession`. 65 class ExternalCaptureSessionFactory { 66 public: 67 virtual ~ExternalCaptureSessionFactory() = default; 68 69 // IsStreamConfigurationSupported is called by the client to query whether a 70 // stream configuration is supported by this capture session. 71 virtual bool IsStreamConfigurationSupported( 72 CameraDeviceSessionHwl* device_session_hwl, 73 const StreamConfiguration& stream_config) = 0; 74 75 // Create is called by the client to create a capture session and get a unique 76 // pointer to the capture session. 77 virtual std::unique_ptr<CaptureSession> CreateSession( 78 CameraDeviceSessionHwl* device_session_hwl, 79 const StreamConfiguration& stream_config, 80 ProcessCaptureResultFunc process_capture_result, NotifyFunc notify, 81 HwlSessionCallback session_callback, 82 std::vector<HalStream>* hal_configured_streams, 83 CameraBufferAllocatorHwl* camera_allocator_hwl) = 0; 84 }; 85 86 #if !GCH_HWL_USE_DLOPEN 87 extern "C" __attribute__((weak)) ExternalCaptureSessionFactory* 88 GetCaptureSessionFactory(); 89 #endif 90 91 } // namespace google_camera_hal 92 } // namespace android 93 94 #endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_CAPTURE_SESSION_H_