1 /* 2 * Copyright (C) 2024 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 package com.google.jetpackcamera.core.camera 17 18 import android.content.Context 19 import androidx.camera.core.SurfaceRequest 20 import androidx.camera.lifecycle.ProcessCameraProvider 21 import kotlinx.coroutines.CoroutineDispatcher 22 import kotlinx.coroutines.channels.Channel 23 import kotlinx.coroutines.channels.SendChannel 24 import kotlinx.coroutines.flow.MutableStateFlow 25 import kotlinx.coroutines.flow.StateFlow 26 27 /** 28 * Context that can be shared by all functions in a camera session. 29 * 30 * Can be used to confer context (such as reactive state or session-wide parameters) 31 * on context receivers using [with] in a camera session. 32 */ 33 internal data class CameraSessionContext( 34 val context: Context, 35 val cameraProvider: ProcessCameraProvider, 36 val backgroundDispatcher: CoroutineDispatcher, 37 val screenFlashEvents: SendChannel<CameraUseCase.ScreenFlashEvent>, 38 val focusMeteringEvents: Channel<CameraEvent.FocusMeteringEvent>, 39 val videoCaptureControlEvents: Channel<VideoCaptureControlEvent>, 40 val currentCameraState: MutableStateFlow<CameraState>, 41 val surfaceRequests: MutableStateFlow<SurfaceRequest?>, 42 val transientSettings: StateFlow<TransientSessionSettings?> 43 ) 44