OpenTimelineIO-Swift-Bindings icon indicating copy to clipboard operation
OpenTimelineIO-Swift-Bindings copied to clipboard

Expose available_image_bounds on MediaReference / ExternalReference as CGRect?

Open vade opened this issue 1 year ago • 3 comments

Working on an AVFoundation interoperability implementation of OTIO and noticing that Media Reference does not expose its bounds in any way.

While not strictly necessary, its helpful to have access when trying to read an OTIO timeline and do useful stuff with it

vade avatar Feb 10 '24 02:02 vade

How to expose these is a really interesting question. We’ve decided to align on Imath for spatial primitives, but we also want our bindings to “feel right” for their context.

Given that CGRect is only available in CoreGraphics (not the cross-platform Foundation), I’d be tempted to try and bind Box2d more directly and then include CGRect conversions in some optional Apple platform aware extensions. This has the downside though that the user needs to manually convert when getting and setting.

One other option is that we could make some custom spatial type protocols that match the underlying Imath types and use extensions to define protocol adherence for types like CGRect. This helps with pain in setting, but getting still requires an unwrap to get to the Apple types.

reinecke avatar Feb 10 '24 03:02 reinecke

Oh, just realized, we should move this issue to the Swift-Bindings repo.

reinecke avatar Feb 10 '24 03:02 reinecke

Hey @reinecke - Ah this tracks. Maybe theres a 'natural' exposing of the box2D binding, but as you said, an Apple Centric solution would expose a CGRect variant of the box2D binding so clients wouldn't need to worry too much?

vade avatar Feb 10 '24 03:02 vade

merged

vade avatar May 12 '25 18:05 vade