Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Conviva
- Fixed an issue where the initial metadata passed to the convivaConnector was not persistent across Conviva sessions.
- Fixed an issue where the session's assetName was not configurable by setContentInfo, which has higher precedence than source.metadata.title.
- Fixed an issue with the encodingType, where sometimes the encodingType of the previous session was reported

## [10.7.0] - 2025-12-18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class PlayerHandler {
private weak var endpoints: ConvivaEndpoints?
private weak var storage: ConvivaStorage?
private var playerState: PlayerState = .CONVIVA_UNKNOWN

private var unreportedEncodingType: String?
private var encodingTypeIsPending = false

init(endpoints: ConvivaEndpoints, storage: ConvivaStorage, convivaMetadata: [String:Any]) {
self.endpoints = endpoints
Expand Down Expand Up @@ -189,23 +192,35 @@ class PlayerHandler {
func currentSourceChange(event: CurrentSourceChangeEvent) {
log("handling currentSourceChange")
guard let sourceType = event.currentSource?.type else {
log("not processing currentSourceChange")
return
}
var encodingType: String?

/* EncodingType reporting: The currentSourceChange event is used to extract the encoding type of the internally selected source. For HLS, this event is dispatched right before the sourceChange event. For HESP sources, it is dispatched after the play event, when a valid endpoint has been selected.*/

var calculatedEncodingType: String? = nil
switch sourceType.lowercased() {
case "application/vnd.theo.hesp+json":
encodingType = "HESP"
calculatedEncodingType = "HESP"
case "application/x-mpegurl",
"application/vnd.apple.mpegurl",
"video/mp2t":
encodingType = "HLS"
calculatedEncodingType = "HLS"
default:
encodingType = nil
calculatedEncodingType = nil
}

if self.storage?.metadataEntryForKey(ENCODING_TYPE) == nil,
let encodingType = encodingType {
self.setContentInfo([ENCODING_TYPE:encodingType])
if let encodingType = self.storage?.metadataEntryForKey(ENCODING_TYPE) as? String ?? calculatedEncodingType {
/* For HESP sources the encodingType is not available at session startup (play event) and encodingType will have been marked as pending. Once the currentSourceChange event is dispatched, this mark indicates the calculated encodingType can be pushed immediately to conviva and the mark can be reset. */
if self.encodingTypeIsPending {
self.setContentInfo([ENCODING_TYPE:encodingType])
self.unreportedEncodingType = nil
self.encodingTypeIsPending = false
}
/* For HLS sources we cache the encoding type till the play event (Conviva session creation), at which the cached value will be pushed to conviva and the caching is reset to prevent further reporting. */
else {
self.unreportedEncodingType = encodingType
}
}
}

Expand Down Expand Up @@ -251,6 +266,20 @@ class PlayerHandler {

let adDescriptionMetadata: [String: Any] = collectAdDescriptionMetadata(from: convivaSessionSource.description)
metadata.merge(adDescriptionMetadata) { (_, new) in new }

/* EncodingType reporting:
1. A customer set encodingType always has precedence over the calculated encodingtype
2. For HLS sources (unreportedEncodingType is set on earlier currentSourceChange event) we can now report the encodingType.
3. For HESP sources (unreportedEncodingType is still nil) we mark the encodingType as pending, because the currentSourceChange event will be dispatched after the play event).
*/
if let encodingType = self.storage?.metadataEntryForKey(ENCODING_TYPE) as? String ?? self.unreportedEncodingType {
log("reporting encodingType \(self.unreportedEncodingType ?? "nil")")
metadata[ENCODING_TYPE] = encodingType
self.unreportedEncodingType = nil
} else {
self.encodingTypeIsPending = true
log("marked encodingType as pending")
}

self.setContentInfo(metadata)
}
Expand Down