# webrtc/samples architecture

> Architecture diagram of the GitHub repository webrtc/samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/webrtc/samples
- Repository: https://github.com/webrtc/samples

## Overview

WebRTC Code Samples is a browser-based collection of independent JavaScript demonstrations, not one integrated application. A user opens a sample and exercises a specific browser media or networking capability; the result is a live stream, peer connection, data-channel exchange, or processing effect. The graph groups the major sample families and highlights the internal video-processing pipeline where the excerpts show actual orchestration. Most samples are independent, so no links between them are inferred. The README establishes how users access the samples; unsampled implementations are represented by their existing directories.

Main entry points: [`src/content/insertable-streams/video-processing/js/pipeline.js`](https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/video-processing/js/pipeline.js) (Video Pipeline), [`src/content/peerconnection`](https://github.com/webrtc/samples/tree/gh-pages/src/content/peerconnection) (Connection Controls), [`src/content/peerconnection/perfect-negotiation/js/peer.js`](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/perfect-negotiation/js/peer.js) (Peer Negotiation), [`src/content`](https://github.com/webrtc/samples/tree/gh-pages/src/content) (Sample Collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Media Capture"]
  node_getusermedia["Media Acquisition"]
  node_capture_samples["Canvas and Video Capture"]
end

subgraph group_peer["Peer Connections"]
  node_peer_negotiation["Peer Negotiation<br/>[peer.js]"]
  node_peer_controls["Connection Controls"]
  node_peer_media["Media Connections<br/>[main.js]"]
  node_bandwidth["Bandwidth and Stats<br/>[main.js]"]
  node_negotiation_timing["Negotiation Timing<br/>[main.js]"]
  node_ice_gathering["ICE Gathering<br/>[main.js]"]
end

subgraph group_data["Data Channels"]
  node_datachannel_samples["Data Channel Samples"]
  node_messaging["Channel Messaging<br/>[main.js]"]
end

subgraph group_processing["Stream Processing"]
  node_insertable_streams["Insertable Streams"]
  node_video_pipeline["Video Pipeline<br/>[pipeline.js]"]
  node_webgpu["WebGPU Processing"]
  node_encryption["End-to-End Encryption<br/>[main.js]"]
end

subgraph group_devices["Devices and Extensions"]
  node_devices["Device Selection"]
  node_svc["Scalable Video Coding<br/>[main.js]"]
end

node_user(("Browser User"))
node_sample_collection["Sample Collection"]

node_user -->|"opens samples"| node_sample_collection
node_video_pipeline -->|"starts source, transform, and sink"| node_video_pipeline
node_video_pipeline -->|"passes processed stream"| node_video_pipeline
node_peer_controls -->|"delegates negotiation"| node_peer_negotiation

click node_sample_collection "https://github.com/webrtc/samples/tree/gh-pages/src/content"
click node_getusermedia "https://github.com/webrtc/samples/tree/gh-pages/src/content/getusermedia"
click node_capture_samples "https://github.com/webrtc/samples/tree/gh-pages/src/content/capture"
click node_peer_negotiation "https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/perfect-negotiation/js/peer.js"
click node_peer_controls "https://github.com/webrtc/samples/tree/gh-pages/src/content/peerconnection"
click node_peer_media "https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/audio/js/main.js"
click node_bandwidth "https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/bandwidth/js/main.js"
click node_negotiation_timing "https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/negotiate-timing/js/main.js"
click node_ice_gathering "https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/trickle-ice/js/main.js"
click node_datachannel_samples "https://github.com/webrtc/samples/tree/gh-pages/src/content/datachannel"
click node_messaging "https://github.com/webrtc/samples/blob/gh-pages/src/content/datachannel/messaging/main.js"
click node_insertable_streams "https://github.com/webrtc/samples/tree/gh-pages/src/content/insertable-streams"
click node_video_pipeline "https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/video-processing/js/pipeline.js"
click node_webgpu "https://github.com/webrtc/samples/tree/gh-pages/src/content/insertable-streams/webgpu"
click node_encryption "https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/endtoend-encryption/js/main.js"
click node_devices "https://github.com/webrtc/samples/tree/gh-pages/src/content/devices"
click node_svc "https://github.com/webrtc/samples/blob/gh-pages/src/content/extensions/svc/js/main.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_getusermedia,node_capture_samples,node_user toneBlue
class node_peer_negotiation,node_peer_controls,node_peer_media,node_bandwidth,node_negotiation_timing,node_ice_gathering toneAmber
class node_datachannel_samples,node_messaging toneMint
class node_insertable_streams,node_video_pipeline,node_webgpu,node_encryption toneRose
class node_devices,node_svc toneIndigo
class node_sample_collection toneTeal
```

## Components

### Media Capture

- [Media Acquisition](https://github.com/webrtc/samples/tree/gh-pages/src/content/getusermedia): `src/content/getusermedia`
- [Canvas and Video Capture](https://github.com/webrtc/samples/tree/gh-pages/src/content/capture): `src/content/capture`

### Peer Connections

- [Peer Negotiation](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/perfect-negotiation/js/peer.js): `src/content/peerconnection/perfect-negotiation/js/peer.js`
- [Connection Controls](https://github.com/webrtc/samples/tree/gh-pages/src/content/peerconnection): `src/content/peerconnection`
- [Media Connections](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/audio/js/main.js): `src/content/peerconnection/audio/js/main.js`
- [Bandwidth and Stats](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/bandwidth/js/main.js): `src/content/peerconnection/bandwidth/js/main.js`
- [Negotiation Timing](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/negotiate-timing/js/main.js): `src/content/peerconnection/negotiate-timing/js/main.js`
- [ICE Gathering](https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/trickle-ice/js/main.js): `src/content/peerconnection/trickle-ice/js/main.js`

### Data Channels

- [Data Channel Samples](https://github.com/webrtc/samples/tree/gh-pages/src/content/datachannel): `src/content/datachannel`
- [Channel Messaging](https://github.com/webrtc/samples/blob/gh-pages/src/content/datachannel/messaging/main.js): `src/content/datachannel/messaging/main.js`

### Stream Processing

- [Insertable Streams](https://github.com/webrtc/samples/tree/gh-pages/src/content/insertable-streams): `src/content/insertable-streams`
- [Video Pipeline](https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/video-processing/js/pipeline.js): `src/content/insertable-streams/video-processing/js/pipeline.js`
- [WebGPU Processing](https://github.com/webrtc/samples/tree/gh-pages/src/content/insertable-streams/webgpu): `src/content/insertable-streams/webgpu`
- [End-to-End Encryption](https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/endtoend-encryption/js/main.js): `src/content/insertable-streams/endtoend-encryption/js/main.js`

### Devices and Extensions

- [Device Selection](https://github.com/webrtc/samples/tree/gh-pages/src/content/devices): `src/content/devices`
- [Scalable Video Coding](https://github.com/webrtc/samples/blob/gh-pages/src/content/extensions/svc/js/main.js): `src/content/extensions/svc/js/main.js`

### Other components

- **Browser User**
- [Sample Collection](https://github.com/webrtc/samples/tree/gh-pages/src/content): `src/content`

## Connections

- Browser User → Sample Collection: opens samples
- Video Pipeline → Video Pipeline: starts source, transform, and sink (evidence: `src/content/insertable-streams/video-processing/js/pipeline.js`)
- Video Pipeline → Video Pipeline: passes processed stream (evidence: `src/content/insertable-streams/video-processing/js/pipeline.js`)
- Connection Controls → Peer Negotiation: delegates negotiation (evidence: `src/content/peerconnection/perfect-negotiation/js/main.js`)
