Skip to content

Commit

Permalink
fix(core): source: camera: replace logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 3, 2024
1 parent 50cf4c2 commit 4e53f71
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package io.github.thibaultbee.streampack.core.internal.sources.video.camera

import android.Manifest
import android.content.Context
import android.util.Log
import android.view.Surface
import androidx.annotation.RequiresPermission
import io.github.thibaultbee.streampack.core.data.VideoConfig
import io.github.thibaultbee.streampack.core.internal.data.Frame
import io.github.thibaultbee.streampack.core.internal.utils.av.video.DynamicRangeProfile
import io.github.thibaultbee.streampack.core.logger.Logger
import io.github.thibaultbee.streampack.core.utils.extensions.defaultCameraId
import io.github.thibaultbee.streampack.core.utils.extensions.isFrameRateSupported
import kotlinx.coroutines.runBlocking
Expand All @@ -34,14 +34,14 @@ class CameraSource(
var previewSurface: Surface? = null
set(value) {
if (field == value) {
Log.w(TAG, "Preview surface is already set to $value")
Logger.w(TAG, "Preview surface is already set to $value")
return
}
if (cameraController.isCameraRunning) {
if (value == null) {
stopPreview()
} else {
Log.e(TAG, "Need to restart camera to change preview surface")
Logger.e(TAG, "Need to restart camera to change preview surface")
field = value
runBlocking {
restartCamera()
Expand All @@ -55,7 +55,7 @@ class CameraSource(
override var outputSurface: Surface? = null
set(value) {
if (field == value) {
Log.w(TAG, "Output surface is already set to $value")
Logger.w(TAG, "Output surface is already set to $value")
return
}
if (cameraController.isCameraRunning) {
Expand All @@ -64,14 +64,15 @@ class CameraSource(
stopStream()
}
} else {
Log.e(TAG, "Need to restart camera to change output surface")
Logger.e(TAG, "Need to restart camera to change output surface")
field = value
runBlocking {
restartCamera()
}
}
} else {
field = value
}
field = value
}

override var cameraId: String = context.defaultCameraId
Expand All @@ -82,7 +83,7 @@ class CameraSource(
throw UnsupportedOperationException("Camera $value does not support $fps fps")
}
if (field == value) {
Log.w(TAG, "Camera ID is already set to $value")
Logger.w(TAG, "Camera ID is already set to $value")
return
}

Expand All @@ -93,7 +94,7 @@ class CameraSource(
}
}

private var cameraController = CameraController(context)
private val cameraController = CameraController(context)
override val settings = CameraSettings(context, cameraController)

override val timestampOffset = CameraHelper.getTimeOffsetToMonoClock(context, cameraId)
Expand Down Expand Up @@ -122,7 +123,7 @@ class CameraSource(

override fun configure(config: VideoConfig) {
if (!context.isFrameRateSupported(cameraId, config.fps)) {
Log.w(TAG, "Camera $cameraId does not support ${config.fps} fps")
Logger.w(TAG, "Camera $cameraId does not support ${config.fps} fps")
}

var needRestart = false
Expand Down Expand Up @@ -151,7 +152,7 @@ class CameraSource(
if (surfacesToRestart.isNotEmpty()) {
startCameraRequestSessionIfNeeded(surfacesToRestart)
} else {
Log.w(TAG, "Trying to restart camera without surfaces")
Logger.w(TAG, "Trying to restart camera without surfaces")
}
}

Expand Down Expand Up @@ -181,7 +182,7 @@ class CameraSource(
@RequiresPermission(Manifest.permission.CAMERA)
suspend fun startPreview() {
if (isPreviewing) {
Log.w(TAG, "Camera is already previewing")
Logger.w(TAG, "Camera is already previewing")
return
}

Expand All @@ -191,7 +192,7 @@ class CameraSource(

fun stopPreview() {
if (!isPreviewing) {
Log.w(TAG, "Camera is not previewing")
Logger.w(TAG, "Camera is not previewing")
return
}

Expand All @@ -200,7 +201,7 @@ class CameraSource(

override suspend fun startStream() {
if (isStreaming) {
Log.w(TAG, "Camera is already streaming")
Logger.w(TAG, "Camera is already streaming")
return
}

Expand All @@ -212,7 +213,7 @@ class CameraSource(

override suspend fun stopStream() {
if (!isStreaming) {
Log.w(TAG, "Camera is not streaming")
Logger.w(TAG, "Camera is not streaming")
return
}

Expand Down

0 comments on commit 4e53f71

Please sign in to comment.