Skip to content

Commit 2a3556e

Browse files
committed
Adjustments
Initializer API adjustments Place extension methods into dedicated directories Polish inline API documentation
1 parent f75888f commit 2a3556e

File tree

5 files changed

+94
-76
lines changed

5 files changed

+94
-76
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// MuxUpload+AVFoundation.swift
3+
//
4+
5+
import AVFoundation
6+
import Foundation
7+
8+
extension MuxUpload {
9+
10+
/// Initializes a MuxUpload from an ``AVAsset``
11+
///
12+
/// - Parameters:
13+
/// - uploadURL: the URL of the direct upload that's
14+
/// included in the create a new direct upload URL
15+
/// [response](https://docs.mux.com/api-reference#video/operation/create-direct-upload)
16+
/// - inputAsset: the asset containing audiovisual
17+
/// media to be used as the input for the direct
18+
/// upload
19+
/// - options: options used to control the direct
20+
/// upload of the input to Mux
21+
public convenience init(
22+
uploadURL: URL,
23+
inputAsset: AVAsset,
24+
options: UploadOptions
25+
) {
26+
self.init(
27+
input: UploadInput(asset: inputAsset),
28+
options: options,
29+
uploadManager: .shared
30+
)
31+
}
32+
33+
}

Sources/MuxUploadSDK/PublicAPI/MuxUpload+AVFoundation.swift

Lines changed: 0 additions & 22 deletions
This file was deleted.

Sources/MuxUploadSDK/PublicAPI/MuxUpload.swift

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ import Foundation
1111
public typealias UploadResult = Result<MuxUpload.Success, MuxUpload.UploadError>
1212

1313
/**
14-
Uploads a video file to a previously-created Direct Upload. Create instances of this object using ``Builder``
14+
Uploads a media asset to Mux using a previously-created
15+
Direct Upload signed URL.
16+
17+
Before initializing ``MuxUpload``, create a
18+
[direct upload](https://docs.mux.com/api-reference#video/tag/direct-uploads)
19+
using the Mux API first. The signed URL you'll get back
20+
after creating a direct upload is needed to get the
21+
``MuxUpload`` ready to deliver your media asset to Mux.
1522

1623
TODO: usage here
1724
*/
@@ -34,7 +41,7 @@ public final class MuxUpload: Hashable, Equatable {
3441
input.uploadInfo
3542
}
3643

