@@ -236,18 +236,35 @@ class PlayerHandler {
236236 func updateMetadata( ) {
237237 log ( " handling updateMetadata " )
238238 guard let convivaSessionSource = self . currentConvivaSession. source,
239- let url = self . currentConvivaSession . source ? . url as? String else {
239+ let url = convivaSessionSource . url else {
240240 return
241241 }
242242
243- let metadata : [ String : Any ] = [
243+ var metadata : [ String : Any ] = [
244244 CIS_SSDK_METADATA_PLAYER_NAME: self . storage? . metadataEntryForKey ( CIS_SSDK_METADATA_PLAYER_NAME) ?? Utilities . playerName,
245245 CIS_SSDK_METADATA_STREAM_URL: url,
246246 CIS_SSDK_METADATA_ASSET_NAME: convivaSessionSource. description. metadata? . title ?? Utilities . defaultStringValue,
247247 ]
248+
249+ let adDescriptionMetadata : [ String : Any ] = collectAdDescriptionMetadata ( from: convivaSessionSource. description)
250+ metadata. merge ( adDescriptionMetadata) { ( _, new) in new }
251+
248252 self . setContentInfo ( metadata)
249253 }
250254
255+ private func collectAdDescriptionMetadata( from sourceDescription: SourceDescription ) -> [ String : Any ] {
256+ var metadata : [ String : Any ] = [ : ]
257+ if let theoAdDescription = sourceDescription. ads? . first ( where: { $0 is THEOAdDescription } ) as? THEOAdDescription ,
258+ let streamActivityMonitorId = theoAdDescription. streamActivityMonitorId {
259+ metadata [ " streamActivityMonitorId " ] = streamActivityMonitorId
260+ } else if let daiConfiguration = sourceDescription. sources. first? . ssai as? GoogleDAIConfiguration ,
261+ let streamActivityMonitorId = daiConfiguration. streamActivityMonitorID {
262+ metadata [ " streamActivityMonitorId " ] = streamActivityMonitorId
263+ return metadata
264+ }
265+ return metadata
266+ }
267+
251268 func durationChange( event: DurationChangeEvent ) {
252269 log ( " handling durationChange " )
253270 var metadata : [ String : Any ] = [ : ]
0 commit comments