4
4
5
5
import Foundation
6
6
7
+ // MARK: - Direct Upload Options
8
+
7
9
/// Options for the direct upload
8
10
public struct DirectUploadOptions {
9
11
10
12
// MARK: - Transport Options
11
13
12
- /// Options to control the SDK network operations to
13
- /// transport the direct upload input to Mux
14
+ /// Options for tuning network transport of direct upload
15
+ /// chunks to Mux. Using the ``default`` is recommended
16
+ /// for most applications.
14
17
public struct Transport {
15
18
16
- /// At least 8M is recommended
19
+ /// The size of each file chunk in bytes sent by the
20
+ /// SDK during an upload. At least 8MB is recommended.
17
21
public var chunkSizeInBytes : Int
18
22
19
- /// Number of retry attempts per chunk if the
20
- /// associated request fails
23
+ /// Number of retry attempts per chunk if its upload
24
+ /// request is unsuccessful
21
25
public var retryLimitPerChunk : Int
22
26
23
- /// A default set of transport options: 8MB chunk
24
- /// size and chunk request retry limit of 3
27
+ /// Default options for ``DirectUpload`` chunk transport
28
+ /// over the network. The chunk size is 8MB and the
29
+ /// per-chunk retry limit is 3.
25
30
public static var `default` : Transport {
26
31
Transport (
27
32
chunkSizeInBytes: 8 * 1024 * 1024 ,
28
33
retryLimitPerChunk: 3
29
34
)
30
35
}
31
36
32
- /// Initializes options that govern network transport
33
- /// by the SDK
34
- ///
37
+ /// Initializes options for transport of upload chunks
38
+ /// over the network
35
39
/// - Parameters:
36
- /// - chunkSize: the size of each file chunk in
37
- /// bytes the SDK sends when uploading, default
38
- /// value is 8MB
39
- /// - retriesPerChunk: number of retry attempts
40
- /// if the chunk request fails, default value is 3
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
58
+ /// over the network
59
+ /// - Parameters:
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.
41
66
public init (
42
67
chunkSizeInBytes: Int = 8 * 1024 * 1024 ,
43
68
retryLimitPerChunk: Int = 3
@@ -47,12 +72,14 @@ public struct DirectUploadOptions {
47
72
}
48
73
}
49
74
50
- /// Transport options for the direct upload
75
+ /// Network transport options for direct upload chunks
51
76
public var transport : Transport
52
77
53
78
// MARK: - Input Standardization Options
54
79
55
- /// Options controlling direct upload input standardization
80
+ /// Options for adjusments made by ``DirectUpload``
81
+ /// to some inputs to minimize processing time during
82
+ /// ingestion
56
83
public struct InputStandardization {
57
84
58
85
/// If requested the SDK will attempt to detect
@@ -124,8 +151,8 @@ public struct DirectUploadOptions {
124
151
maximumResolution: . default
125
152
)
126
153
127
- // Kept private to an invalid combination of parameters
128
- // being used for initialization
154
+ // Kept private to avoid an invalid combination of
155
+ // parameters being used for initialization
129
156
private init (
130
157
isRequested: Bool ,
131
158
maximumResolution: MaximumResolution
@@ -134,10 +161,8 @@ public struct DirectUploadOptions {
134
161
self . maximumResolution = maximumResolution
135
162
}
136
163
137
- /// Used to initialize ``DirectUploadOptions.InputStandardization``
138
- /// with that enables input standardization with
139
- /// a maximum resolution
140
- ///
164
+ /// Initializes options that request input
165
+ /// standardization with a custom maximum resolution
141
166
/// - Parameters:
142
167
/// - maximumResolution: the maximum resolution
143
168
/// of the standardized input
@@ -186,12 +211,14 @@ public struct DirectUploadOptions {
186
211
187
212
// MARK: Direct Upload Options Initializers
188
213
214
+ /// Initializes options that dictate how the direct upload
215
+ /// is carried out by the SDK
189
216
/// - Parameters:
190
- /// - inputStandardization: options to enable or
191
- /// disable standardizing the format of the direct
192
- /// upload inputs, it is requested by default. To
193
- /// prevent the SDK from making any changes to the
194
- /// 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``.
195
222
/// - transport: options for transporting the
196
223
/// direct upload input to Mux
197
224
/// - eventTracking: event tracking options for the
@@ -206,19 +233,49 @@ public struct DirectUploadOptions {
206
233
self . eventTracking = eventTracking
207
234
}
208
235
236
+ /// Initializes options that dictate how the direct upload
237
+ /// is carried out by the SDK
238
+ /// - Parameters:
239
+ /// - eventTracking: event tracking options for the
240
+ /// direct upload
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
209
266
/// - Parameters:
210
267
/// - eventTracking: event tracking options for the
211
268
/// direct upload
212
- /// - inputStandardization: options to enable or
213
- /// disable standardizing the format of the direct
214
- /// upload inputs, it is requested by default. To
215
- /// prevent the SDK from making any changes to the
216
- /// format of the input use ``DirectUploadOptions.InputStandardization.skipped``
217
- /// - chunkSize: the size of each file chunk in
218
- /// bytes the SDK sends when uploading, default
219
- /// value is 8MB
220
- /// - retriesPerChunk : number of retry attempts
221
- /// if the chunk request fails, default value is 3
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``.
274
+ /// - chunkSizeInBytes: The size of each file chunk
275
+ /// in bytes sent by the SDK during an upload.
276
+ /// Defaults to 8MB.
277
+ /// - retryLimitPerChunk : number of retry attempts
278
+ /// if the chunk request fails. Defaults to 3.
222
279
public init (
223
280
eventTracking: EventTracking = . default,
224
281
inputStandardization: InputStandardization = . default,
@@ -237,6 +294,16 @@ public struct DirectUploadOptions {
237
294
238
295
// MARK: - Extensions
239
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
+
240
307
extension DirectUploadOptions . InputStandardization . MaximumResolution : CustomStringConvertible {
241
308
public var description : String {
242
309
switch self {
0 commit comments