Camera

The library provides a Kotlin Multiplatform wrapper for the native Aurora OS camera. It supports camera preview (via Compose), photo capture, video recording, and QR code scanning.

Dependency libraries

  • streamcamera
  • libpulse
  • libpulse-simple

Features

  • Camera control: List available cameras, start, stop, switch, and manage flash/torch.
  • Preview: Render video stream in Compose UI using Canvas or the ready-to-use CameraViewfinder.
  • Photo capture: Take photos (JPEG/PNG) into a file or get raw bytes.
  • Video recording: Record MP4 with hardware H.264 encoding, pause/resume, and optional audio.
  • QR scanning: Scan QR codes on the fly with results delivered via SharedFlow.
  • Orientation: Automatically rotate frames based on device and camera mount angles.

Example

// 1. Start camera
val cameras = AuroraCamera.getInfoList()
AuroraCamera.start(cameras.first().id, CaptureSize.High)

// 2. Show preview in Compose UI
CameraViewfinder(modifier = Modifier.fillMaxSize())

// 3. Take photo
val photoPath = AuroraCamera.takePhotoPath("/home/defaultuser/Pictures")
AuroraCamera.takePhoto(photoPath)

// 4. Record video (with audio)
val videoPath = AuroraCamera.takeVideoPath("/home/defaultuser/Videos")
AuroraCamera.startVideoRecording(videoPath, enableAudio = true)
// ... pauseVideoRecording() / resumeVideoRecording() ...
AuroraCamera.stopVideoRecording()

// 5. Scan QR codes (results arrive in AuroraCamera.qrResults flow)
AuroraCamera.scanQrStart()

// 6. Cleanup
AuroraCamera.stop()