Skip to content

Commit caf5d48

Browse files
authored
feat: expose maximum resolution playback modifiers for 1080p and 2160p (#16)
1 parent d488c74 commit caf5d48

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

Sources/MuxPlayerSwift/PublicAPI/Options/PlaybackOptions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public enum ResolutionTier {
1313
/// The asset will stream with a resolution that does
1414
/// not exceed 720p (720 x 1280)
1515
case upTo720p
16+
/// The asset will stream with a resolution that does
17+
/// not exceed 1080p (1080 x 1920)
18+
case upTo1080p
19+
/// The asset will stream with a resolution that does
20+
/// not exceed 2160 (2160 x 4096)
21+
case upTo2160p
1622
}
1723

1824
extension ResolutionTier {
@@ -22,6 +28,10 @@ extension ResolutionTier {
2228
return ""
2329
case .upTo720p:
2430
return "720p"
31+
case .upTo1080p:
32+
return "1080p"
33+
case .upTo2160p:
34+
return "2160p"
2535
}
2636
}
2737
}

Tests/MuxPlayerSwift/PlaybackURLTests.swift

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,31 @@ final class PlaybackURLTests: XCTestCase {
1919
}
2020

2121
func testMaximumResolution() throws {
22-
let playbackOptions = PlaybackOptions(
23-
maximumResolutionTier: .upTo720p
24-
)
25-
26-
let playerItem = AVPlayerItem(
27-
playbackID: "abc",
28-
playbackOptions: playbackOptions
29-
)
3022

31-
XCTAssertEqual(
32-
(playerItem.asset as! AVURLAsset).url.absoluteString,
33-
"https://stream.mux.com/abc.m3u8?redundant_streams=true&max_resolution=720p"
34-
)
23+
let expectedURLs: [String: String] = [
24+
ResolutionTier.upTo720p.queryValue: "https://stream.mux.com/abc.m3u8?redundant_streams=true&max_resolution=720p",
25+
ResolutionTier.upTo1080p.queryValue: "https://stream.mux.com/abc.m3u8?redundant_streams=true&max_resolution=1080p",
26+
ResolutionTier.upTo2160p.queryValue: "https://stream.mux.com/abc.m3u8?redundant_streams=true&max_resolution=2160p",
27+
ResolutionTier.default.queryValue: "https://stream.mux.com/abc.m3u8?redundant_streams=true",
28+
]
29+
30+
let tiers: [ResolutionTier] = [.upTo720p, .upTo1080p, .upTo2160p, .default]
31+
32+
for tier in tiers {
33+
let playbackOptions = PlaybackOptions(
34+
maximumResolutionTier: tier
35+
)
36+
37+
let playerItem = AVPlayerItem(
38+
playbackID: "abc",
39+
playbackOptions: playbackOptions
40+
)
41+
42+
XCTAssertEqual(
43+
(playerItem.asset as! AVURLAsset).url.absoluteString,
44+
expectedURLs[tier.queryValue]
45+
)
46+
}
3547
}
3648

3749
func testCustomDomainPlaybackURL() throws {

0 commit comments

Comments
 (0)