Best practices for DAI backup streams

Unlike a client-side video implementation where the video stream and ads are requested independent of one another, the server-side implementation used with Dynamic Ad Insertion (DAI) requests only one stream, with ads dynamically stitched into the video content. If a server error occurs, the stream can be blocked, which not only provides a poor user experience, but lost revenue.

Ad Manager DAI provides you with HTTP errors when you create a stream as well as when the stream is running, and allows you to specify a backup stream in the event that you do not get a valid response from the server.

The backup stream should be used when an error is detected during the stream creation. If an error occurs while the stream is running, Ad Manager automatically attempts to resolve the issues using all of your variants. If none of the variants successfully play, the stream ends. It is then recommended that you initiate another stream and attempt to run the stream again.

Handle HTTP errors detected when a stream is created

Error type Recommendation
400 errors When you see HTTP 400 errors, you should not fall back to the raw streams, as the client likely experienced an error in these instances. Make sure that the request you're sending to the server is correct and contains all of the required parameters.
500 errors When you see HTTP 500 errors, you should fall back to the raw backup stream, without monetization. In the IMA SDK, these errors can be caught with an error handler, and the default stream can be switched to the backup stream.
See an example of how to handle an error with the IMA SDK

TVOS

static NSString *const kBackupContentPath =
@"http://googleimadev‑vh.akamaihd.net/i/big_buck_bunny/bbb‑,480p,720p,1080p,.mov.csmil/"
@"master.m3u8";

- (void)streamManager:(IMAStreamManager *)streamManager
didReceiveError:(NSError *)error {
NSLog(@"Error: %@", error);
[self playBackupStream];
}

- (void)playBackupStream {
NSURL *contentURL = [NSURL URLWithString:kBackupContentPath];
self.playerViewController.player = [[AVPlayer alloc] initWithURL:contentURL];
[self.playerViewController.player play];
}

Get the backup stream URL for a video on demand (VOD) or live linear stream

Your app should have a mechanism to get the backup URL for both VOD and live linear streams. In the case of VOD, the backup stream should be the ingestURL that is provided in the MRSS feed. For live linear, the backup stream should be the content stream specified in the Ad Manager UI.

Handle HTTP errors while the stream is running

If you encounter an error while the stream is running, it is not recommended that you fall back to the raw stream. Ad Manager automatically attempts to correct most of the errors that it encounters. However, in cases where the server is not able to handle an error, the stream stops playing. If the steam stops, the app should initiate a new stream. If the error persists, you should then fall back to the raw stream.

Was this helpful?
How can we improve it?