Skip to content

Commit 4b1fe41

Browse files
authored
Releases/v0.5.0 (#85)
* Add an overload initializer for UploadOptions (#81) * Bump version to v0.5.0 * Remove prefix use in public APIs and respell Upload as DirectUpload (#84)
1 parent 7e42c2d commit 4b1fe41

24 files changed

+296
-278
lines changed

Example/SwiftUploadSDKExample/SwiftUploadSDKExample/Model/ThumbnailModel.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class ThumbnailModel: ObservableObject {
4848
}
4949

5050
private let asset: AVAsset
51-
private let upload: MuxUpload
51+
private let upload: DirectUpload
5252
private var thumbnailGenerator: AVAssetImageGenerator?
5353

5454
@Published var thumbnail: CGImage?
55-
@Published var uploadProgress: MuxUpload.TransportStatus?
55+
@Published var uploadProgress: DirectUpload.TransportStatus?
5656

57-
init(asset: AVAsset, upload: MuxUpload) {
57+
init(asset: AVAsset, upload: DirectUpload) {
5858
self.asset = asset
5959
self.upload = upload
6060

Example/SwiftUploadSDKExample/SwiftUploadSDKExample/Model/UploadCreationModel.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class UploadCreationModel : ObservableObject {
4141
}
4242
}
4343

44-
@discardableResult func startUpload(preparedMedia: PreparedUpload, forceRestart: Bool) -> MuxUpload {
45-
let upload = MuxUpload(
44+
@discardableResult func startUpload(preparedMedia: PreparedUpload, forceRestart: Bool) -> DirectUpload {
45+
let upload = DirectUpload(
4646
uploadURL: preparedMedia.remoteURL,
4747
videoFileURL: preparedMedia.localVideoFile
4848
)

Example/SwiftUploadSDKExample/SwiftUploadSDKExample/Model/UploadListModel.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import MuxUploadSDK
1212
class UploadListModel : ObservableObject {
1313

1414
init() {
15-
UploadManager.shared.addUploadsUpdatedDelegate(
15+
DirectUploadManager.shared.addDelegate(
1616
Delegate(
1717
handler: { uploads in
1818

@@ -40,17 +40,17 @@ class UploadListModel : ObservableObject {
4040
)
4141
}
4242

43-
@Published var lastKnownUploads: [MuxUpload] = Array()
43+
@Published var lastKnownUploads: [DirectUpload] = Array()
4444
}
4545

46-
fileprivate class Delegate: UploadsUpdatedDelegate {
47-
let handler: ([MuxUpload]) -> Void
48-
49-
func uploadListUpdated(with list: [MuxUpload]) {
50-
handler(list)
46+
fileprivate class Delegate: DirectUploadManagerDelegate {
47+
let handler: ([DirectUpload]) -> Void
48+
49+
func didUpdate(managedDirectUploads: [DirectUpload]) {
50+
handler(managedDirectUploads)
5151
}
5252

53-
init(handler: @escaping ([MuxUpload]) -> Void) {
53+
init(handler: @escaping ([DirectUpload]) -> Void) {
5454
self.handler = handler
5555
}
5656
}

Example/SwiftUploadSDKExample/SwiftUploadSDKExample/Screens/UploadListView.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct UploadListScreen: View {
2323
}
2424
}
2525

26-
extension MuxUpload {
26+
extension DirectUpload {
2727
var objectIdentifier: ObjectIdentifier {
2828
ObjectIdentifier(self)
2929
}
@@ -51,7 +51,7 @@ fileprivate struct ListContainerView: View {
5151
fileprivate struct ListItem: View {
5252

5353
@StateObject var thumbnailModel: ThumbnailModel
54-
let upload: MuxUpload
54+
let upload: DirectUpload
5555

5656
var body: some View {
5757
ZStack(alignment: .bottom) {
@@ -130,7 +130,7 @@ fileprivate struct ListItem: View {
130130
}
131131
}
132132

133-
private func statusLine(status: MuxUpload.TransportStatus?) -> String {
133+
private func statusLine(status: DirectUpload.TransportStatus?) -> String {
134134
guard let status = status, let progress = status.progress, let startTime = status.startTime, startTime > 0 else {
135135
return "missing status"
136136
}
@@ -152,14 +152,14 @@ fileprivate struct ListItem: View {
152152
return "\(formattedMBytes) MB in \(formattedTime)s (\(formattedDataRate) KB/s)"
153153
}
154154

155-
private func elapsedBytesOfTotal(status: MuxUpload.TransportStatus) -> String {
155+
private func elapsedBytesOfTotal(status: DirectUpload.TransportStatus) -> String {
156156
guard let progress = status.progress else {
157157
return "unknown"
158158
}
159159
return "\(progress.completedUnitCount / 1000)KB"
160160
}
161161

162-
init(upload: MuxUpload) {
162+
init(upload: DirectUpload) {
163163
self.upload = upload
164164
_thumbnailModel = StateObject(
165165
wrappedValue: {
@@ -214,7 +214,7 @@ struct UploadListItem_Previews: PreviewProvider {
214214
static var previews: some View {
215215
ZStack {
216216
WindowBackground
217-
let upload = MuxUpload(uploadURL: URL(string: "file:///")!, videoFileURL: URL(string: "file:///")!)
217+
let upload = DirectUpload(uploadURL: URL(string: "file:///")!, videoFileURL: URL(string: "file:///")!)
218218
ListItem(upload: upload)
219219
}
220220
}

Example/SwiftUploadSDKExample/SwiftUploadSDKExample/Widgets/UploadProgressView.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ struct UploadProgressView: View {
4040
}
4141
}
4242

43-
private func uploadStatus(uploadState: AppUploadState) -> MuxUpload.Status? {
43+
private func uploadStatus(uploadState: AppUploadState) -> DirectUpload.Status? {
4444
switch uploadState {
4545
case .done(let success): return success.finalState
4646
case .uploading(let status): return status
4747
default: return nil
4848
}
4949
}
5050

51-
private func dataRateTxt(status: MuxUpload.Status?) -> String {
51+
private func dataRateTxt(status: DirectUpload.Status?) -> String {
5252
guard let status = status, let progress = status.progress else {
5353
return ""
5454
}
@@ -69,7 +69,7 @@ struct UploadProgressView: View {
6969
}
7070
}
7171

72-
private func elapsedBytesOfTotal(status: MuxUpload.Status) -> String {
72+
private func elapsedBytesOfTotal(status: DirectUpload.Status) -> String {
7373
guard let progress = status.progress else {
7474
return "unknown"
7575
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import MuxUploadSDK
3838
let directUploadURL: URL = /* Fetch the direct upload URL created before */
3939
let videoInputURL: URL = /* File URL to your video file. See Test App for how to retrieve a video from PhotosKit */
4040

41-
let upload = MuxUpload(
41+
let upload = DirectUpload(
4242
uploadURL: directUploadURL,
4343
inputFileURL: videoInputURL,
4444
)

Sources/MuxUploadSDK/InputStandardization/UploadInputStandardizationWorker.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class UploadInputStandardizationWorker {
4343

4444
func standardize(
4545
sourceAsset: AVAsset,
46-
maximumResolution: UploadOptions.InputStandardization.MaximumResolution,
46+
maximumResolution: DirectUploadOptions.InputStandardization.MaximumResolution,
4747
outputURL: URL,
4848
completion: @escaping (AVAsset, AVAsset?, Error?) -> ()
4949
) {

Sources/MuxUploadSDK/InputStandardization/UploadInputStandardizer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class UploadInputStandardizer {
1111
func standardize(
1212
id: String,
1313
sourceAsset: AVAsset,
14-
maximumResolution: UploadOptions.InputStandardization.MaximumResolution,
14+
maximumResolution: DirectUploadOptions.InputStandardization.MaximumResolution,
1515
outputURL: URL,
1616
completion: @escaping (AVAsset, AVAsset?, Error?) -> ()
1717
) {

Sources/MuxUploadSDK/InternalUtilities/ChunkedFile.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ChunkedFile {
3939
/// Reads the next chunk from the file, advancing the file for the next read
4040
/// This method does synchronous I/O, so call it in the background
4141
func readNextChunk() -> Result<FileChunk, Error> {
42-
MuxUploadSDK.logger?.info("--readNextChunk(): called")
42+
SDKLogger.logger?.info("--readNextChunk(): called")
4343
do {
4444
guard fileHandle != nil else {
4545
return Result.failure(ChunkedFileError.invalidState("readNextChunk() called but the file was not open"))
@@ -62,7 +62,7 @@ class ChunkedFile {
6262
fileHandle: fileHandle,
6363
fileURL: fileURL
6464
)
65-
MuxUploadSDK.logger?.info("Opened file with len \(String(describing: fileSize)) at path \(fileURL.path)")
65+
SDKLogger.logger?.info("Opened file with len \(String(describing: fileSize)) at path \(fileURL.path)")
6666
} catch {
6767
throw ChunkedFileError.fileHandle(error)
6868
}
@@ -75,7 +75,7 @@ class ChunkedFile {
7575
do {
7676
try fileHandle?.close()
7777
} catch {
78-
MuxUploadSDK.logger?.warning("Swallowed error closing file: \(error.localizedDescription)")
78+
SDKLogger.logger?.warning("Swallowed error closing file: \(error.localizedDescription)")
7979
}
8080
state = nil
8181
}
@@ -87,7 +87,7 @@ class ChunkedFile {
8787
}
8888

8989
private func doReadNextChunk() throws -> FileChunk {
90-
MuxUploadSDK.logger?.info("--doReadNextChunk")
90+
SDKLogger.logger?.info("--doReadNextChunk")
9191
guard let fileHandle = fileHandle, let fileURL = fileURL else {
9292
throw ChunkedFileError.invalidState("doReadNextChunk called without file handle. Did you call open()?")
9393
}

Sources/MuxUploadSDK/InternalUtilities/Reporting/Reporter.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extension Reporter {
9292
func reportUploadSuccess(
9393
inputDuration: Double,
9494
inputSize: UInt64,
95-
options: UploadOptions,
95+
options: DirectUploadOptions,
9696
uploadEndTime: Date,
9797
uploadStartTime: Date,
9898
uploadURL: URL
@@ -133,7 +133,7 @@ extension Reporter {
133133
errorDescription: String,
134134
inputDuration: Double,
135135
inputSize: UInt64,
136-
options: UploadOptions,
136+
options: DirectUploadOptions,
137137
uploadEndTime: Date,
138138
uploadStartTime: Date,
139139
uploadURL: URL
@@ -173,7 +173,7 @@ extension Reporter {
173173
func reportUploadInputStandardizationSuccess(
174174
inputDuration: Double,
175175
inputSize: UInt64,
176-
options: UploadOptions,
176+
options: DirectUploadOptions,
177177
nonStandardInputReasons: [UploadInputFormatInspectionResult.NonstandardInputReason],
178178
standardizationEndTime: Date,
179179
standardizationStartTime: Date,
@@ -216,7 +216,7 @@ extension Reporter {
216216
inputDuration: Double,
217217
inputSize: UInt64,
218218
nonStandardInputReasons: [UploadInputFormatInspectionResult.NonstandardInputReason],
219-
options: UploadOptions,
219+
options: DirectUploadOptions,
220220
standardizationEndTime: Date,
221221
standardizationStartTime: Date,
222222
uploadCanceled: Bool,

Sources/MuxUploadSDK/InternalUtilities/UploadInput.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct UploadInput {
2121
)
2222
case standardizationFailed(AVAsset, UploadInfo)
2323
case awaitingUploadConfirmation(UploadInfo)
24-
case uploadInProgress(UploadInfo, MuxUpload.TransportStatus)
25-
case uploadPaused(UploadInfo, MuxUpload.TransportStatus)
26-
case uploadSucceeded(UploadInfo, MuxUpload.Success)
27-
case uploadFailed(UploadInfo, MuxUpload.UploadError)
24+
case uploadInProgress(UploadInfo, DirectUpload.TransportStatus)
25+
case uploadPaused(UploadInfo, DirectUpload.TransportStatus)
26+
case uploadSucceeded(UploadInfo, DirectUpload.SuccessDetails)
27+
case uploadFailed(UploadInfo, DirectUploadError)
2828
}
2929

3030
var status: Status
@@ -83,7 +83,7 @@ struct UploadInput {
8383
}
8484
}
8585

86-
var transportStatus: MuxUpload.TransportStatus? {
86+
var transportStatus: DirectUpload.TransportStatus? {
8787
switch status {
8888
case .ready:
8989
return nil
@@ -122,7 +122,7 @@ extension UploadInput {
122122
}
123123

124124
mutating func processStartNetworkTransport(
125-
startingTransportStatus: MuxUpload.TransportStatus
125+
startingTransportStatus: DirectUpload.TransportStatus
126126
) {
127127
if case UploadInput.Status.underInspection = status {
128128
status = .uploadInProgress(uploadInfo, startingTransportStatus)
@@ -132,16 +132,16 @@ extension UploadInput {
132132
}
133133

134134
mutating func processUploadSuccess(
135-
transportStatus: MuxUpload.TransportStatus
135+
transportStatus: DirectUpload.TransportStatus
136136
) {
137137
if case UploadInput.Status.uploadInProgress(let info, _) = status {
138-
status = .uploadSucceeded(info, MuxUpload.Success(finalState: transportStatus))
138+
status = .uploadSucceeded(info, DirectUpload.SuccessDetails(finalState: transportStatus))
139139
} else {
140140
return
141141
}
142142
}
143143

144-
mutating func processUploadFailure(error: MuxUpload.UploadError) {
144+
mutating func processUploadFailure(error: DirectUploadError) {
145145
status = .uploadFailed(uploadInfo, error)
146146
}
147147

Sources/MuxUploadSDK/PublicAPI/AVFoundation+MuxUpload/MuxUpload+AVFoundation.swift renamed to Sources/MuxUploadSDK/PublicAPI/AVFoundation+DirectUpload/DirectUpload+AVFoundation.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// MuxUpload+AVFoundation.swift
2+
// DirectUpload+AVFoundation.swift
33
//
44

55
import AVFoundation
66
import Foundation
77

8-
extension MuxUpload {
8+
extension DirectUpload {
99

10-
/// Initializes a MuxUpload from an ``AVAsset``
10+
/// Initializes a DirectUpload from an ``AVAsset``
1111
///
1212
/// - Parameters:
1313
/// - uploadURL: the URL of your direct upload, see
@@ -20,7 +20,7 @@ extension MuxUpload {
2020
public convenience init(
2121
uploadURL: URL,
2222
inputAsset: AVAsset,
23-
options: UploadOptions
23+
options: DirectUploadOptions
2424
) {
2525
self.init(
2626
input: UploadInput(

0 commit comments

Comments
 (0)