Skip to content

Commit

Permalink
Refactored inherited roles parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Nov 22, 2023
1 parent 22d5a3d commit fd71c4d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Sources/MarkersExtractor/Export/ExportProfile Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class AnimatedImagesWriter: NSObject, ImageWriterProtocol {
}
}

assert(progress.fractionCompleted == 1.0)
// TODO: NSProgress is wonky, sometimes its not fully 1.0 so asserting here isn't helpful
// assert(progress.fractionCompleted == 1.0)
}

private func write(descriptor: ImageDescriptor) async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ class FCPXMLMarkerExtractor: NSObject, ProgressReporting {
switch role {
case let .audio(roleString):
markerRoles.isAudioDefault = isRoleDefault
markerRoles.audio = roleString
if !roleString.isEmpty { markerRoles.audio = roleString }

case let .video(roleString):
markerRoles.isVideoDefault = isRoleDefault
markerRoles.video = roleString
if !roleString.isEmpty { markerRoles.video = roleString }

case .caption(_):
// TODO: assign to video role may not be right?
Expand Down
22 changes: 0 additions & 22 deletions Sources/MarkersExtractor/Import/Marker/MarkerRole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,6 @@ public struct MarkerRoles: Equatable, Hashable, Sendable {
self.isAudioDefault = isAudioDefault
if collapseSubroles { self.collapseSubroles() }
}

// TODO: could remove once refactored into DAWFileKit

/// Returns FCP's default role(s) for each clip type.
/// FCP does not write the role to the XML when it does not have a custom role set and is using
/// a default role.
///
/// - Note: This does not cover all cases as clip type is not the only identifier
/// that can be used to determine clip role.
///
/// - Parameter clipType: XML element name. ie: "title" for XML `<title ...>`
/// - Returns: Role name string. Returns `nil` for unhandled/unrecognized clip types.
public init?(defaultForClipType clipType: String) {
switch clipType {
case "asset-clip":
self.init(video: "Video", isVideoDefault: true)
case "title":
self.init(video: "Titles", isVideoDefault: true)
default:
return nil
}
}
}

// MARK: - Methods
Expand Down
2 changes: 0 additions & 2 deletions Tests/MarkersExtractorTests/MarkerRolesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ final class MarkerRolesTests: XCTestCase {
}

func testIsDefault() {
XCTAssertEqual(MarkerRoles(defaultForClipType: "title")?.isVideoDefault, true)

XCTAssertEqual(MarkerRoles(video: "Video", isVideoDefault: true).isVideoDefault, true)
XCTAssertEqual(MarkerRoles(video: "Video", isVideoDefault: false).isVideoDefault, false)

Expand Down

0 comments on commit fd71c4d

Please sign in to comment.