Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support CodeScanner and Video simultaneously #2412

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions package/android/src/main/java/com/mrousavy/camera/CameraView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ class CameraView(context: Context) :
}

// Video/Frame Processor
if (video == true || enableFrameProcessor) {
val codeScanner = codeScannerOptions
if (video == true || enableFrameProcessor || codeScanner != null) {
config.video = CameraConfiguration.Output.Enabled.create(
CameraConfiguration.Video(
videoHdr,
pixelFormat,
enableFrameProcessor
enableFrameProcessor,
codeScanner
)
)
} else {
Expand All @@ -173,16 +175,6 @@ class CameraView(context: Context) :
config.audio = CameraConfiguration.Output.Disabled.create()
}

// Code Scanner
val codeScanner = codeScannerOptions
if (codeScanner != null) {
config.codeScanner = CameraConfiguration.Output.Enabled.create(
CameraConfiguration.CodeScanner(codeScanner.codeTypes)
)
} else {
config.codeScanner = CameraConfiguration.Output.Disabled.create()
}

// Orientation
config.orientation = orientation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ data class CameraConfiguration(
var preview: Output<Preview> = Output.Disabled.create(),
var photo: Output<Photo> = Output.Disabled.create(),
var video: Output<Video> = Output.Disabled.create(),
var codeScanner: Output<CodeScanner> = Output.Disabled.create(),

// Orientation
var orientation: Orientation = Orientation.PORTRAIT,
Expand Down Expand Up @@ -44,7 +43,7 @@ data class CameraConfiguration(
// Output<T> types, those need to be comparable
data class CodeScanner(val codeTypes: List<CodeType>)
data class Photo(val enableHdr: Boolean)
data class Video(val enableHdr: Boolean, val pixelFormat: PixelFormat, val enableFrameProcessor: Boolean)
data class Video(val enableHdr: Boolean, val pixelFormat: PixelFormat, val enableFrameProcessor: Boolean, val codeScanner: CodeScannerOptions?)
data class Audio(val nothing: Unit)
data class Preview(val surface: Surface)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
}

// CodeScanner Output
val codeScanner = configuration.codeScanner as? CameraConfiguration.Output.Enabled<CameraConfiguration.CodeScanner>
if (codeScanner != null) {
val imageFormat = ImageFormat.YUV_420_888
val sizes = characteristics.getVideoSizes(cameraDevice.id, imageFormat)
Expand Down
Loading