@@ -11,8 +11,9 @@ public struct DirectUploadOptions {
1111
1212 // MARK: - Transport Options
1313
14- /// Options to adjust ``DirectUpload`` chunk transport
15- /// over the network.
14+ /// Options for tuning network transport of direct upload
15+ /// chunks to Mux. Using the ``default`` is recommended
16+ /// for most applications.
1617 public struct Transport {
1718
1819 /// The size of each file chunk in bytes sent by the
@@ -33,15 +34,35 @@ public struct DirectUploadOptions {
3334 )
3435 }
3536
36- /// Initializes options for upload chunk transport
37+ /// Initializes options for transport of upload chunks
38+ /// over the network
39+ /// - Parameters:
40+ /// - chunkSize: the size of each file chunk sent
41+ /// by the SDK during an upload.
42+ /// Defaults to 8MB.
43+ /// - retryLimitPerChunk: number of times a failed
44+ /// chunk request is retried. Default limit is
45+ /// 3 retries.
46+ public init (
47+ chunkSize: Measurement < UnitInformationStorage > = . defaultDirectUploadChunkSize,
48+ retryLimitPerChunk: Int = 3
49+ ) {
50+ self . chunkSizeInBytes = Int (
51+ abs ( chunkSize. converted ( to: . bytes) . value)
52+ . rounded ( . down)
53+ )
54+ self . retryLimitPerChunk = retryLimitPerChunk
55+ }
56+
57+ /// Initializes options for transport of upload chunks
3758 /// over the network
38- ///
3959 /// - Parameters:
40- /// - chunkSizeInBytes: the size of each file chunk in
41- /// bytes the SDK sends when uploading, default
42- /// value is 8MB
43- /// - retryLimitPerChunk: number of retry attempts
44- /// if the chunk request fails, default value is 3
60+ /// - chunkSizeInBytes: the size of each file
61+ /// chunk in bytes the SDK uploads in a single
62+ /// request. Default chunk size is 8MB.
63+ /// - retryLimitPerChunk: number of times a failed
64+ /// chunk request is retried. Default limit is
65+ /// 3 retries.
4566 public init (
4667 chunkSizeInBytes: Int = 8 * 1024 * 1024 ,
4768 retryLimitPerChunk: Int = 3
@@ -51,7 +72,7 @@ public struct DirectUploadOptions {
5172 }
5273 }
5374
54- /// Transport options for the direct upload
75+ /// Network transport options for direct upload chunks
5576 public var transport : Transport
5677
5778 // MARK: - Input Standardization Options
@@ -190,12 +211,14 @@ public struct DirectUploadOptions {
190211
191212 // MARK: Direct Upload Options Initializers
192213
214+ /// Initializes options that dictate how the direct upload
215+ /// is carried out by the SDK
193216 /// - Parameters:
194- /// - inputStandardization: options to enable or
195- /// disable standardizing the format of the direct
196- /// upload inputs, it is requested by default. To
197- /// prevent the SDK from making any changes to the
198- /// format of the input use ``DirectUploadOptions.InputStandardization.skipped``
217+ /// - inputStandardization: options related to input
218+ /// standardization. Input standardization is requested
219+ /// by default.
220+ /// To skip input standardization pass in
221+ /// ``DirectUploadOptions.InputStandardization.skipped``.
199222 /// - transport: options for transporting the
200223 /// direct upload input to Mux
201224 /// - eventTracking: event tracking options for the
@@ -210,26 +233,49 @@ public struct DirectUploadOptions {
210233 self . eventTracking = eventTracking
211234 }
212235
236+ /// Initializes options that dictate how the direct upload
237+ /// is carried out by the SDK
213238 /// - Parameters:
214239 /// - eventTracking: event tracking options for the
215240 /// direct upload
216- /// - inputStandardization: options to enable or
217- /// disable standardizing the format of the direct
218- /// upload inputs, it is requested by default. To
219- /// prevent the SDK from making any changes to the
241+ /// - inputStandardization: options related to input
242+ /// standardization. Input standardization is requested
243+ /// by default.
244+ /// To skip input standardization pass in
245+ /// ``DirectUploadOptions.InputStandardization.skipped``.
246+ /// - chunkSize: The size of each file chunk sent by
247+ /// the SDK during an upload. Defaults to 8MB.
248+ /// - retryLimitPerChunk: number of retry attempts
249+ /// if the chunk request fails. Defaults to 3.
250+ public init (
251+ eventTracking: EventTracking = . default,
252+ inputStandardization: InputStandardization = . default,
253+ chunkSize: Measurement < UnitInformationStorage > = . defaultDirectUploadChunkSize,
254+ retryLimitPerChunk: Int = 3
255+ ) {
256+ self . eventTracking = eventTracking
257+ self . inputStandardization = inputStandardization
258+ self . transport = Transport (
259+ chunkSize: chunkSize,
260+ retryLimitPerChunk: retryLimitPerChunk
261+ )
262+ }
263+
264+ /// Initializes options that dictate how the direct upload
265+ /// is carried out by the SDK
220266 /// - Parameters:
221267 /// - eventTracking: event tracking options for the
222268 /// direct upload
223- /// - inputStandardization: options to enable or
224- /// disable standardizing the format of the direct
225- /// upload inputs. True by default.
226- /// To prevent the SDK from making any changes to the
227- /// format of the input use ``DirectUploadOptions.InputStandardization.skipped``
269+ /// - inputStandardization: options related to input
270+ /// standardization. Input standardization is requested
271+ /// by default.
272+ /// To skip input standardization pass in
273+ /// ``DirectUploadOptions.InputStandardization.skipped``.
228274 /// - chunkSizeInBytes: The size of each file chunk
229275 /// in bytes sent by the SDK during an upload.
230276 /// Defaults to 8MB.
231277 /// - retryLimitPerChunk: number of retry attempts
232- /// if the chunk request fails, default value is 3
278+ /// if the chunk request fails. Defaults to 3.
233279 public init (
234280 eventTracking: EventTracking = . default,
235281 inputStandardization: InputStandardization = . default,
@@ -248,6 +294,16 @@ public struct DirectUploadOptions {
248294
249295// MARK: - Extensions
250296
297+ extension Measurement where UnitType == UnitInformationStorage {
298+ /// Default direct upload chunk size
299+ public static var defaultDirectUploadChunkSize : Self {
300+ Measurement (
301+ value: 8 ,
302+ unit: . megabytes
303+ )
304+ }
305+ }
306+
251307extension DirectUploadOptions . InputStandardization . MaximumResolution : CustomStringConvertible {
252308 public var description : String {
253309 switch self {
0 commit comments