# LIVE Service Server Side Ad Insertion

The IOIO LIVE service allows insertion of server side Ads via the MediaLive scheduling functionality.

This guide contains:

  • Creation of a Media Tailor entry
  • Adding the AdServers structure to a Blueprint
  • Inserting a Dynamic Ad using the dedicated endpoint

# Creating Media Tailor

In order to use the Ad insertion in Live we need to create a Media Tailor in the VOD service:

  1. Get an ID token or an API key.
  2. Get access to the VOD swagger.
  3. Locate the endpoint: POST /broker/private/mediatailors for API authorization or POST /broker/mediatailors for Token authorization.
  4. The body should follow this structure:
{
  "name": "string",
  "slate_ad": "string",
  "ad_server": "string",
  "type": "broker/live",
  "source_url": "string"
}
  • "name": Is a string which contains a meaningful name for the mediatalor.
  • "slate_ad": This is URL to the image which shall be displayed when no Ad has been played.
  • "ad_server": This is the Ad Server URL which will be used for the Ad Insertion.
  • "type": This is the type of the Media Tailor, there can be two types, broker and live for our particular example we will need a media tailor of type live.
  • "source_url": This is the base url from where the video is consumed for example when viewing videos from Akamai the base URL is https://[edge_hostname].akamaized.net/hls/live/[stream_id]/[event_name]/[file_name]. So we can place this part of the URL in the field: https://[edge_hostname].akamaized.net/hls/live/ and the rest will be added later.
  1. Once created you can view all of the Media Tailors by using this endpoint: GET /broker/private/mediatailors. Response will be similar to this:
{
  "status": true,
  "data": [
    {
      "name": "Live Test",
      "guid": "95b0b20d-1ada-4131-8fff-6501e6ddf2ec",
      "adServer": "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
      "type": "live",
      "masterEndpoint": "https://qa2.stg.ioio.tv/v1/master/703a141da0a277ceca8c0fd0d72d7b1f8a57af1a/95b0b20d-1ada-4131-8fff-6501e6ddf2ec/",
      "createdAt": 1659622381319,
      "updatedAt": 1659622381319,
      "sourceUrl": "https://stg-ioiotv.akamaized.net/hls/live/2016865/"
    }
  ]
}

As we can see here we have the Master Endpoint which will be used later for viewing the stream.

  1. Now we need to create a workflow which uses the needed data for inserting Ads. The workflow needs to have code snippet:
        "adServers": [
            {
                "destinationRefId": "Akamai",
                "adServerId": "95b0b20d-1ada-4131-8fff-6501e6ddf2ec"
            }
        ]

It needs to be located in root/settings/adServers.

  1. Once located we need to set the destinationRefId, this should be the ID of the destination we have.
  2. Next we need to set the adServerId which is the ID of the Media Tailor which was created in the Broker API.
  3. Now that we have all of this we can start our workflow and assemble our playback URL:
  • First we need the master endpoint from the Media Tailors endpoints in our exaple it's the following: https://qa2.stg.ioio.tv/v1/master/703a141da0a277ceca8c0fd0d72d7b1f8a57af1a/95b0b20d-1ada-4131-8fff-6501e6ddf2ec/
  • Second we need the rest of the route which we use to stream from Akamai, this is our whole URL: https://stg-ioiotv.akamaized.net/hls/live/2016865/msl4test01/master.m3u8 and we need only this part since in the sourceUrl we have the rest: /msl4test01/master.m3u8
  • When combined our whole URL should look like this: https://qa2.stg.ioio.tv/v1/master/703a141da0a277ceca8c0fd0d72d7b1f8a57af1a/95b0b20d-1ada-4131-8fff-6501e6ddf2ec//msl4test01/master.m3u8

This URL should be used for viewing when inserting Ads.

  1. Start the workflow as you would normally start it.
  2. Locate the POST ​/channels​/{workflowId}​/dynamic-ads endpoint. This endpoint needs the workflow ID for which we will insert an Ad and the body accepts the duration in the following example:
{
  "duration": 30
}

NOTE: Duration is in seconds

  1. Once executed the manifest will be decorated with the needed tags to insert an Ad into the stream.