Skip to content

fix(android): let VideoScreenObject orientation be set from Dart - #177

Open
samerzmd wants to merge 1 commit into
HaishinKit:mainfrom
samerzmd:fix/android-video-screen-object-orientation
Open

samerzmd wants to merge 1 commit into
HaishinKit:mainfrom
samerzmd:fix/android-video-screen-object-orientation

Conversation

@samerzmd

Copy link
Copy Markdown

Problem

VideoScreenObject already supports imageOrientation, deviceOrientation
and rotatesWithContent in HaishinKit.kt, but none of them are reachable from
Dart: the Dart object serialises only track, and the native elements setter
reads only track (VideoScreenObject$Keys contains nothing else).

The consequence is that a capture keeps whatever rotation it had when the video
source was attached. A device held in landscape renders rotated by 90 degrees —
in the preview texture and in the published stream — and there is no way to
correct it from Dart. Re-attaching the video source does not help, and neither
does rotating the display.

Change

  • Dart VideoScreenObject gains imageOrientation, deviceOrientation and
    rotatesWithContent, and serialises them into elements.
  • ScreenHandler applies those elements to the native object.

Two files, no API removed, no behaviour change for callers that don't set the
new properties (deviceOrientation defaults to 0, rotatesWithContent to true).

Verification

Galaxy S22 Ultra held in landscape, printed text in frame as the reference
(furniture edges are ambiguous under a 90° rotation): the label reads
vertically before the change and horizontally after.

Note for maintainers

Consumers currently need an explicit VideoScreenObject(track: 0) for this to
apply, since track 0 renders through the Screen itself where there's no handle
to reach. If you'd prefer to plumb orientation at that level instead, that would
be the better fix and I'm happy to drop this.

VideoScreenObject in HaishinKit.kt already exposes imageOrientation,
deviceOrientation and rotatesWithContent, but the Dart object serialises
only `track` and the native `elements` setter reads only `track`, so none
of them are reachable from Dart.

The effect is that a capture keeps whatever rotation it had when the video
source was attached. A device held in landscape then renders rotated by 90
degrees, both in the preview texture and in the published stream, with no
way to correct it from the Dart side. Re-attaching the source does not
help, and neither does rotating the display.

Serialise the three properties on the Dart VideoScreenObject and apply
them to the native object in ScreenHandler.

Verified on a Galaxy S22 Ultra held in landscape, using printed text in
frame as the reference: the label reads vertically before the change and
horizontally after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant