|
|
|
|
@ -119,7 +119,7 @@ class StreamCaptureEngine(
|
|
|
|
|
if (previous != null && config.copy(videoBitrate = previous.videoBitrate) == previous) { |
|
|
|
|
try { |
|
|
|
|
encoder!!.setParameters(Bundle().apply { putInt(MediaCodec.PARAMETER_KEY_VIDEO_BITRATE, config.bitrate) }) |
|
|
|
|
lastGood = config; ready(config, false) |
|
|
|
|
lastGood = config; activeConfig = config; ready(config, false) |
|
|
|
|
LogManager.addLog("INFO", "video", "bitrate changed id=$id revision=$generation ${previous.bitrate}->${config.bitrate}") |
|
|
|
|
return@post |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
@ -256,7 +256,8 @@ class StreamCaptureEngine(
|
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
if (output != null) { |
|
|
|
|
val map = manager.getCameraCharacteristics(mode.camera).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP) |
|
|
|
|
val characteristics = manager.getCameraCharacteristics(mode.camera) |
|
|
|
|
val map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP) |
|
|
|
|
?: error("Missing preview stream map") |
|
|
|
|
val size = if (mode.highSpeed) android.util.Size(mode.width, mode.height) else |
|
|
|
|
map.getOutputSizes(SurfaceTexture::class.java).orEmpty().filter { |
|
|
|
|
@ -264,11 +265,11 @@ class StreamCaptureEngine(
|
|
|
|
|
&& it.width.toLong() * mode.height == it.height.toLong() * mode.width |
|
|
|
|
}.maxByOrNull { it.width * it.height } ?: error("No compatible camera preview size") |
|
|
|
|
output.texture.setDefaultBufferSize(size.width, size.height) |
|
|
|
|
format = StreamPreviewFormat(size.width, size.height, cameraPose(mode.camera)) |
|
|
|
|
format = StreamPreviewFormat(size.width, size.height, cameraPose(mode.camera), |
|
|
|
|
characteristics.get(CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE) == CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME) |
|
|
|
|
preview.update(format) |
|
|
|
|
} else if (withPreview) preview.update(preview.state.value.format) |
|
|
|
|
val targets = listOfNotNull(input, output?.surface) |
|
|
|
|
check(targets.isNotEmpty()) { "Missing encoder surface" } |
|
|
|
|
val targets = listOfNotNull(checkNotNull(input) { "Missing encoder surface" }, output?.surface) |
|
|
|
|
val callback = object : CameraCaptureSession.StateCallback() { |
|
|
|
|
override fun onConfigured(configured: CameraCaptureSession) { |
|
|
|
|
if (!valid()) { configured.close(); return } |
|
|
|
|
|