This guide covers configuring your manifest manipulator to request ad or slate segments using the ad pod segment method.
Select a streaming protocol:
Prerequisites
Before you continue, you must set up a livestream event for the Pod serving redirect Dynamic Ad Insertion (DAI) type and encoding profiles. To set up a livestream event, choose one of the following methods:
- Ad Manager UI: Set up a livestream for DAI.
- Ad Manager API: Use a client library to call
LiveStreamEventService.createLiveStreamEvents
method. Set theLiveStreamEvent.dynamicAdInsertionType
parameter toPOD_SERVING_REDIRECT
.
After you set up the livestream event, retrieve the event's encoding profiles
from Ad Manager UI or API by calling
DaiEncodingProfileService.getDaiEncodingProfilesByStatement
method.
Retrieve the content stream
When a user selects a livestream event, the client app makes a stream request to Google Ad Manager. In the stream response, the app extracts the Google DAI session ID and metadata to include in the stream manifest request.
The following example passes a Google DAI session ID to a manifest manipulator:
https://MANIFEST_MANIPULATOR_URL/manifest.m3u8?DAI_stream_ID=SESSION_ID&network_code=NETWORK_CODE&DAI_custom_asset_key=CUSTOM_ASSET_KEY
When processing the video content playback request, store the Google DAI session ID and CUSTOM_ASSET_KEY from the request to prepare for ad stitching.
Identify ad break segments and insert discontinuities
As you process each variant manifest, identify the EXT-X-CUE-IN
and
EXT-X-CUE-OUT
tags in your stream, indicating the start and end of an ad
break.
Replace the EXT-X-CUE-IN
and EXT-X-CUE-OUT
tags with the
EXT-X-DISCONTINUITY
elements for the client video player to switch between
content and ads.
The following example manifest replaces the EXT-X-CUE-IN
and EXT-X-CUE-OUT
tags:
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.000,
contentorigin.com/1.ts
#EXTINF:5.000,
contentorigin.com/2.ts
#EXT-X-CUE-OUT:15.000
#EXTINF:5.000,
contentorigin.com/3.ts
#EXTINF:5.000,
contentorigin.com/4.ts
#EXTINF:5.000,
contentorigin.com/5.ts
#EXT-X-CUE-IN
#EXTINF:5.000,
contentorigin.com/6.ts
#EXTINF:5.000,
contentorigin.com/7.mp4
#EXTINF:5.000,
contentorigin.com/8.mp4
The following example shows a replaced manifest:
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.000,
contentorigin.com/1.ts
#EXTINF:5.000,
contentorigin.com/2.ts
#EXTINF:5.000,
#EXT-X-DISCONTINUITY
{... Insert ad segments here ...}
#EXT-X-DISCONTINUITY
#EXTINF:5.000,
contentorigin.com/6.mp4
#EXTINF:5.000,
contentorigin.com/7.mp4
#EXTINF:5.000,
contentorigin.com/8.mp4
Google DAI ad segments are not encrypted. If your content is encrypted, remove
encryption by inserting EXT-X-KEY:METHOD=NONE
element prior to the first ad
segment of each ad break. At the end of the ad break, add encryption back by
inserting an appropriate EXT-X-KEY
.
Keep track of the start time, duration, and index of the upcoming ad break.
Generate a Hash-based Message Authentication Code (HMAC) token
Each segment request made using segment redirect pod serving must include a HMAC-signed token for authentication.
Calculate this token once per ad break and share the token across all stream sessions.
Gather token parameters
To populate the token body, gather the following from the current ad break:
Token Parameters | ||
---|---|---|
custom_asset_key
|
Required | The custom livestream asset key from Google Ad Manager. |
cust_params
|
Optional | Custom targeting parameters. See cust_params .
|
exp
|
Required | Expiration timestamp for the current token in seconds. |
network_code
|
Required | The Ad Manager 360 network code. |
pod_id
|
Required | Identifier for the ad break. An integer starting at
1 . For each ad break, this identifier increments by one.
This value must be the same across all users viewing the same ad break in the current event. |
pd
|
Required, except for events with duration-less ad breaks enabled. | The duration in milliseconds of the ad break. Referred as
ad_pod_duration .
|
scte35
|
Optional | Base64-encoded SCTE-35 signal. Google DAI always copies the signal to
the created ad break, even if the signal is incorrect.
If incorrect, you receive a message in the
X-Ad-Manager-Dai-Warning HTTP header in the response, and the
signal still continues to create an ad break. For details on how DAI uses
the SCTE-35 signal, see the supported
ad markers.
|
Create token string
To create a token string, list each parameter in alphabetical order,
in the format NAME=VALUE
,
with each name-value pair separated by a ~
tilde character.
For unused optional parameters, use an empty string as the value, or remove the parameter entirely.
The following example formats a token string:
custom_asset_key=CUSTOM_ASSET_STRING~exp=EXPIRATION~network_code=NETWORK_CODE~pd=POD_DURATION~pod_id=AD_POD_INDEX~scte35=SCTE35_MESSAGE
Generate HMAC signature
The HMAC signature is a SHA-256 hash of the token string in HEX format. The secret key is the HMAC authentication key associated with your livestream event in Google Ad Manager.
Sign token string
After you generate the HMAC signature, append the signature to the token string in the following format:
~hmac=HMAC_SIGNATURE
Encode token string
To pass the token as a URL parameter, encode the URL for safety.
The following example generates a signed and encoded HMAC token where unused optional parameters are empty strings:
custom_asset_key=iYdOkYZdQ1KFULXSN0Gi7g~cust_params=~exp=1489680000~network_code=6062~pd=180000~pod_id=5~scte35=
Secret key:
A7490591290583E4B93189DEE7E287C299FC686872ABC7ADC9F9F536443505F
HMAC signature:
86d7e5f8c96fe4c83141d764df376ae14a0e2066f2e6b2ccfb9e1e2d3c869a88
Signed token:
custom_asset_key=iYdOkYZdQ1KFULXSN0Gi7g~cust_params=~exp=1489680000~network_code=6062~pd=180000~pod_id=5~scte35=~hmac=86d7e5f8c96fe4c83141d764df376ae14a0e2066f2e6b2ccfb9e1e2d3c869a88
URL-encoded signed token:
custom_asset_key%3DiYdOkYZdQ1KFULXSN0Gi7g~cust_params%3D~exp%3D1489680000~network_code%3D6062~pd%3D180000~pod_id%3D5~scte35%3D~hmac%3D86d7e5f8c96fe4c83141d764df376ae14a0e2066f2e6b2ccfb9e1e2d3c869a88
The following example generates a signed and encoded HMAC token without unused optional parameters:
custom_asset_key=iYdOkYZdQ1KFULXSN0Gi7g3~exp=1489680000~network_code=6062~pd=180000~pod_id=5
Secret key:
A7490591290583E4B93189DEE7E287C299FC686872ABC7ADC9F9F536443505F
HMAC signature:
6a8c44c72e4718ff63ad2284edf2a8b9e319600b430349d31195c99b505858c9
Signed token:
custom_asset_key=iYdOkYZdQ1KFULXSN0Gi7g~exp=1489680000~network_code=6062~pd=180000~pod_id=5~hmac=6a8c44c72e4718ff63ad2284edf2a8b9e319600b430349d31195c99b505858c9
URL-encoded signed token:
custom_asset_key%3DiYdOkYZdQ1KFULXSN0Gi7g~exp%3D1489680000~network_code%3D6062~pd%3D180000~pod_id%3D5~hmac%3D6a8c44c72e4718ff63ad2284edf2a8b9e319600b430349d31195c99b505858c9
Build ad segment URLs
Replace each content segment between the EXT-X-DISCONTINUITY
tags with a URL
pointing to the ad pod segment method.
The following example assembles an ad pod segment. Note that ad segments use a zero-based index:
https://dai.google.com/linear/pods/v1/seg/network/NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/0.ts?sd=AD_SEGMENT_DURATION&pd=AD_BREAK_DURATION&stream_id=SESSION_ID&auth-token=HMAC
The following example inserts the ad pod segments into the manifest:
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.00,
contentorigin.com/1.ts
#EXTINF:5.00,
contentorigin.com/2.ts
#EXT-X-DISCONTINUITY
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/0.ts?sd=5000&so=0&pd=15000&stream_id=SESSION_ID
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/1.ts?sd=5000&so=5000&pd=15000&stream_id=SESSION_ID
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/2.ts?sd=5000&so=10000&pd=15000&stream_id=SESSION_ID
#EXT-X-DISCONTINUITY
#EXTINF:5.00,
contentorigin.com/6.mp4
#EXTINF:5.00,
contentorigin.com/7.mp4
#EXTINF:5.00,
contentorigin.com/8.mp4
Optional: Schedule an ad break
To enhance your fill rate, send an Early Ad Break Notification (EABN) with the ad pod duration, custom targeting parameters, and SCTE-35 signal data. For more details, see Send early ad break notifications.