Skip to content

Commit 440593f

Browse files
committed
Clarified enum naming and favored more terse function syntax
1 parent f23275d commit 440593f

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

mambaSharedFramework/HLSValueTypes.swift

+8-12
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,15 @@ public func ==(lhs: HLSCodecArray, rhs: HLSCodecArray) -> Bool {
460460
public struct HLSVideoLayout: Equatable, FailableStringLiteralConvertible {
461461
/// Each specifier controls one aspect of the entry. That is, the specifiers are disjoint and the values for a
462462
/// specifier are mutually exclusive.
463-
public let layouts: [VideoLayout]
463+
public let layouts: [VideoLayoutIdentifier]
464464
/// The client SHOULD assume that the order of entries reflects the most common presentation in the content.
465465
///
466466
/// For example, if the content is predominantly stereoscopic, with some brief sections that are monoscopic then the
467467
/// Multivariant Playlist SHOULD specify `REQ-VIDEO-LAYOUT="CH-STEREO,CH-MONO"`. On the other hand, if the content
468468
/// is predominantly monoscopic then the Multivariant Playlist SHOULD specify `REQ-VIDEO-LAYOUT="CH-MONO,CH-STEREO"`.
469-
public let predominantLayout: VideoLayout
469+
public let predominantLayout: VideoLayoutIdentifier
470470

471-
public enum VideoLayout: String {
471+
public enum VideoLayoutIdentifier: String {
472472
/// Monoscopic.
473473
///
474474
/// Indicates that a single image is present.
@@ -488,9 +488,9 @@ public struct HLSVideoLayout: Equatable, FailableStringLiteralConvertible {
488488
}
489489

490490
public init?(string: String) {
491-
var layouts = [VideoLayout]()
491+
var layouts = [VideoLayoutIdentifier]()
492492
for str in string.split(separator: ",") {
493-
if let layout = VideoLayout(str: str) {
493+
if let layout = VideoLayoutIdentifier(str: str) {
494494
layouts.append(layout)
495495
} else {
496496
// Favor failing to parse the whole array if we find an unrecognized layout, so that we don't risk mis-
@@ -505,17 +505,13 @@ public struct HLSVideoLayout: Equatable, FailableStringLiteralConvertible {
505505
self.layouts = layouts
506506
}
507507

508-
public init?(layouts: [VideoLayout]) {
508+
public init?(layouts: [VideoLayoutIdentifier]) {
509509
guard let predominantLayout = layouts.first else { return nil }
510510
self.layouts = layouts
511511
self.predominantLayout = predominantLayout
512512
}
513513

514-
public func containsStereo() -> Bool {
515-
layouts.contains(.chStereo)
516-
}
517-
518-
public func containsMono() -> Bool {
519-
layouts.contains(.chMono)
514+
public func contains(_ layout: VideoLayoutIdentifier) -> Bool {
515+
layouts.contains(layout)
520516
}
521517
}

mambaTests/Util Tests/Value Types/HLSVideoLayoutTests.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class HLSVideoLayoutTests: XCTestCase {
4444
}
4545
XCTAssertEqual(videoLayout.layouts, [.chMono])
4646
XCTAssertEqual(videoLayout.predominantLayout, .chMono)
47-
XCTAssertTrue(videoLayout.containsMono())
48-
XCTAssertFalse(videoLayout.containsStereo())
47+
XCTAssertTrue(videoLayout.contains(.chMono))
48+
XCTAssertFalse(videoLayout.contains(.chStereo))
4949
}
5050

5151
func test_stereoLayout() {
@@ -54,8 +54,8 @@ class HLSVideoLayoutTests: XCTestCase {
5454
}
5555
XCTAssertEqual(videoLayout.layouts, [.chStereo])
5656
XCTAssertEqual(videoLayout.predominantLayout, .chStereo)
57-
XCTAssertFalse(videoLayout.containsMono())
58-
XCTAssertTrue(videoLayout.containsStereo())
57+
XCTAssertFalse(videoLayout.contains(.chMono))
58+
XCTAssertTrue(videoLayout.contains(.chStereo))
5959
}
6060

6161
func test_stereoWithMonoLayout() {
@@ -64,8 +64,8 @@ class HLSVideoLayoutTests: XCTestCase {
6464
}
6565
XCTAssertEqual(videoLayout.layouts, [.chStereo, .chMono])
6666
XCTAssertEqual(videoLayout.predominantLayout, .chStereo)
67-
XCTAssertTrue(videoLayout.containsMono())
68-
XCTAssertTrue(videoLayout.containsStereo())
67+
XCTAssertTrue(videoLayout.contains(.chMono))
68+
XCTAssertTrue(videoLayout.contains(.chStereo))
6969
}
7070

7171
func test_monoWithStereoLayout() {
@@ -74,8 +74,8 @@ class HLSVideoLayoutTests: XCTestCase {
7474
}
7575
XCTAssertEqual(videoLayout.layouts, [.chMono, .chStereo])
7676
XCTAssertEqual(videoLayout.predominantLayout, .chMono)
77-
XCTAssertTrue(videoLayout.containsMono())
78-
XCTAssertTrue(videoLayout.containsStereo())
77+
XCTAssertTrue(videoLayout.contains(.chMono))
78+
XCTAssertTrue(videoLayout.contains(.chStereo))
7979
}
8080

8181
func test_monoWithStereoWithUnknownLayout() {

0 commit comments

Comments
 (0)