37-
/// Indicates the status of the upload as it goes
44+
/// Indicates the status of the upload input as it goes
3845
/// through its lifecycle
3946
public enum InputStatus {
4047
/// Upload initialized and not yet started
@@ -59,6 +66,8 @@ public final class MuxUpload: Hashable, Equatable {
5966
case uploadFailed(AVAsset, Status, UploadResult)
6067
}
6168

69+
/// Current status of the upload input as it goes through
70+
/// its lifecycle
6271
public var inputStatus: InputStatus {
6372
switch input.status {
6473
case .ready(let sourceAsset):
@@ -151,9 +160,12 @@ public final class MuxUpload: Hashable, Equatable {
151160

152161
}
153162

154-
/// Initializes a MuxUpload
163+
/// Initializes a MuxUpload from a local file URL
164+
///
155165
/// - Parameters:
156-
/// - uploadURL: the URL of the direct upload
166+
/// - uploadURL: the URL of the direct upload that's
167+
/// included in the create a new direct upload URL
168+
/// [response](https://docs.mux.com/api-reference#video/operation/create-direct-upload)
157169
/// - videoFileURL: the file:// URL of the upload
158170
/// input
159171
/// - chunkSize: the size of chunks when uploading,
@@ -162,7 +174,8 @@ public final class MuxUpload: Hashable, Equatable {
162174
/// a failed chunk upload request
163175
/// - inputStandardization: enable or disable input
164176
/// standardization by the SDK locally
165-
/// - optOutOfEventTracking: opt out of event tracking
177+
/// - eventTracking: options to opt out of event
178+
/// tracking
166179
public convenience init(
167180
uploadURL: URL,
168181
videoFileURL: URL,
@@ -171,40 +184,43 @@ public final class MuxUpload: Hashable, Equatable {
171184
inputStandardization: UploadOptions.InputStandardization = .init(
172185
targetResolution: UploadOptions.InputStandardization.ResolutionPreset.default
173186
),
174-
optOutOfEventTracking: Bool = false
187+
eventTracking: UploadOptions.EventTracking = UploadOptions.EventTracking(optedOut: false)
175188
) {
176-
let uploadSettings = UploadOptions(
177-
inputStandardization: inputStandardization,
178-
transport: UploadOptions.Transport(
179-
chunkSize: chunkSize,
180-
retriesPerChunk: retriesPerChunk
181-
),
182-
eventTracking: UploadOptions.EventTracking(
183-
optedOut: optOutOfEventTracking
184-
)
185-
)
186-
187-
let inputSourceAsset = AVAsset(url: videoFileURL)
188-
189-
let input = UploadInput(status: .ready(inputSourceAsset))
190-
191189
self.init(
192-
input: input,
193-
options: uploadSettings,
190+
input: UploadInput(asset: AVAsset(url: videoFileURL)),
191+
options: UploadOptions(
192+
inputStandardization: inputStandardization,
193+
transport: UploadOptions.Transport(
194+
chunkSize: chunkSize,
195+
retriesPerChunk: retriesPerChunk
196+
),
197+
eventTracking: eventTracking
198+
),
194199
uploadManager: .shared
195200
)
196201
}
197202

203+
/// Initializes a MuxUpload from a local file URL
204+
///
205+
/// - Parameters:
206+
/// - uploadURL: the URL of the direct upload that's
207+
/// included in the create a new direct upload URL
208+
/// [response](https://docs.mux.com/api-reference#video/operation/create-direct-upload)
209+
/// - inputFileURL: the file:// URL of the upload
210+
/// input
211+
/// - options: options used to control the direct
212+
/// upload of the input to Mux
198213
public convenience init(
199214
uploadURL: URL,
200215
inputFileURL: URL,
201216
options: UploadOptions
202217
) {
203-
let inputSourceAsset = AVAsset(url: inputFileURL)
204-
let input = UploadInput(status: .ready(inputSourceAsset))
205-
206218
self.init(
207-
input: input,
219+
input: UploadInput(
220+
asset: AVAsset(
221+
url: inputFileURL
222+
)
223+
),
208224
manage: true,
209225
options: options,
210226
uploadManager: .shared

Sources/MuxUploadSDK/PublicAPI/PHAsset+MuxUpload.swift renamed to Sources/MuxUploadSDK/PublicAPI/PhotosKit+MuxUpload/PHAsset+MuxUpload.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,32 @@ import Photos
77

88
extension PHAsset {
99

10-
/// Asynchronously initializes ``MuxUpload`` from a
11-
/// requesting for an ``AVAsset`` containing the input.
12-
/// A ``MuxUpload`` can only be initialized from a ``PHAsset``
13-
/// whose ``PHAsset.mediaType`` is
14-
/// ``PHAssetMediaType.video``.
10+
/// Convenience method that requests an ``AVAsset``
11+
/// containing audiovisual media associated with the callee
12+
/// ``PHAsset``. If the request succeeds ``MuxUpload``
13+
/// is initialized with the received ``AVAsset``
1514
///
15+
/// A ``MuxUpload`` can only be initialized from a ``PHAsset``
16+
/// whose ``PHAsset.mediaType`` is ``PHAssetMediaType.video``
1617
///
1718
/// - Parameters:
18-
/// - imageManager: Photos image manager
19+
/// - imageManager: an object that facilitates retrieval
20+
/// of asset data associated with the callee
1921
/// - requestOptions: options used when requesting
20-
/// an ``AVAsset`` from the `imageManager`
21-
/// - uploadURL: the direct upload URL
22-
/// - options: the upload settings
23-
/// - completion: receives the initialized MuxUpload
24-
/// when it is ready, receives nil if initialization
25-
/// failed or if the ``PHAsset`` is not a video.
22+
/// an ``AVAsset`` from a ``PHImageManager`
23+
/// - options: options used to control the direct
24+
/// upload of the input to Mux
25+
/// - uploadURL: the URL of the direct upload that's
26+
/// included in the create a new direct upload URL
27+
/// [response](https://docs.mux.com/api-reference#video/operation/create-direct-upload)
28+
/// - completion: called when initialized ``MuxUpload``
29+
/// is ready, receives nil if the asset data request
30+
/// failed or if the ``PHAsset`` callee is not a video
2631
func prepareForDirectUpload(
2732
from imageManager: PHImageManager = .default(),
2833
requestOptions: PHVideoRequestOptions,
29-
uploadURL: URL,
3034
options: UploadOptions,
35+
uploadURL: URL,
3136
completion: @escaping (MuxUpload?) -> ()
3237
) {
3338
if mediaType != .video {

Sources/MuxUploadSDK/PublicAPI/StandardizationResult.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)