## Overview

The WebRTC Validator Tool is a web-based tool that aims to emulate the WebRTC
player available on Google Smart Displays with Google Assistant.
This web application leverages the
[WebRTC API](https://www.w3.org/TR/webrtc/#peer-to-peer-connections) available
within modern browsers. More generally, the WebRTC Validator Tool is a WebRTC
[peer](https://www.w3.org/TR/webrtc/) you can stream from or to.

[Go to the WebRTC Validator Tool](https://smarthome-webrtc-validator.withgoogle.com/)
![Overview image of WebRTC Validator Tool.](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-overview.png)

## Customize STUN/TURN Server

The WebRTC Validator Tool by default uses the Google STUN server. The WebRTC
Validator Tool can use a user-defined STUN/TURN server.
![STUN/TURN server selection box.](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-stun-box.png)

#### Adding a STUN/TURN Server

1. Place the address of the STUN or TURN server in the **STUN** **or** **TURN** **URI** text box. Ensure the URI scheme is in the following format `scheme:host:[port]`. By default the tool uses `stun:stun.l.google.com:19302`
2. (Optional) If you are using a TURN server, you will be required to enter the credentials into the **TURN Username** \& **Turn Password** text box.
3. Click **Add Server** to add the server details to the tool.

The STUN/TURN servers will be used in the order they appear in the list.

#### Removing a STUN/TURN Server

1. Select the STUN/TURN server you wish to remove.
2. Click **Remove Server**.

The tool will use `stun:stun.l.google.com:19302` if no other
STUN/TURN server(s) are specified.

## Enable/Disable Sending of Audio

1. The tool by default sends audio as part of the WebRTC stream. If you wish to disable the sending of audio, uncheck the **Enable Audio** check box.

![Audio Checkbox](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-audio-checkbox.png)

## Submit Button

Once you have confirmed you STUN/TURN server(s) and Audio preferences click
**Submit**.
![Submit Button](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-buttons.png)

> [!NOTE]
> **Note:**The WebRTC Validator Tool will require access to your local webcam device and microphone. You will be required to allow access to use the tool.

![Camera Permission Dialog](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-camera-permission.png)

The video input from your webcam will be displayed in the Local Video Element.

## Create Offer SDP

1. Click **Create Offer SDP** to generate an Offer SDP. The Offer JSON will be formatted in the following format:

   ```
   {
   "action": "offer",
   "sdp": "o=- 4611731400430051336 2 IN IP4 127.0.0.1..."
   }
   ```

2.The Offer SDP can now be passed to a WebRTC peer. This could be
your
[Google Smart Home WebRTC agent](https://developers.home.google.com/cloud-to-cloud/traits/camerastream.md.txt)
or the WebRTC Validator Tool running on another browser.

## Submit Answer SDP

1. Place the Answer JSON in the Answer SDP text box and click **Submit Answer
   SDP**. The Answer JSON must be in the following format:

   ```
   {
   "action": "answer",
   "sdp": "o=- 4611731400430051336 2 IN IP4 127.0.0.1..."
   }
   ```
2. If the Answer SDP is valid then the video (and audio) from the remote source
   will be visible in the Remote Video Element.

## Debugging WebRTC

It is highly recommended that the WebRTC Validator Tool is used with a Chrome
browser
([ver. 87](https://www.google.com/url?sa=D&q=https://chromestatus.com/features%23milestone%253D87)
or higher). Tools within the Chrome browser will be able to help debug your
WebRTC stream.

#### Webrtc-Internals Page

1. Open a new tab in your Chrome browser
2. Visit the following address `chrome://webrtc-internals`

![WebRTC Inspect Window](https://developers.home.google.com/static/tools/images/webrtc-validator-tool-chrome-webrtc-inspect.png)

This page displays all the active on-going WebRTC connections. The statistics
and metrics generated on this page are gathered from the
[getStats() API](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats).

#### Chrome Developer Tools

The [Chrome Developer Tools](https://developer.chrome.com/docs/devtools/) will
also be helpful to troubleshoot any issues with the WebRTC stream. It is highly
recommended to open the
[Console](https://developer.chrome.com/docs/devtools/console/log/) before using
the WebRTC Validator Tool.