OpenTimelineIO / OpenTimelineIO-Swift-Bindings

Swift bindings for the OpenTimelineIO Library (http://opentimeline.io)
http://opentimeline.io
Apache License 2.0
18 stars 11 forks source link

Expose available_image_bounds on MediaReference / ExternalReference as CGRect? #51

Open vade opened 9 months ago

vade commented 9 months ago

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

reinecke commented 9 months ago

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 commented 9 months ago

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

vade commented 9 months ago

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?