# Audio
$ffplay-fs16le-ar48k-afaformat=channel_layouts=mono\/tmp/test_output_audio.pcm
# Video## `video_size` must match the resolution in the video filename (320x180 in# this example).
$ffplay-frawvideo-pixel_formatyuv420p-video_size320x180\/tmp/test_output_video_0_320x180.yuv
选项
运行示例时,您可以指定以下选项:
选项
说明
--output_file_prefix PREFIX
指定输出文件的前缀。默认为 /tmp_test_output_。
--collection_duration DURATION
指定收集媒体的时长。默认为 30s。
--join_timeout TIMEOUT
指定等待应用加入会议的时长。默认为 2m。
--meet_api_url URL
指定 Meet Media API 的网址。默认为 https://meet.googleapis.com/v2alpha/。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Meet Media API: C++ reference client quickstart\n\n| **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features. \n|\n| **To use the Meet Media API to access real-time media from a conference, the Google Cloud project, OAuth principal, and all participants in the conference must be enrolled in the Developer Preview Program.**\n\nThis page explains how to set up and run a sample using the [C++ reference\nclient\nimplementation](https://github.com/googleworkspace/meet-media-api-samples). To\nlearn about the TypeScript client instead, see the [TypeScript reference client\nquickstart](/workspace/meet/media-api/guides/ts).\n\nPrerequisites\n-------------\n\nTo run this quickstart, you need the following prerequisites:\n\n- You've cloned the [GitHub\n repository](https://github.com/googleworkspace/meet-media-api-samples).\n- [Bazel 7.4.1](https://bazel.build/versions/7.4.0/install/ubuntu).\n- [A Google Cloud project](/workspace/guides/create-project) with Google Meet REST API enabled.\n- A Google Workspace account.\n\n### Enable the Meet REST API\n\nBefore using Google APIs, you need to turn them on in a Google Cloud project. You can turn on one or more APIs in a single Google Cloud project. \n\n### Google Cloud console\n\n1. In the Google Cloud console, enable the Meet REST API.\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=meet.googleapis.com)\n2. Confirm that you're enabling the Meet REST API in the correct\n Cloud project, then click **Next**.\n\n3. Confirm that you're enabling the Meet REST API, then click\n **Enable**.\n\n### gcloud CLI\n\n1. If necessary, set the current Cloud project to the one you\n created:\n\n gcloud config set project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the **Project ID** of the\n Cloud project you created.\n2. Enable the Meet REST API:\n\n gcloud services enable meet.googleapis.com\n\nBuild the C++ client\n--------------------\n\n1. The C++ implementation is built with [Bazel](https://bazel.build/). However,\n the C++ WebRTC library (*libwebrtc* ) doesn't have a working Bazel build, so\n you must build that library first by following the instructions at [WebRTC\n docs](https://webrtc.github.io/webrtc-org/native-code/development/).\n\n The following is an abbreviated version of what's explained in the\n [WebRTC docs](https://webrtc.github.io/webrtc-org/native-code/development/): \n\n $ cd ~\n $ mkdir src\n $ cd src\n $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git\n $ export PATH=~/src/depot_tools:$PATH\n $ mkdir webrtc-checkout\n $ cd webrtc-checkout\n $ fetch --nohooks webrtc\n $ cd src\n $ # Latest known version to work with our builds\n $ git checkout b00c469cad3f8c926fcf81ded90b90b6e1e62b9c\n $ cd ..\n $ gclient sync\n $ mv src webrtc\n $ cd webrtc\n $ ./build/install-build-deps.sh\n $ gn gen out/Default --args='is_debug=false use_custom_libcxx=false rtc_include_tests=false rtc_build_examples=false dcheck_always_on=true rtc_use_x11=false use_rtti=true'\n $ ninja -C out/Default\n\n \u003e **Note** : Commit `b00c469cad3f8c926fcf81ded90b90b6e1e62b9c` is the\n \u003e latest known version to work with our builds due to toolchain and abseil\n \u003e updates. This might change in the future. This set of commands works now,\n \u003e but the provided link should be referred to in case the underlying tooling\n \u003e changes. If you're building for a non-x64 Debian or Ubuntu Linux variant,\n \u003e your prerequisite setup might be different.\n2. After building *libwebrtc* , update your `WORKSPACE` file to point to your\n `webrtc-checkout` directory. Update the `webrtc_path` path near the top of\n that file:\n\n webrtc_path = \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-s2\"\u003e\"/usr/local/myuser/webrtc-checkout/\"\u003c/span\u003e \u003c/var\u003e\n\n3. Use Bazel to build the C++ client:\n\n $ bazel build //cpp/...\n\n\u003e **Note** : You should be using Bazel 7.4.1. If you have newer versions of\n\u003e Bazel installed, you can run it by using `bazel-7.4.1 build/run/test ...`\n\n1. Optionally, run the tests:\n\n $ bazel test //cpp/...\n\nGenerate OAuth tokens\n---------------------\n\nTo connect to the Meet Media API, your app must use OAuth to generate\naccess tokens. To learn more about accessing Google APIs with OAuth, see [*Using\nOAuth 2.0 to Access Google APIs*](/identity/protocols/oauth2).\n\nYou can use the [OAuth 2.0\nPlayground](https://developers.google.com/oauthplayground) to generate tokens.\nWhen using the playground, make sure to:\n\n- Use your client ID and secret credentials from your cloud project.\n- Request the correct [scopes](/workspace/meet/media-api/guides/get-started#scopes).\n- Sign in to a Google Account and accept access.\n\nOnce complete, click the `Exchange authorization code for tokens` button and\ncopy the generated access token.\n\nStart a meeting\n---------------\n\n[Start a meeting](https://meet.google.com/new) using the same user account that\nyou used to generate the OAuth token. Copy the meeting code. You're now ready to\nrun the samples.\n\nSample apps\n-----------\n\nThe [GitHub\nrepository](https://github.com/googleworkspace/meet-media-api-samples) offers\nsamples for receiving media and participant metadata from a meeting.\n\nThese samples collect data for a specified amount of time (default is 3 seconds)\nand write the collected data to files.\n\nAudio files are in PCM16 format. Video files are in YUV420p format. These files\ncan be played by using a library such as FFmpeg.\n\nBecause video resolutions might change during a meeting, samples include the\nresolution in video file names.\n\nParticipant metadata files will be human-readable text files.\n\n### Single User Media Sample\n\nThe single user media sample is a basic app that focuses on collecting audio and\nvideo. The sample doesn't determine which participant created the audio and\nvideo data. Therefore, using this sample in a meeting with more than one\nparticipant might result in corrupted output.\n\nTo run the single user media sample, run: \n\n### Linux\n\n $ bazel run cpp/samples:single_user_media_sample -- \\\n --meeting_space_id \u003cvar translate=\"no\"\u003eMEETING_SPACE_ID\u003c/var\u003e \\\n --oauth_token \u003cvar translate=\"no\"\u003eOAUTH_TOKEN\u003c/var\u003e\n\nBy default, a single audio file is saved to `/tmp/test_output_audio.pcm`.\n\nBecause video streams might change resolutions during a meeting, multiple video\nfiles might be created. Video file names will include an incrementing counter\nand the resolution for that file. For example, if the video stream resolution\nchanged from 320x180 to 240x135 and then back to 320x180, the following video\nfiles would be created:\n\n- `/tmp/test_output_video_0_320x180.pcm`\n- `/tmp/test_output_video_1_240x135.pcm`\n- `/tmp/test_output_video_2_320x180.pcm`\n\n### (Optional) Use FFmpeg to Play Output Files on Linux and Mac\n\n[FFmpeg](https://www.ffmpeg.org/) can be used to play created audio and video\nfiles. Example commands: \n\n### Linux \\& Mac\n\n # Audio\n $ ffplay -f s16le -ar 48k -af aformat=channel_layouts=mono \\\n /tmp/test_output_audio.pcm\n\n # Video\n #\n # `video_size` must match the resolution in the video filename (320x180 in\n # this example).\n $ ffplay -f rawvideo -pixel_format yuv420p -video_size 320x180 \\\n /tmp/test_output_video_0_320x180.yuv\n\n### Options\n\nYou can specify these options when running the samples:\n\n| Option | Description |\n|------------------------------------------------------------|-------------------------------------------------------------------------------------------------|\n| `--output_file_prefix `\u003cvar translate=\"no\"\u003ePREFIX\u003c/var\u003e | Specify the prefix for output files. Defaults to `/tmp_test_output_`. |\n| `--collection_duration `\u003cvar translate=\"no\"\u003eDURATION\u003c/var\u003e | Specify how long to collect media. Defaults to `30s`. |\n| `--join_timeout `\u003cvar translate=\"no\"\u003eTIMEOUT\u003c/var\u003e | Specify how long to wait for the app to join the conference. Defaults to `2m`. |\n| `--meet_api_url `\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e | Specify the URL for the Meet Media API API. Defaults to `https://meet.googleapis.com/v2alpha/`. |\n\nRelated topics\n--------------\n\n- [Troubleshoot and fix Meet Media API errors](/workspace/meet/media-api/guides/troubleshoot)\n\n- [Meet Media API data channels reference](/workspace/meet/media-api/reference/dc/media_api)"]]