處理線性 DAI 串流中的定時中繼資料

互動式媒體廣告 (IMA) 動態廣告插播 SDK (DAI) 取決於串流媒體區隔 (頻內中繼資料) 或串流資訊清單檔案 (傳入資訊清單中繼資料) 中的中繼資料資訊,來追蹤觀眾的位置和用戶端廣告事件。視播放的串流類型而定,動態廣告插播串流可提供不同格式的中繼資料。Roku IMA SDK 會透過單一 API 處理所有中繼資料格式。

您的應用程式負責擷取中繼資料,並將其轉送至 IMA DAI SDK。SDK 提供的 StreamManager.onMessage() 方法可傳遞這項資訊。這個方法會以 roVideo 通訊埠提供的 msg 物件形式轉送中繼資料。接著,IMA DAI SDK 會處理這些物件,建立廣告事件的時間。它採用單一引數:

  • msg:roVideo 通訊埠提供的訊息類型物件。

中繼資料程式碼範例

以下範例說明如何處理 roVideo 通訊埠的中繼資料,並透過 StreamManager.onMessage() 將其傳送至 IMA SDK。

Sub runLoop()
  ' Forward all timed metadata events to IMA.
  m.top.video.timedMetaDataSelectionKeys = ["*"]

  ' Cycle through all the fields and set listeners.
  ' IMPORTANT: Failure to listen to the position and timedmetadata fields could
  ' result in ad impressions not being reported.
  m.port = CreateObject("roMessagePort")
  fields = m.top.video.getFields()
  for each field in fields
    m.top.video.observeField(field, m.port)
  end for

  while True
    msg = wait(1000, m.port)
    if m.top.video = invalid
      print "exiting"
      exit while
    end if

    m.streamManager.onMessage(msg)
    currentTime = m.top.video.position
    If currentTime > 3 And not m.top.adPlaying
       m.top.video.enableTrickPlay = true
    End If
  end while
End Sub

如要進一步瞭解如何在應用程式中加入迴圈處理串流中繼資料,請參閱 IMA Roku 入門指南。指南的事件監聽器和串流開始一節包含中繼資料處理迴圈。

HTTP 即時串流 (HLS CMAF) 串流

使用共同媒體應用程式架構 (CMAF) 的線性 DAI HLS 串流,會透過符合 ID3 經由 CMAF 標準的頻帶 eMSGv1 方塊傳遞定時中繼資料。這些 eMSG 方塊內嵌在每個媒體區隔的開頭,每個 ID3 eMSG 都含有與串流中上次中斷有關的 PTS。

如果是 IMA Roku,所有 HLS CMAF 串流都會使用 eMSGv0 格式傳送頻內 ID3 資料。 IMA 會將 eMSGv0 格式提供的資訊與影片物件的資訊結合。

如要啟用正確剖析 HLS CMAF 串流 ID3 事件的功能,您必須使用 StreamRequest.videoObject 在串流要求中傳送影片物件。