@@ -11,7 +11,14 @@ import Foundation
1111public 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
0 commit comments