Skip to content

Commit

Permalink
Added plannedDuration to interstitial tag builder
Browse files Browse the repository at this point in the history
- fixed qutoe escape issues for numerical values in builder
- upated unit tests
  • Loading branch information
rmigneco committed Oct 28, 2024
1 parent c7f6484 commit c3fff36
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
27 changes: 24 additions & 3 deletions mambaSharedFramework/InterstitialTagBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public final class InterstitialTagBuilder {
/// the duration of the interstitial content in seconds
var duration: Double?

/// the expected duration of the interstitial content in seconds which can indicate a value when the actual duration is not yet known
var plannedDuration: Double?

/// The value of X-RESUME-OFFSET is a decimal-floating-point of seconds that specifies where primary playback is to resume
/// following the playback of the interstitial.
var resumeOffset: Double?
Expand Down Expand Up @@ -122,6 +125,18 @@ public final class InterstitialTagBuilder {
return self
}

/// Specifies the planned duration of the interstitial
///
/// - Parameter duration: `Double` indicating duration
///
/// - Returns: an instance of the builder
@discardableResult
public func withPlannedDuration(_ plannedDuration: Double) -> Self {
self.plannedDuration = plannedDuration

return self
}

/// Configures the interstitial with a resume offset
///
/// - Parameter offset: `Double` indicating the resume offset
Expand Down Expand Up @@ -240,17 +255,23 @@ public final class InterstitialTagBuilder {
}

if let duration {
hlsTagDictionary[PantosValue.duration.rawValue] = HLSValueData(value: String(duration), quoteEscaped: true)
hlsTagDictionary[PantosValue.duration.rawValue] = HLSValueData(value: String(duration),
quoteEscaped: false)
}

if let plannedDuration {
hlsTagDictionary[PantosValue.plannedDuration.rawValue] = HLSValueData(value: String(plannedDuration),
quoteEscaped: false)
}

if let resumeOffset {
hlsTagDictionary[PantosValue.resumeOffset.rawValue] = HLSValueData(value: String(resumeOffset),
quoteEscaped: true)
quoteEscaped: false)
}

if let playoutLimit {
hlsTagDictionary[PantosValue.playoutLimit.rawValue] = HLSValueData(value: String(playoutLimit),
quoteEscaped: true)
quoteEscaped: false)
}

if let restrictions {
Expand Down
3 changes: 3 additions & 0 deletions mambaTests/Util Tests/InterstitialTagBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ final class InterstitialTagBuilderTests: XCTestCase {
func decorateAndTest(_ tagBuilder: InterstitialTagBuilder) -> HLSTag {

let duration: Double = 10.0
let plannedDuration: Double = 10.0
let alignment = HLSInterstitialAlignment(values: [.in, .out])
let restrictions = HLSInterstitialSeekRestrictions(restrictions: [.skip, .jump])
let playoutLimit: Double = 30.0
Expand All @@ -75,6 +76,7 @@ final class InterstitialTagBuilderTests: XCTestCase {

let tag = tagBuilder
.withDuration(duration)
.withPlannedDuration(plannedDuration)
.withAlignment(alignment)
.withRestrictions(restrictions)
.withPlayoutLimit(playoutLimit)
Expand All @@ -86,6 +88,7 @@ final class InterstitialTagBuilderTests: XCTestCase {
.buildTag()

XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.duration), duration)
XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.plannedDuration), plannedDuration)
XCTAssertEqual(tag.value<HLSInterstitialAlignment>(forValueIdentifier: PantosValue.snap), alignment)
XCTAssertEqual(tag.value<HLSInterstitialSeekRestrictions>(forValueIdentifier: PantosValue.restrict), restrictions)
XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.playoutLimit), playoutLimit)
Expand Down

0 comments on commit c3fff36

Please sign in to comment.