|
1 | 1 | ## CascableCoreSwift |
2 | 2 |
|
3 | | -CascableCoreSwift is a Swift package that provides better, more "Swift-y" APIs for [CascableCore](https://github.com/cascable/cascablecore-distribution/) — an SDK for working with over 200 models of WiFi-enabled DSLR and mirrorless cameras. This package is additive in that it adds to the existing CascableCore APIs rather than replacing it. |
| 3 | +CascableCoreSwift is a Swift package that provides better, more "Swift-y" APIs for [CascableCore](https://github.com/cascable/cascablecore-distribution/) — an SDK for working with over 200 models of DSLR and mirrorless cameras. This package is additive in that it adds to the existing CascableCore APIs rather than replacing it. |
4 | 4 |
|
5 | 5 | - For more information on the CascableCore product, including getting a trial license, see the [Cascable Developer Portal](https://developer.cascable.se/). |
6 | 6 |
|
7 | 7 | - The best starting point for working with the SDK is by seeing CascableCore in action by checking out the [CascableCore Demo Projects](https://github.com/Cascable/cascablecore-demo) repository. You'll need a trial license for it to do anything useful! |
8 | 8 |
|
9 | 9 | - Next, our [Getting Started With CascableCore](https://github.com/Cascable/cascablecore-demo/blob/master/Getting%20Started%20With%20CascableCore.md) document contains discussion about the CascableCore APIs and concepts in the order in which you're likely to encounter them. These APIs and concepts are equally important for both Objective-C and Swift developers. |
10 | 10 |
|
| 11 | +### Contents |
| 12 | + |
| 13 | +- [Strongly-Typed Property API](#strongly-typed-property-api) |
| 14 | +- [Combine Publishers](#combine-publishers) |
| 15 | + - [Basic Usage](#basic-usage) |
| 16 | + - [Live View](#live-view) |
| 17 | +- [Metal-Backed Live View Rendering View Controller](#metal-backed-live-view-rendering-view-controller) |
| 18 | +- [Manual Camera Discovery](#strongly-typed-property-api) |
| 19 | + |
11 | 20 |
|
12 | 21 | ### Strongly-Typed Property API |
13 | 22 |
|
@@ -141,6 +150,33 @@ camera.liveViewPublisher(options: [.skipImageDecoding: true]) |
141 | 150 | ``` |
142 | 151 |
|
143 | 152 |
|
| 153 | +### Metal-Backed Live View Rendering View Controller |
| 154 | + |
| 155 | +Some cameras deliver high-framerate, high-quality live view streams that're a challenge to handle efficiently. For our app [Cascable Studio](https://cascable.se/studio/) we developed a rendering pipeline that uses Metal to keep live view rendering entirely on the GPU, significantly reducing resource usage and increasing performance compared to using solutions like `UIImageView`. |
| 156 | + |
| 157 | +With CascableCore 16, we're excited to be able to open-source this for everyone to use! |
| 158 | + |
| 159 | +Included is an easy-to-use Metal-backed `UIViewController` that you can use to display live view in your app. Simply create the view controller and place it into your UI as you would any other, then connect it to a camera's live view feed: |
| 160 | + |
| 161 | +```swift |
| 162 | +// Make sure you pass .skipImageDecoding since CascableCore's internal |
| 163 | +// decoding is CPU-based and resource-intensive. |
| 164 | + |
| 165 | +camera.liveViewPublisher(options: [.skipImageDecoding: true]) |
| 166 | + .receive(on: DispatchQueue.main) |
| 167 | + .sinkWithReadyHandler { completion in |
| 168 | + print("Live view ended with completion reason: \(completion)" ) |
| 169 | + } receiveValue: { frame, readyForNextFrame in |
| 170 | + liveViewRendererView.render(frame: frame, completionHandler: { orientation, size in |
| 171 | + // Sync the rest of your UI with the orientation etc. |
| 172 | + readyForNextFrame() |
| 173 | + }) |
| 174 | + } |
| 175 | +``` |
| 176 | + |
| 177 | +The underlying Metal rendering pipeline works on all platforms, while the view controller is currently only for UIKit-based platforms (i.e., everything except for AppKit-based macOS apps, including Mac Catalyst). If you have need for an AppKit view controller, please get in touch. |
| 178 | + |
| 179 | + |
144 | 180 | ### Manual Camera Discovery |
145 | 181 |
|
146 | 182 | This package adds a nicer API for manual camera discovery, allowing quick creation of descriptors and a `Result<Camera, Error>` |
|
0 commit comments