[null,null,["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eServer Guided Ad Insertion (SGAI) requires Pod Serving DAI to be enabled in your Google Ad Manager network, allowing for the creation and retrieval of ad metadata and ad pod manifests via Pod serving API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eAd pod manifest URLs can be generated and inserted into your content stream using a manifest manipulation server, or alternatively, your app can trigger ad breaks based on events such as user interaction or push notifications.\u003c/p\u003e\n"],["\u003cp\u003eBefore generating ad pod manifest URLs, it's recommended to utilize the Early Ad Break Notification (EABN) API to specify ad break parameters, especially for production and test streams with programmatic campaigns.\u003c/p\u003e\n"],["\u003cp\u003eUpon a user initiating a content stream, a stream registration request with targeting parameters is required to create a streaming session on Ad Manager, which will then return response data including metadata and polling frequency.\u003c/p\u003e\n"],["\u003cp\u003eAfter making a stream registration, use the provided \u003ccode\u003epolling_frequency\u003c/code\u003e to poll for ad metadata and generate the ad pod manifest URL, which is then passed to a video player to start loading the ad pod, and remember to report impressions and ad events by listening to ad events and sending media verification pings.\u003c/p\u003e\n"]]],[],null,["# Get started with SGAI for livestream\n\nServer guided ad insertion (SGAI) provides an ad pod manifest ready for\nstitching on client devices. If you have enabled Pod Serving DAI in your Google\nAd Manager network, you have access to use SGAI. If you don't have Pod Serving\nDAI enabled, contact your account manager.\n\nWith SGAI, you use the Pod serving API endpoints for creating a stream\nretrieving ad metadata and the ad pod manifests.\n\nIf you have a manifest manipulation server, you can generate the ad pod\nmanifest URLs and insert ad markers that carry the ad pod manifest information\nin your content stream, according to your preferred specification.\n\nAlternatively, you can schedule an ad break using a different mechanism other\nthan the ad markers in the stream manifest. In these cases, your app can listen\nto other events, for example, user interaction with the stream, the app itself,\nor a push notification. After these events, the app can generate the ad\npod manifest URLs and tell the player to begin loading the ad pod manifest.\n\nPrerequisites\n-------------\n\nBefore continuing, ensure you have the following:\n\n- The DAI Pod serving enabled on your Google Ad Manager network.\n- A livestream event with type **Pod serving manifest** . To create the event, see [Set up a livestream for DAI](//support.google.com/admanager/answer/7294289).\n\n### Follow recommendations\n\nBefore you\n[generate the ad pod manifest URL](#generate-ad-pod-manifest-url), we recommend\nyou call the\n[Early Ad Break Notification (EABN) API](/ad-manager/dynamic-ad-insertion/api/eabn)\nto specify the expected duration, targeting information, and other\nparameters of each ad break.\n\nFor production and test streams, call the EABN API, especially if your ad\nnetwork has any programmatic campaigns. For more information, see\n[Features and guidelines for Programmatic Direct](//support.google.com/admanager/answer/9345607).\n\nMake a stream registration request\n----------------------------------\n\nWhen a user starts a content stream in your video player app, you make a stream\nregistration request with targeting parameters to create a streaming session\non Ad Manager. For details on making a stream registration request, see\n[Method:stream](/ad-manager/dynamic-ad-insertion/api/pod-serving/reference/live#method_stream).\nAfterwards, you receive\n[response data](/ad-manager/dynamic-ad-insertion/api/pod-serving/reference/live#stream)\nfrom the request.\n\nThe following examples make a stream registration request: \n\n### Plain text HTTP\n\n- Request:\n\n authority: dai.google.com\n method: POST\n path: /ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream\n scheme: https\n content-type: application/x-www-form-urlencoded\n\n cust_params=customID%253D1543216789%2526anotherKey%253Dvalue1%252Cvalue2\n\n- Response:\n\n {\n \"manifest_format\": \"hls\",\n \"media_verification_url\": \"https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/\",\n \"metadata_url\": \"https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata\",\n \"polling_frequency\": 10,\n \"session_update_url\": \"https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session\",\n \"stream_id\": \"24fd4e7c-95a0-42be-8874-00625139b9db:TUL\"\n }\n\n### Shell\n\n- Command line:\n\n curl \\\n -H \"Host: dai.google.com\" \\\n -H \"content-type: application/x-www-form-urlencoded\" \\\n --data-binary \"cust_params=channelID%253D1543216789%2526anotherKey%253Dvalue1%252Cvalue2\" \\\n --compressed \"https://dai.google.com/ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream\"\n\n- Output:\n\n {\n \"manifest_format\": \"hls\",\n \"media_verification_url\": \"https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/\",\n \"metadata_url\": \"https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata\",\n \"pod_manifest_url\": \"https://dai.google.com/linear/pods/v1/hls/event/TFyZF0IoSpqvCLtLv8JdCw/pod/$pod-id$.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db%3ATUL\",\n \"polling_frequency\": 10,\n \"session_update_url\": \"https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session\",\n \"stream_id\": \"24fd4e7c-95a0-42be-8874-00625139b9db:TUL\"\n }\n\n### Javascript\n\n- Using Fetch API:\n\n const response = await fetch(\"https://dai.google.com/ssai/pods/api/v1/network/51636543/custom_asset/hls-podserving-manifest/stream\", {\n \"headers\": {\n \"content-type\": \"application/x-www-form-urlencoded\",\n },\n \"body\": \"cust_params=channelID%3D1543216789%26anotherKey%3Dvalue1%2Cvalue2\",\n \"method\": \"POST\",\n });\n\n const stream = await response.json();\n console.log(stream);\n\n- Console log:\n\n {\n \"stream_id\": \"24fd4e7c-95a0-42be-8874-00625139b9db:TUL\",\n \"media_verification_url\": \"https://dai.google.com/view/p/service/linear/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/loc/TUL/network/51636543/event/TFyZF0IoSpqvCLtLv8JdCw/media/\",\n \"metadata_url\": \"https://dai.google.com/linear/pods/hls/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/metadata\",\n \"session_update_url\": \"https://dai.google.com/linear/v1/pa/event/TFyZF0IoSpqvCLtLv8JdCw/stream/24fd4e7c-95a0-42be-8874-00625139b9db:TUL/session\",\n \"polling_frequency\": 10,\n \"pod_manifest_url\": \"https://dai.google.com/linear/pods/v1/hls/event/TFyZF0IoSpqvCLtLv8JdCw/pod/$pod-id$.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db%3ATUL\",\n \"manifest_format\": \"hls\"\n }\n\nPoll for ad break metadata\n--------------------------\n\nAfter you make a stream registration request, poll for the ad metadata. To\npoll, you set a timer using the `polling_frequence` in the stream response at\nthe registration step to call the ad\n[metadata](/ad-manager/dynamic-ad-insertion/api/pod-serving/reference/live#method_metadata).\nFor each poll, you might receive a partial list of ads with metadata as they\nbecome available.\n\nGenerate the ad pod manifest URL\n--------------------------------\n\nConstruct a URL for the\n[pod resource](/ad-manager/dynamic-ad-insertion/api/pod-serving/reference/live#method_pod_manifest)\nof the Pod Serving API. Afterwards, pass the URL to a video player to start\nloading the ad pod.\n\nThe following example demonstrates the structure of the ad pod manifest URL: \n\n https://dai.google.com/linear/pods/v1/hls/network/51636543/custom_asset/pod_serving_hls_manifest_mp4/ad_break_id/ab101.m3u8?stream_id=24fd4e7c-95a0-42be-8874-00625139b9db:TUL&pd=120000\n\n| **Note:** The ad break parameters, such as `ad_break_id`, `duration`, `cust_params` and `scte35` must be the same for all clients watching the same livestream, while the stream ID is unique for each client. If you choose to generate the ad pod manifest URL on the server side and insert the generated URLs in the stream manifest, follow your manifest manipulator server documentation on sending the stream ID from the clients and generate the other ad break parameters.\n\nYou can calculate the ad pod manifest URL parameters based on the ad break\ninformation retrieved from the video player or a server notification. For\nrequirements of these parameters, see\n[Method: pod manifest](/ad-manager/dynamic-ad-insertion/api/pod-serving/reference/live#method_pod_manifest).\n\nPlay the ad pod manifest\n------------------------\n\nOn the client video player app, begin content stream playback with a primary\nvideo player and follow your video player's documentation on observing the\nplayback and ad schedule, if relevant.\n\nIf you generate the ad pod manifest URLs and insert those in the manifest on the\nserver side, observe the video player's upcoming ad break events, and ensure to\nsubscribe to id3 events during each ad break playback. If you schedule the ad\nbreak events from the client side, subscribe to the id3 events on creation.\n\nReport impressions and ad events\n--------------------------------\n\nWhen a video player plays the ad pod and encounters id3 timed metadata,\n[listen to ad events](/ad-manager/dynamic-ad-insertion/api/pod-serving/live/client#listen_for_ad_events)\nthat the video player triggers and process them to\n[send media verification pings](/ad-manager/dynamic-ad-insertion/api/pod-serving/live/client#send_media_verification_pings).\n| **Important:** Don't delay the ping to the media verification URL. We recommend you ping immediately and not longer than one minute."]]