Skip to content

Commit c3fff36

Browse files
committed
Added plannedDuration to interstitial tag builder
- fixed qutoe escape issues for numerical values in builder - upated unit tests
1 parent c7f6484 commit c3fff36

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

mambaSharedFramework/InterstitialTagBuilder.swift

+24-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public final class InterstitialTagBuilder {
5252
/// the duration of the interstitial content in seconds
5353
var duration: Double?
5454

55+
/// the expected duration of the interstitial content in seconds which can indicate a value when the actual duration is not yet known
56+
var plannedDuration: Double?
57+
5558
/// The value of X-RESUME-OFFSET is a decimal-floating-point of seconds that specifies where primary playback is to resume
5659
/// following the playback of the interstitial.
5760
var resumeOffset: Double?
@@ -122,6 +125,18 @@ public final class InterstitialTagBuilder {
122125
return self
123126
}
124127

128+
/// Specifies the planned duration of the interstitial
129+
///
130+
/// - Parameter duration: `Double` indicating duration
131+
///
132+
/// - Returns: an instance of the builder
133+
@discardableResult
134+
public func withPlannedDuration(_ plannedDuration: Double) -> Self {
135+
self.plannedDuration = plannedDuration
136+
137+
return self
138+
}
139+
125140
/// Configures the interstitial with a resume offset
126141
///
127142
/// - Parameter offset: `Double` indicating the resume offset
@@ -240,17 +255,23 @@ public final class InterstitialTagBuilder {
240255
}
241256

242257
if let duration {
243-
hlsTagDictionary[PantosValue.duration.rawValue] = HLSValueData(value: String(duration), quoteEscaped: true)
258+
hlsTagDictionary[PantosValue.duration.rawValue] = HLSValueData(value: String(duration),
259+
quoteEscaped: false)
260+
}
261+
262+
if let plannedDuration {
263+
hlsTagDictionary[PantosValue.plannedDuration.rawValue] = HLSValueData(value: String(plannedDuration),
264+
quoteEscaped: false)
244265
}
245266

246267
if let resumeOffset {
247268
hlsTagDictionary[PantosValue.resumeOffset.rawValue] = HLSValueData(value: String(resumeOffset),
248-
quoteEscaped: true)
269+
quoteEscaped: false)
249270
}
250271

251272
if let playoutLimit {
252273
hlsTagDictionary[PantosValue.playoutLimit.rawValue] = HLSValueData(value: String(playoutLimit),
253-
quoteEscaped: true)
274+
quoteEscaped: false)
254275
}
255276

256277
if let restrictions {

mambaTests/Util Tests/InterstitialTagBuilderTests.swift

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ final class InterstitialTagBuilderTests: XCTestCase {
6363
func decorateAndTest(_ tagBuilder: InterstitialTagBuilder) -> HLSTag {
6464

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

7677
let tag = tagBuilder
7778
.withDuration(duration)
79+
.withPlannedDuration(plannedDuration)
7880
.withAlignment(alignment)
7981
.withRestrictions(restrictions)
8082
.withPlayoutLimit(playoutLimit)
@@ -86,6 +88,7 @@ final class InterstitialTagBuilderTests: XCTestCase {
8688
.buildTag()
8789

8890
XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.duration), duration)
91+
XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.plannedDuration), plannedDuration)
8992
XCTAssertEqual(tag.value<HLSInterstitialAlignment>(forValueIdentifier: PantosValue.snap), alignment)
9093
XCTAssertEqual(tag.value<HLSInterstitialSeekRestrictions>(forValueIdentifier: PantosValue.restrict), restrictions)
9194
XCTAssertEqual(tag.value<Double>(forValueIdentifier: PantosValue.playoutLimit), playoutLimit)

0 commit comments

Comments
 (0)