1 /* 2 * Copyright 2020 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 package androidx.camera.camera2.pipe 18 19 import android.hardware.camera2.CameraExtensionSession 20 import androidx.annotation.RestrictTo 21 22 /** 23 * This defines a fixed set of inputs and outputs for a single [CameraGraph] instance. 24 * 25 * [CameraStream]s can be used to build [Request]s that are sent to a [CameraGraph]. 26 */ 27 @JvmDefaultWithCompatibility 28 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 29 public interface StreamGraph { 30 public val streams: List<CameraStream> 31 public val streamIds: Set<StreamId> 32 public val inputs: List<InputStream> 33 public val outputs: List<OutputStream> 34 getnull35 public operator fun get(config: CameraStream.Config): CameraStream? 36 37 public operator fun get(streamId: StreamId): CameraStream? = streams.find { it.id == streamId } 38 <lambda>null39 public operator fun get(outputId: OutputId): OutputStream? = outputs.find { it.id == outputId } 40 41 /** 42 * Get the estimated real time latency for an extension session or output stall duration for a 43 * regular session. This method accepts an [OutputId] for MultiResolution use cases when there 44 * are multiple streams. This method returns null if the [StreamGraph] is not configured 45 * correctly or if the Android version is under 34 for extensions. 46 */ getOutputLatencynull47 public fun getOutputLatency(streamId: StreamId, outputId: OutputId? = null): OutputLatency? 48 49 /** Wrapper class for [CameraExtensionSession.StillCaptureLatency] object. */ 50 public data class OutputLatency( 51 public val estimatedCaptureLatencyNs: Long, 52 public val estimatedProcessingLatencyNs: Long 53 ) { 54 public val estimatedLatencyNs: Long 55 get() = estimatedCaptureLatencyNs + estimatedProcessingLatencyNs 56 } 57 } 58