Repository navigation
feat(android): in-stream video mirror toggle with preview synchronization - #63
Merged
Merged
Conversation
…flicker on start and flip fallback
Use PreviewView COMPATIBLE so viewfinder scaleX matches the RTP flip, show Mirror On/Off on the button, and stack Flip/Mirror on the land rail. Tighten rotate+flip chroma tests and extract CameraMirror for JVM coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements an in-stream "Mirror" toggle feature in the Android app (
android/) allowing users to horizontally flip their streamed video and synchronized viewfinder preview on demand.Key Highlights
FrameConverter.flipHorizontallyInPlaceuses an in-place two-pointer byte reversal for Y, U, and V planes directly modifying the buffer with 0 heap allocations.CameraX's
PreviewViewautomatically applies a mirror transformation to the front-facing camera for natural selfie orientation, but displays back-facing camera unmirrored:isMirrored = false): PreviewView is normal (scaleX = 1f), stream is normal.isMirrored = true): PreviewView inverted (scaleX = -1f), stream is horizontally flipped.isMirrored = false): Stream has raw upright sensor pixels. To match the unmirrored stream, PreviewView's default selfie mirror must be inverted (scaleX = -1f).isMirrored = true): Stream is horizontally flipped to look like a mirror. PreviewView's default selfie mirror already reflects this (scaleX = 1f).Mirrored state is stored in
SharedPreferencesusing"camera_mirror_" + facing(camera_mirror_back/camera_mirror_front). Switching lenses automatically restores that lens's mirror preference and updates the UI and stream.flipCameraButtonandmirrorButtonare wrapped in a horizontalLinearLayoutwithlayout_width="0dp"andlayout_weight="1"across portrait and landscape layouts, preserving layout rhythm.Added
ic_mirror.xml(24x24dp vector styled consistently withic_flip.xml) and string resourcesbtn_mirror,btn_mirror_on,btn_mirror_off.Verification & Benchmark
FrameConverterTest.kt:assertArrayEqualsagainst original arrays).assertSame).flipHorizontallyInPlace.JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew test: 18/18 test classes passing (154 tests total, 0 failures).JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew assembleDebug: SUCCESS (zero lint or resource errors).JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew check: SUCCESS (lint and checks passing cleanly).