@@ -11,8 +11,9 @@ public struct DirectUploadOptions {
11
11
12
12
// MARK: - Transport Options
13
13
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.
16
17
public struct Transport {
17
18
18
19
/// The size of each file chunk in bytes sent by the
@@ -33,15 +34,35 @@ public struct DirectUploadOptions {
33
34
)
34
35
}
35
36
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
37
58
/// over the network
38
- ///
39
59
/// - 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.
45
66
public init (
46
67
chunkSizeInBytes: Int = 8 * 1024 * 1024 ,
47
68
retryLimitPerChunk: Int = 3
@@ -51,7 +72,7 @@ public struct DirectUploadOptions {
51
72
}
52
73
}
53
74
54
- /// Transport options for the direct upload
75
+ /// Network transport options for direct upload chunks
55
76
public var transport : Transport
56
77
57
78
// MARK: - Input Standardization Options
@@ -190,12 +211,14 @@ public struct DirectUploadOptions {
190
211
191
212
// MARK: Direct Upload Options Initializers
192
213
214
+ /// Initializes options that dictate how the direct upload
215
+ /// is carried out by the SDK
193
216
/// - 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``.
199
222
/// - transport: options for transporting the
200
223
/// direct upload input to Mux
201
224
/// - eventTracking: event tracking options for the
@@ -210,26 +233,49 @@ public struct DirectUploadOptions {
210
233
self . eventTracking = eventTracking
211
234
}
212
235
236
+ /// Initializes options that dictate how the direct upload
237
+ /// is carried out by the SDK
213
238
/// - Parameters:
214
239
/// - eventTracking: event tracking options for the
215
240
/// 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
220
266
/// - Parameters:
221
267
/// - eventTracking: event tracking options for the
222
268
/// 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``.
228
274
/// - chunkSizeInBytes: The size of each file chunk
229
275
/// in bytes sent by the SDK during an upload.
230
276
/// Defaults to 8MB.
231
277
/// - retryLimitPerChunk: number of retry attempts
232
- /// if the chunk request fails, default value is 3
278
+ /// if the chunk request fails. Defaults to 3.
233
279
public init (
234
280
eventTracking: EventTracking = . default,
235
281
inputStandardization: InputStandardization = . default,
@@ -248,6 +294,16 @@ public struct DirectUploadOptions {
248
294
249
295
// MARK: - Extensions
250
296
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
+
251
307
extension DirectUploadOptions . InputStandardization . MaximumResolution : CustomStringConvertible {
252
308
public var description : String {
253
309
switch self {
0 commit comments