[go: nahoru, domu]

blob: 388167c713157c785dfd98352a279c26f64c342a [file] [log] [blame]
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.camera.camera2.pipe.impl
import android.view.Surface
import androidx.camera.camera2.pipe.StreamId
import javax.inject.Inject
/**
* This object keeps track of which surfaces have been configured for each stream. In addition,
* it will keep track of which surfaces have changed or replaced so that the CaptureSession can be
* reconfigured if the configured surfaces change.
*/
@CameraGraphScope
class StreamMap @Inject constructor() {
private val activeSurfaceMap: MutableMap<StreamId, Surface> = mutableMapOf()
operator fun set(stream: StreamId, surface: Surface?) {
if (surface == null) {
// TODO: Tell the graph processor that it should resubmit the repeating request or
// reconfigure the camera2 captureSession
activeSurfaceMap.remove(stream)
} else {
activeSurfaceMap[stream] = surface
}
}
operator fun get(stream: StreamId): Surface? = activeSurfaceMap[stream]
}