Writing Sender Apps for the CAF DAI SDK

Unlike previous integrations between Chromecast and DAI, the CAF DAI SDK focuses heavily on maintaining the standards and expectations set by the Cast Application Framework. As such, there are no requirements to heavily customize your sender apps to manage bidirectional communications between the IMA and the sender app. These communications are now managed via the integrated CAF Ad Breaks functionality, rather than requiring custom message systems to communicate between the sender app and receiver.

Depending on your sender, you may still need to add some limited code to your senders to fully enable CAF Ad Breaks support, such as adding support for skippable ads to web senders.

All that is required now, aside from support for CAF Ad Breaks, is to include the DAI stream data in the CAF MediaInfo object that is sent from the sender to the receiver. You can choose to send this data in many different ways, for example, you could hard code the contentSourceID on your receiver and only send videoID with the MediaInfo object, or you could send an arbitrary identifier to the receiver, and from there query an online database for the actual DAI parameters.

However, for the purpose of simplicity, all our samples will assume that you follow this simple structure and naming convention for your MediaInfo objects:

contentId A unique identifier for this media item
contentUrl The fallback stream url to load if the DAI StreamRequest fails for any reason
streamType For live streams this value should be set to 'LIVE'. For VOD streams, this value should be set to 'BUFFERED'
customData assetKey Live streams only. Identifies the live stream to be loaded
contentSourceId VOD streams only. Identifies the media feed that contains the requested stream.
videoId VOD streams only. Identifies the requested stream within the specified media feed.
ApiKey An optional API key that can be required to retrieve the stream url from the IMA DAI SDK.
senderCanSkip A boolean value to let the receiver know whether the sending device has the ability to display a skip button, enabling support for skippable ads

Example LIVE Stream:

{
  "media": {
    "contentId": "bbb",
    "contentUrl": "https://storage.googleapis.com/interactive-media-ads/media/bbb.m3u8",
    "streamType": "LIVE",
    "customData": {
      "assetKey": "sN_IYUG8STe1ZzhIIE_ksA",
      "ApiKey": "",
      "senderCanSkip": true
    }
  },
  "credentials": "testCredentials"
}

Example VOD Stream:

{
  "media": {
    "contentId": "tos",
    "contentUrl": "https://storage.googleapis.com/interactive-media-ads/media/tos.m3u8",
    "streamType": "BUFFERED",
    "customData": {
      "contentSourceId": "2528370",
      "videoId": "tears-of-steel",
      "ApiKey": "",
      "senderCanSkip": true
    }
  },
  "credentials": "testCredentials"
}