[
  {
    "path": ".github/.ci.conf",
    "content": "# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nGO_MOD_VERSION_EXPECTED=1.24\nSKIP_API_DIFF=true\n"
  },
  {
    "path": ".github/.gitignore",
    "content": "# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\n.goassets\n"
  },
  {
    "path": ".github/fetch-scripts.sh",
    "content": "#!/bin/sh\n\n#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nset -eu\n\nSCRIPT_PATH=\"$(realpath \"$(dirname \"$0\")\")\"\nGOASSETS_PATH=\"${SCRIPT_PATH}/.goassets\"\n\nGOASSETS_REF=${GOASSETS_REF:-main}\n\nif [ -d \"${GOASSETS_PATH}\" ]; then\n  if ! git -C \"${GOASSETS_PATH}\" diff --exit-code; then\n    echo \"${GOASSETS_PATH} has uncommitted changes\" >&2\n    exit 1\n  fi\n  git -C \"${GOASSETS_PATH}\" fetch origin\n  git -C \"${GOASSETS_PATH}\" checkout ${GOASSETS_REF}\n  git -C \"${GOASSETS_PATH}\" reset --hard origin/${GOASSETS_REF}\nelse\n  git clone -b ${GOASSETS_REF} https://github.com/pion/.goassets.git \"${GOASSETS_PATH}\"\nfi\n"
  },
  {
    "path": ".github/install-hooks.sh",
    "content": "#!/bin/sh\n\n#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nSCRIPT_PATH=\"$(realpath \"$(dirname \"$0\")\")\"\n\n. ${SCRIPT_PATH}/fetch-scripts.sh\n\ncp \"${GOASSETS_PATH}/hooks/commit-msg.sh\" \"${SCRIPT_PATH}/../.git/hooks/commit-msg\"\ncp \"${GOASSETS_PATH}/hooks/pre-commit.sh\" \"${SCRIPT_PATH}/../.git/hooks/pre-commit\"\n"
  },
  {
    "path": ".github/pion-gopher-webrtc.png.license",
    "content": "SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\nSPDX-License-Identifier: MIT"
  },
  {
    "path": ".github/plot.png.license",
    "content": "SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\nSPDX-License-Identifier: MIT"
  },
  {
    "path": ".github/workflows/api.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: API\non:\n  pull_request:\n\njobs:\n  check:\n    uses: pion/.goassets/.github/workflows/api.reusable.yml@main\n"
  },
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: CodeQL\n\non:\n  workflow_dispatch:\n  schedule:\n    - cron: '23 5 * * 0'\n  pull_request:\n    branches:\n      - main\n    paths:\n      - '**.go'\n\njobs:\n  analyze:\n    uses: pion/.goassets/.github/workflows/codeql-analysis.reusable.yml@main\n"
  },
  {
    "path": ".github/workflows/fuzz.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Fuzz\non:\n  push:\n    branches:\n      - main\n  schedule:\n    - cron: \"0 */8 * * *\"\n\njobs:\n  fuzz:\n    uses: pion/.goassets/.github/workflows/fuzz.reusable.yml@main\n    with:\n      go-version: \"1.25\" # auto-update/latest-go-version\n      fuzz-time: \"60s\"\n"
  },
  {
    "path": ".github/workflows/lint.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Lint\non:\n  pull_request:\n\njobs:\n  lint:\n    uses: pion/.goassets/.github/workflows/lint.reusable.yml@main\n    with:\n      golangci-lint-version: v2.10.1\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Release\non:\n  push:\n    tags:\n      - 'v*'\n\njobs:\n  release:\n    uses: pion/.goassets/.github/workflows/release.reusable.yml@main\n    with:\n      go-version: \"1.25\" # auto-update/latest-go-version\n"
  },
  {
    "path": ".github/workflows/renovate-go-sum-fix.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Fix go.sum\non:\n  push:\n    branches:\n      - renovate/*\n\njobs:\n  fix:\n    uses: pion/.goassets/.github/workflows/renovate-go-sum-fix.reusable.yml@main\n    secrets:\n      token: ${{ secrets.PIONBOT_PRIVATE_KEY }}\n"
  },
  {
    "path": ".github/workflows/reuse.yml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: REUSE Compliance Check\n\non:\n  push:\n  pull_request:\n\njobs:\n  lint:\n    uses: pion/.goassets/.github/workflows/reuse.reusable.yml@main\n"
  },
  {
    "path": ".github/workflows/test.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Test\non:\n  push:\n    branches:\n      - main\n  pull_request:\n\njobs:\n  test:\n    uses: pion/.goassets/.github/workflows/test.reusable.yml@main\n    strategy:\n      matrix:\n        go: [\"1.25\", \"1.24\"] # auto-update/supported-go-version-list\n      fail-fast: false\n    with:\n      go-version: ${{ matrix.go }}\n    secrets: inherit\n\n  test-i386:\n    uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@main\n    strategy:\n      matrix:\n        go: [\"1.25\", \"1.24\"] # auto-update/supported-go-version-list\n      fail-fast: false\n    with:\n      go-version: ${{ matrix.go }}\n\n  test-windows:\n    uses: pion/.goassets/.github/workflows/test-windows.reusable.yml@main\n    strategy:\n      matrix:\n        go: [\"1.25\", \"1.24\"] # auto-update/supported-go-version-list\n      fail-fast: false\n    with:\n      go-version: ${{ matrix.go }}\n\n  test-macos:\n    uses: pion/.goassets/.github/workflows/test-macos.reusable.yml@main\n    strategy:\n      matrix:\n        go: [\"1.25\", \"1.24\"] # auto-update/supported-go-version-list\n      fail-fast: false\n    with:\n      go-version: ${{ matrix.go }}\n\n  test-wasm:\n    uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@main\n    with:\n      go-version: \"1.25\" # auto-update/latest-go-version\n    secrets: inherit\n"
  },
  {
    "path": ".github/workflows/tidy-check.yaml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n# If this repository should have package specific CI config,\n# remove the repository name from .goassets/.github/workflows/assets-sync.yml.\n#\n# If you want to update the shared CI config, send a PR to\n# https://github.com/pion/.goassets instead of this repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nname: Go mod tidy\non:\n  pull_request:\n  push:\n    branches:\n      - main\n\njobs:\n  tidy:\n    uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@main\n    with:\n      go-version: \"1.25\" # auto-update/latest-go-version\n"
  },
  {
    "path": ".gitignore",
    "content": "# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\n### JetBrains IDE ###\n#####################\n.idea/\n\n### Emacs Temporary Files ###\n#############################\n*~\n\n### Folders ###\n###############\nbin/\nvendor/\nnode_modules/\n\n### Files ###\n#############\n*.ivf\n*.ogg\ntags\ncover.out\n*.sw[poe]\n*.wasm\nexamples/sfu-ws/cert.pem\nexamples/sfu-ws/key.pem\nwasm_exec.js\n"
  },
  {
    "path": ".golangci.yml",
    "content": "# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nversion: \"2\"\nlinters:\n  enable:\n    - asciicheck       # Simple linter to check that your code does not contain non-ASCII identifiers\n    - bidichk          # Checks for dangerous unicode character sequences\n    - bodyclose        # checks whether HTTP response body is closed successfully\n    - containedctx     # containedctx is a linter that detects struct contained context.Context field\n    - contextcheck     # check the function whether use a non-inherited context\n    - cyclop           # checks function and package cyclomatic complexity\n    - decorder         # check declaration order and count of types, constants, variables and functions\n    - dogsled          # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())\n    - dupl             # Tool for code clone detection\n    - durationcheck    # check for two durations multiplied together\n    - err113           # Golang linter to check the errors handling expressions\n    - errcheck         # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases\n    - errchkjson       # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.\n    - errname          # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.\n    - errorlint        # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.\n    - exhaustive       # check exhaustiveness of enum switch statements\n    - forbidigo        # Forbids identifiers\n    - forcetypeassert  # finds forced type assertions\n    - gochecknoglobals # Checks that no globals are present in Go code\n    - gocognit         # Computes and checks the cognitive complexity of functions\n    - goconst          # Finds repeated strings that could be replaced by a constant\n    - gocritic         # The most opinionated Go source code linter\n    - gocyclo          # Computes and checks the cyclomatic complexity of functions\n    - godot            # Check if comments end in a period\n    - godox            # Tool for detection of FIXME, TODO and other comment keywords\n    - goheader         # Checks is file header matches to pattern\n    - gomoddirectives  # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.\n    - goprintffuncname # Checks that printf-like functions are named with `f` at the end\n    - gosec            # Inspects source code for security problems\n    - govet            # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string\n    - grouper          # An analyzer to analyze expression groups.\n    - importas         # Enforces consistent import aliases\n    - ineffassign      # Detects when assignments to existing variables are not used\n    - lll              # Reports long lines\n    - maintidx         # maintidx measures the maintainability index of each function.\n    - makezero         # Finds slice declarations with non-zero initial length\n    - misspell         # Finds commonly misspelled English words in comments\n    - modernize        # Replace and suggests simplifications to code\n    - nakedret         # Finds naked returns in functions greater than a specified function length\n    - nestif           # Reports deeply nested if statements\n    - nilerr           # Finds the code that returns nil even if it checks that the error is not nil.\n    - nilnil           # Checks that there is no simultaneous return of `nil` error and an invalid value.\n    - nlreturn         # nlreturn checks for a new line before return and branch statements to increase code clarity\n    - noctx            # noctx finds sending http request without context.Context\n    - predeclared      # find code that shadows one of Go's predeclared identifiers\n    - revive           # golint replacement, finds style mistakes\n    - staticcheck      # Staticcheck is a go vet on steroids, applying a ton of static analysis checks\n    - tagliatelle      # Checks the struct tags.\n    - thelper          # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers\n    - unconvert        # Remove unnecessary type conversions\n    - unparam          # Reports unused function parameters\n    - unused           # Checks Go code for unused constants, variables, functions and types\n    - varnamelen       # checks that the length of a variable's name matches its scope\n    - wastedassign     # wastedassign finds wasted assignment statements\n    - whitespace       # Tool for detection of leading and trailing whitespace\n  disable:\n    - depguard         # Go linter that checks if package imports are in a list of acceptable packages\n    - funlen           # Tool for detection of long functions\n    - gochecknoinits   # Checks that no init functions are present in Go code\n    - gomodguard       # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.\n    - interfacebloat   # A linter that checks length of interface.\n    - ireturn          # Accept Interfaces, Return Concrete Types\n    - mnd              # An analyzer to detect magic numbers\n    - nolintlint       # Reports ill-formed or insufficient nolint directives\n    - paralleltest     # paralleltest detects missing usage of t.Parallel() method in your Go test\n    - prealloc         # Finds slice declarations that could potentially be preallocated\n    - promlinter       # Check Prometheus metrics naming via promlint\n    - rowserrcheck     # checks whether Err of rows is checked successfully\n    - sqlclosecheck    # Checks that sql.Rows and sql.Stmt are closed.\n    - testpackage      # linter that makes you use a separate _test package\n    - tparallel        # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes\n    - wrapcheck        # Checks that errors returned from external packages are wrapped\n    - wsl              # Whitespace Linter - Forces you to use empty lines!\n  settings:\n    staticcheck:\n      checks:\n        - all\n        - -QF1008 # \"could remove embedded field\", to keep it explicit!\n        - -QF1003 # \"could use tagged switch on enum\", Cases conflicts with exhaustive!\n    exhaustive:\n      default-signifies-exhaustive: true\n    forbidigo:\n      forbid:\n        - pattern: ^fmt.Print(f|ln)?$\n        - pattern: ^log.(Panic|Fatal|Print)(f|ln)?$\n        - pattern: ^os.Exit$\n        - pattern: ^panic$\n        - pattern: ^print(ln)?$\n        - pattern: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$\n          pkg: ^testing$\n          msg: use testify/assert instead\n      analyze-types: true\n    gomodguard:\n      blocked:\n        modules:\n          - github.com/pkg/errors:\n              recommendations:\n                - errors\n    govet:\n      enable:\n        - shadow\n    revive:\n      rules:\n        # Prefer 'any' type alias over 'interface{}' for Go 1.18+ compatibility\n        - name: use-any\n          severity: warning\n          disabled: false\n    misspell:\n      locale: US\n    varnamelen:\n      max-distance: 12\n      min-name-length: 2\n      ignore-type-assert-ok: true\n      ignore-map-index-ok: true\n      ignore-chan-recv-ok: true\n      ignore-decls:\n        - i int\n        - n int\n        - w io.Writer\n        - r io.Reader\n        - b []byte\n  exclusions:\n    generated: lax\n    rules:\n      - linters:\n          - forbidigo\n          - gocognit\n        path: (examples|main\\.go)\n      - linters:\n          - gocognit\n        path: _test\\.go\n      - linters:\n          - forbidigo\n        path: cmd\nformatters:\n  enable:\n    - gci              # Gci control golang package import order and make it always deterministic.\n    - gofmt            # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification\n    - gofumpt          # Gofumpt checks whether code was gofumpt-ed.\n    - goimports        # Goimports does everything that gofmt does. Additionally it checks unused imports\n  exclusions:\n    generated: lax\nissues:\n  max-issues-per-linter: 0\n  max-same-issues: 0"
  },
  {
    "path": ".goreleaser.yml",
    "content": "# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\nbuilds:\n- skip: true\n"
  },
  {
    "path": ".reuse/dep5",
    "content": "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\nUpstream-Name: Pion\nSource: https://github.com/pion/\n\nFiles: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples.json sfu-ws/flutter/.gitignore sfu-ws/flutter/pubspec.yaml c-data-channels/webrtc.h examples/examples.json yarn.lock\nCopyright: 2026 The Pion community <https://pion.ly>\nLicense: MIT\n\nFiles: testdata/seed/* testdata/fuzz/* **/testdata/fuzz/* api/*.txt\nCopyright: 2026 The Pion community <https://pion.ly>\nLicense: CC0-1.0\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2026 The Pion community <https://pion.ly>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "LICENSES/MIT.txt",
    "content": "MIT License\n\nCopyright (c) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\">\n  <a href=\"https://pion.ly\"><img src=\"./.github/pion-gopher-webrtc.png\" alt=\"Pion WebRTC\" height=\"250px\"></a>\n  <br>\n  WebRTC Bench\n  <br>\n</h1>\n<h4 align=\"center\">WebRTC Server that generates usage reports, Web/CLI Clients included!</h4>\n<p align=\"center\">\n  <a href=\"https://pion.ly\"><img src=\"https://img.shields.io/badge/pion-webrtc-gray.svg?longCache=true&colorB=brightgreen\" alt=\"Pion webrtc\"></a>\n  <a href=\"https://discord.gg/PngbdqpFbt\"><img src=\"https://img.shields.io/badge/join-us%20on%20discord-gray.svg?longCache=true&logo=discord&colorB=brightblue\" alt=\"join us on Discord\"></a> <a href=\"https://bsky.app/profile/pion.ly\"><img src=\"https://img.shields.io/badge/follow-us%20on%20bluesky-gray.svg?longCache=true&logo=bluesky&colorB=brightblue\" alt=\"Follow us on Bluesky\"></a>\n  <br>\n  <a href=\"LICENSE\"><img src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\"></a>\n</p>\n<br>\n\n`webrtc-bench` is a WebRTC server that plays a video file from disk, and then re-distributes via WebRTC. It generates performance metrics including CPU usage, peer connection counts, and detailed latency measurements for connection setup phases.\n\nThis repo contains a CLI WebRTC Client that will connect and perform the load test. This is done via a REST API hosted on `:8080/doSignaling`. You can also watch the video/load test via the web UI at `:8080/`,\nit connects via the same REST API as the CLI.\n\n### Running\n* `git clone https://github.com/pion/webrtc-bench.git`\n* `cd webrtc-bench/server`\n* `ffmpeg -i $INPUT_FILE -g 30 -b:v 2M input.ivf`\n* `go run main.go`\n\nYou can then access the Web UI at [http://localhost:8080](http://localhost:8080). This requires a browser that supports H264, this repo doesn't do any error handling around signaling failures.\n\nYou can also use the provided WebRTC CLI\n* `cd webrtc-bench/client`\n* `go run main.go localhost:8080`\n\n### Output Files\n\nThe benchmark generates three CSV files with performance data:\n\n#### report.csv (Server)\nSystem-level metrics collected every 3 seconds:\n```\ntimestamp, peerConnectionCount, cpuUsage, droppedLatencyMeasurements\n2020-12-15T13:59:23-08:00, 1, 17.878028, 0\n2020-12-15T13:59:26-08:00, 0, 35.101254, 0\n2020-12-15T13:59:29-08:00, 1, 12.565718, 0\n```\n\n#### server-latencies.csv (Server)\nDetailed WebRTC connection setup timing from server perspective:\n```\ntimestamp,type,latencyMs\n2026-01-02T19:33:57.714Z,signaling_processing,13.391\n2026-01-02T19:33:57.714Z,sdp_offer_processing,6.587\n2026-01-02T19:33:57.714Z,sdp_answer_creation,0.365\n2026-01-02T19:33:57.715Z,ice_gathering,0.255\n2026-01-02T19:33:57.825Z,ice_connection,122.588\n2026-01-02T19:33:57.979Z,dtls_handshake,153.612\n```\n\n**Server Metrics:**\n- `signaling_processing`: Total signaling time (offer → answer)\n- `sdp_offer_processing`: SDP offer parsing time\n- `sdp_answer_creation`: SDP answer generation time\n- `ice_gathering`: ICE candidate gathering time\n- `ice_connection`: Time from connection start to ICE connected\n- `dtls_handshake`: DTLS handshake completion time\n\n#### client-latencies.csv (Client)\nConnection setup timing from client perspective:\n```\ntimestamp,type,latencyMs\n2026-01-02T11:33:57.706Z,ice_gathering,5001.234\n2026-01-02T11:33:57.706Z,signaling_rtt,72.456\n2026-01-02T11:33:57.811Z,ice_connection,5183.789\n2026-01-02T11:33:57.916Z,dtls_handshake,104.123\n2026-01-02T11:33:57.916Z,media_ready,5287.912\n```\n\n**Client Metrics:**\n- `ice_gathering`: ICE candidate gathering time\n- `signaling_rtt`: Round-trip time for signaling exchange\n- `ice_connection`: Total time to ICE connected\n- `dtls_handshake`: DTLS handshake completion time\n- `media_ready`: Total connection setup time\n\nAll latency measurements are recorded with sub-millisecond precision.\n\n### Results\nThe following graph was generated from the `results.csv` that was generated by the server. The client was run from another EC2 instance in the same VPC.\nThe Y Axis is the CPU Usage, and the X Axis is the count of PeerConnections. This was run on a `m4.2xlarge (Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz)`\n\n<img src=\"./.github/plot.png\" alt=\"Results Graph\">\n\n### FAQ\n#### What codec/bitrate was being distributed\nThis is controlled by what video you use. You can go as high (or low) as you want.\n\n#### What SRTP Cipher was used\nSRTP_AEAD_AES_128_GCM\n\n#### What Congestion Control/Feedback is used\nNone, on purpose.\n\nPion by design allows the user to specify what they want. We are distributing a video feed that is already encoded, and has a very small keyframe-interval so these things don't help us.\n\nWhen setting up the PeerConnection you have full control of the RTP/RTCP pipelines, so users can add TWCC/NACK/FEC in a way that works for them.\n\n#### I want to talk about cool WebRTC stuff!\nJoin the [Pion Discord](https://discord.gg/PngbdqpFbt)!\n\n### Community\nPion has an active community on the [Discord](https://discord.gg/PngbdqpFbt).\n\nFollow the [Pion Bluesky](https://bsky.app/profile/pion.ly) or [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news.\n\nWe are always looking to support **your projects**. Please reach out if you have something to build!\n\nIf you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly)\n\n### License\nMIT License - see [LICENSE](LICENSE) for full text\n"
  },
  {
    "path": "client/main.go",
    "content": "// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n// SPDX-License-Identifier: MIT\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/pion/webrtc/v4\"\n)\n\ntype latencyMeasurement struct {\n\ttimestamp  time.Time // When the operation completed (not when it started)\n\tlatencyMs  float64   // Latency duration in milliseconds\n\tmetricType string    // Measurement type (see latencyLogger for valid types)\n}\n\n// nolint: gochecknoglobals\nvar (\n\tclientLatencies = make(chan latencyMeasurement, 10000)\n)\n\ntype connectionMetrics struct {\n\t// Timing milestones\n\tconnectionStart      time.Time\n\tofferCreated         time.Time\n\ticeGatheringStart    time.Time\n\ticeGatheringComplete time.Time\n\tofferSent            time.Time\n\tanswerReceived       time.Time\n\ticeConnected         time.Time\n\tdtlsComplete         time.Time\n\tmediaReady           time.Time\n}\n\n// Generate latency measurements CSV with columns of timestamp, type, and latencyMs.\n// The timestamp represents when the operation completed (not when it started).\n//\n// Valid measurement types:\n//   - \"ice_gathering\": Time spent gathering ICE candidates\n//   - \"signaling_rtt\": Round-trip time from offer sent to answer received\n//   - \"ice_connection\": Time from connection start to ICE connected\n//   - \"dtls_handshake\": Time from ICE connected to DTLS handshake complete\n//   - \"media_ready\": Total connection setup time from start to media ready\nfunc latencyLogger() {\n\tfile, err := os.OpenFile(\"client-latencies.csv\", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) // nolint: gosec\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\tif err := file.Close(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tif _, err := file.WriteString(\"timestamp,type,latencyMs\\n\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\tsyncTicker := time.NewTicker(3 * time.Second)\n\tdefer syncTicker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase measurement, ok := <-clientLatencies:\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif _, err := fmt.Fprintf(file, \"%s,%s,%f\\n\",\n\t\t\t\tmeasurement.timestamp.Format(time.RFC3339Nano),\n\t\t\t\tmeasurement.metricType,\n\t\t\t\tmeasurement.latencyMs); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\tcase <-syncTicker.C:\n\t\t\tif err := file.Sync(); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc recordMetric(timestamp time.Time, metricType string, latencyMs float64) {\n\tmeasurement := latencyMeasurement{\n\t\ttimestamp:  timestamp,\n\t\tlatencyMs:  latencyMs,\n\t\tmetricType: metricType,\n\t}\n\tselect {\n\tcase clientLatencies <- measurement:\n\tdefault:\n\t\t// Channel full, drop measurement to avoid blocking\n\t}\n}\n\nfunc recordConnectionMetrics(metrics *connectionMetrics) {\n\t// Calculate latencies\n\ticeGatheringLatency := float64(metrics.iceGatheringComplete.Sub(metrics.iceGatheringStart).Microseconds()) / 1000.0\n\tsignalingRTT := float64(metrics.answerReceived.Sub(metrics.offerSent).Microseconds()) / 1000.0\n\ticeLatency := float64(metrics.iceConnected.Sub(metrics.connectionStart).Microseconds()) / 1000.0\n\tdtlsLatency := float64(metrics.dtlsComplete.Sub(metrics.iceConnected).Microseconds()) / 1000.0\n\tmediaReadyLatency := float64(metrics.mediaReady.Sub(metrics.connectionStart).Microseconds()) / 1000.0\n\n\t// Record to CSV via channel\n\trecordMetric(metrics.iceGatheringComplete, \"ice_gathering\", iceGatheringLatency)\n\trecordMetric(metrics.answerReceived, \"signaling_rtt\", signalingRTT)\n\trecordMetric(metrics.iceConnected, \"ice_connection\", iceLatency)\n\trecordMetric(metrics.dtlsComplete, \"dtls_handshake\", dtlsLatency)\n\trecordMetric(metrics.mediaReady, \"media_ready\", mediaReadyLatency)\n}\n\nfunc newPeerConnection() { // nolint: cyclop\n\tmetrics := &connectionMetrics{\n\t\tconnectionStart: time.Now(),\n\t}\n\tdone := make(chan struct{})\n\n\tpeerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Track ICE connection state changes\n\tpeerConnection.OnICEConnectionStateChange(func(state webrtc.ICEConnectionState) {\n\t\tif state == webrtc.ICEConnectionStateConnected {\n\t\t\tmetrics.iceConnected = time.Now()\n\t\t}\n\t})\n\n\t// Track when media is ready (ICE + DTLS complete)\n\tpeerConnection.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {\n\t\tif state == webrtc.PeerConnectionStateConnected {\n\t\t\tmetrics.dtlsComplete = time.Now()\n\t\t\tmetrics.mediaReady = time.Now()\n\n\t\t\t// Record metrics after connection is established\n\t\t\trecordConnectionMetrics(metrics)\n\t\t\tclose(done)\n\t\t}\n\t})\n\n\tif _, err = peerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeVideo); err != nil {\n\t\tpanic(err)\n\t}\n\n\tgatherCompletePromise := webrtc.GatheringCompletePromise(peerConnection)\n\n\tmetrics.offerCreated = time.Now()\n\toffer, err := peerConnection.CreateOffer(nil)\n\tif err != nil {\n\t\tpanic(err)\n\t} else if err = peerConnection.SetLocalDescription(offer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tmetrics.iceGatheringStart = time.Now()\n\t<-gatherCompletePromise\n\tmetrics.iceGatheringComplete = time.Now()\n\n\tofferJSON, err := json.Marshal(*peerConnection.LocalDescription())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tmetrics.offerSent = time.Now()\n\t// nolint:gosec,noctx\n\tresp, err := http.Post(\n\t\tfmt.Sprintf(\"http://%s/doSignaling\", os.Args[1]),\n\t\t\"application/json\",\n\t\tbytes.NewReader(offerJSON),\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tresp.Close = true\n\n\tvar answer webrtc.SessionDescription\n\tif err = json.NewDecoder(resp.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\tmetrics.answerReceived = time.Now()\n\n\tif err = peerConnection.SetRemoteDescription(answer); err != nil {\n\t\tpanic(err)\n\t}\n\tif err = resp.Body.Close(); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Wait for connection to complete or timeout\n\tselect {\n\tcase <-done:\n\t\t// Connection completed successfully\n\tcase <-time.After(5 * time.Second):\n\t\t// Connection timeout - metrics may be incomplete\n\t\tpanic(\"connection timeout\")\n\t}\n}\n\nfunc main() {\n\tif len(os.Args) != 2 {\n\t\tpanic(\"client expects server host+port\")\n\t}\n\n\t// Start latency logger goroutine\n\tgo latencyLogger()\n\n\tfor range time.NewTicker(5 * time.Second).C {\n\t\tfor i := 0; i <= 10; i++ {\n\t\t\tnewPeerConnection()\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "codecov.yml",
    "content": "#\n# DO NOT EDIT THIS FILE\n#\n# It is automatically copied from https://github.com/pion/.goassets repository.\n#\n# SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n# SPDX-License-Identifier: MIT\n\ncoverage:\n  status:\n    project:\n      default:\n        # Allow decreasing 2% of total coverage to avoid noise.\n        threshold: 2%\n    patch:\n      default:\n        target: 70%\n        only_pulls: true\n\nignore:\n  - \"examples/*\"\n  - \"examples/**/*\"\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/pion/webrtc-bench\n\ngo 1.24.0\n\nrequire (\n\tgithub.com/pion/webrtc/v4 v4.2.9\n\tgithub.com/shirou/gopsutil/v4 v4.26.2\n)\n\nrequire (\n\tgithub.com/ebitengine/purego v0.10.0 // indirect\n\tgithub.com/go-ole/go-ole v1.2.6 // indirect\n\tgithub.com/google/uuid v1.6.0 // indirect\n\tgithub.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect\n\tgithub.com/pion/datachannel v1.6.0 // indirect\n\tgithub.com/pion/dtls/v3 v3.1.2 // indirect\n\tgithub.com/pion/ice/v4 v4.2.1 // indirect\n\tgithub.com/pion/interceptor v0.1.44 // indirect\n\tgithub.com/pion/logging v0.2.4 // indirect\n\tgithub.com/pion/mdns/v2 v2.1.0 // indirect\n\tgithub.com/pion/randutil v0.1.0 // indirect\n\tgithub.com/pion/rtcp v1.2.16 // indirect\n\tgithub.com/pion/rtp v1.10.1 // indirect\n\tgithub.com/pion/sctp v1.9.2 // indirect\n\tgithub.com/pion/sdp/v3 v3.0.18 // indirect\n\tgithub.com/pion/srtp/v3 v3.0.10 // indirect\n\tgithub.com/pion/stun/v3 v3.1.1 // indirect\n\tgithub.com/pion/transport/v4 v4.0.1 // indirect\n\tgithub.com/pion/turn/v4 v4.1.4 // indirect\n\tgithub.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect\n\tgithub.com/tklauser/go-sysconf v0.3.16 // indirect\n\tgithub.com/tklauser/numcpus v0.11.0 // indirect\n\tgithub.com/wlynxg/anet v0.0.5 // indirect\n\tgithub.com/yusufpapurcu/wmi v1.2.4 // indirect\n\tgolang.org/x/crypto v0.48.0 // indirect\n\tgolang.org/x/net v0.50.0 // indirect\n\tgolang.org/x/sys v0.41.0 // indirect\n\tgolang.org/x/time v0.10.0 // indirect\n)\n"
  },
  {
    "path": "go.sum",
    "content": "github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=\ngithub.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=\ngithub.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=\ngithub.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=\ngithub.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=\ngithub.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=\ngithub.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=\ngithub.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=\ngithub.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=\ngithub.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=\ngithub.com/pion/datachannel v1.6.0 h1:XecBlj+cvsxhAMZWFfFcPyUaDZtd7IJvrXqlXD/53i0=\ngithub.com/pion/datachannel v1.6.0/go.mod h1:ur+wzYF8mWdC+Mkis5Thosk+u/VOL287apDNEbFpsIk=\ngithub.com/pion/dtls/v3 v3.1.2 h1:gqEdOUXLtCGW+afsBLO0LtDD8GnuBBjEy6HRtyofZTc=\ngithub.com/pion/dtls/v3 v3.1.2/go.mod h1:Hw/igcX4pdY69z1Hgv5x7wJFrUkdgHwAn/Q/uo7YHRo=\ngithub.com/pion/ice/v4 v4.2.1 h1:XPRYXaLiFq3LFDG7a7bMrmr3mFr27G/gtXN3v/TVfxY=\ngithub.com/pion/ice/v4 v4.2.1/go.mod h1:2quLV1S5v1tAx3VvAJaH//KGitRXvo4RKlX6D3tnN+c=\ngithub.com/pion/interceptor v0.1.44 h1:sNlZwM8dWXU9JQAkJh8xrarC0Etn8Oolcniukmuy0/I=\ngithub.com/pion/interceptor v0.1.44/go.mod h1:4atVlBkcgXuUP+ykQF0qOCGU2j7pQzX2ofvPRFsY5RY=\ngithub.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=\ngithub.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=\ngithub.com/pion/mdns/v2 v2.1.0 h1:3IJ9+Xio6tWYjhN6WwuY142P/1jA0D5ERaIqawg/fOY=\ngithub.com/pion/mdns/v2 v2.1.0/go.mod h1:pcez23GdynwcfRU1977qKU0mDxSeucttSHbCSfFOd9A=\ngithub.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=\ngithub.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=\ngithub.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=\ngithub.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=\ngithub.com/pion/rtp v1.10.1 h1:xP1prZcCTUuhO2c83XtxyOHJteISg6o8iPsE2acaMtA=\ngithub.com/pion/rtp v1.10.1/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=\ngithub.com/pion/sctp v1.9.2 h1:HxsOzEV9pWoeggv7T5kewVkstFNcGvhMPx0GvUOUQXo=\ngithub.com/pion/sctp v1.9.2/go.mod h1:OTOlsQ5EDQ6mQ0z4MUGXt2CgQmKyafBEXhUVqLRB6G8=\ngithub.com/pion/sdp/v3 v3.0.18 h1:l0bAXazKHpepazVdp+tPYnrsy9dfh7ZbT8DxesH5ZnI=\ngithub.com/pion/sdp/v3 v3.0.18/go.mod h1:ZREGo6A9ZygQ9XkqAj5xYCQtQpif0i6Pa81HOiAdqQ8=\ngithub.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ=\ngithub.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M=\ngithub.com/pion/stun/v3 v3.1.1 h1:CkQxveJ4xGQjulGSROXbXq94TAWu8gIX2dT+ePhUkqw=\ngithub.com/pion/stun/v3 v3.1.1/go.mod h1:qC1DfmcCTQjl9PBaMa5wSn3x9IPmKxSdcCsxBcDBndM=\ngithub.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=\ngithub.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=\ngithub.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=\ngithub.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=\ngithub.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=\ngithub.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=\ngithub.com/pion/webrtc/v4 v4.2.9 h1:DZIh1HAhPIL3RvwEDFsmL5hfPSLEpxsQk9/Jir2vkJE=\ngithub.com/pion/webrtc/v4 v4.2.9/go.mod h1:9EmLZve0H76eTzf8v2FmchZ6tcBXtDgpfTEu+drW6SY=\ngithub.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=\ngithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=\ngithub.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=\ngithub.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=\ngithub.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI=\ngithub.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=\ngithub.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=\ngithub.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=\ngithub.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=\ngithub.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=\ngithub.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=\ngithub.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=\ngithub.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=\ngithub.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=\ngithub.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=\ngithub.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=\ngolang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=\ngolang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=\ngolang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=\ngolang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=\ngolang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=\ngolang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=\ngolang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=\ngolang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=\ngolang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=\ngopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=\ngopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\n"
  },
  {
    "path": "renovate.json",
    "content": "{\n  \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n  \"extends\": [\n    \"github>pion/renovate-config\"\n  ]\n}\n"
  },
  {
    "path": "server/main.go",
    "content": "// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n// SPDX-License-Identifier: MIT\n\n//go:build !js\n\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/pion/webrtc/v4\"\n\t\"github.com/pion/webrtc/v4/pkg/media\"\n\t\"github.com/pion/webrtc/v4/pkg/media/ivfreader\"\n\t\"github.com/shirou/gopsutil/v4/cpu\"\n)\n\ntype latencyMeasurement struct {\n\ttimestamp  time.Time // When the operation completed (not when it started)\n\tlatencyMs  float64   // Latency duration in milliseconds\n\tmetricType string    // Measurement type (see rawLatencyLogger for valid types)\n}\n\n// nolint: gochecknoglobals\nvar (\n\toutboundVideoTrack         *webrtc.TrackLocalStaticSample\n\tpeerConnectionCount        int64\n\trawLatencies               = make(chan latencyMeasurement, 10000)\n\tdroppedLatencyMeasurements int64\n)\n\n// Generate latency measurements CSV with columns of timestamp, type, and latencyMs.\n// The timestamp represents when the operation completed (not when it started).\n//\n// Valid measurement types (prefixed by protocol layer):\n//   - \"signaling_processing\": Total server-side signaling processing time (offer to answer)\n//   - \"sdp_offer_processing\": Time to process incoming SDP offer (SetRemoteDescription)\n//   - \"sdp_answer_creation\": Time to create SDP answer (CreateAnswer)\n//   - \"ice_gathering\": Time spent gathering local ICE candidates\n//   - \"ice_connection\": Time from PeerConnection creation to ICE connected (includes signaling + network + client)\n//   - \"dtls_handshake\": Time from ICE connected to DTLS handshake complete\nfunc rawLatencyLogger() {\n\tfile, err := os.OpenFile(\"server-latencies.csv\", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) // nolint: gosec\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\tif err := file.Close(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tif _, err := file.WriteString(\"timestamp,type,latencyMs\\n\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\tsyncTicker := time.NewTicker(3 * time.Second)\n\tdefer syncTicker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase measurement, ok := <-rawLatencies:\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif _, err := fmt.Fprintf(file, \"%s,%s,%f\\n\",\n\t\t\t\tmeasurement.timestamp.Format(time.RFC3339Nano),\n\t\t\t\tmeasurement.metricType,\n\t\t\t\tmeasurement.latencyMs); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\tcase <-syncTicker.C:\n\t\t\tif err := file.Sync(); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Generate CSV with columns of timestamp, peerConnectionCount, cpuUsage, and droppedLatencyMeasurements.\nfunc reportBuilder() {\n\tfile, err := os.OpenFile(\"report.csv\", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) // nolint: gosec\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif _, err := file.WriteString(\"timestamp, peerConnectionCount, cpuUsage, droppedLatencyMeasurements\\n\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor range time.NewTicker(3 * time.Second).C {\n\t\tusage, err := cpu.Percent(0, false)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t} else if len(usage) != 1 {\n\t\t\tpanic(fmt.Sprintf(\"CPU Usage results should have 1 sample, have %d\", len(usage)))\n\t\t}\n\t\tif _, err = fmt.Fprintf(file, \"%s, %d, %f, %d\\n\", time.Now().Format(time.RFC3339), atomic.LoadInt64(&peerConnectionCount), usage[0], atomic.LoadInt64(&droppedLatencyMeasurements)); err != nil { // nolint: lll\n\t\t\tpanic(err)\n\t\t}\n\t}\n}\n\n// HTTP Handler that accepts an Offer and returns an Answer\n// adds outboundVideoTrack to PeerConnection.\nfunc doSignaling(w http.ResponseWriter, r *http.Request) { // nolint: cyclop, varnamelen\n\tsignalingStartTime := time.Now()\n\tdefer func() {\n\t\tlatency := time.Since(signalingStartTime)\n\t\tmeasurement := latencyMeasurement{\n\t\t\ttimestamp:  time.Now(),\n\t\t\tlatencyMs:  float64(latency.Microseconds()) / 1000.0,\n\t\t\tmetricType: \"signaling_processing\",\n\t\t}\n\t\tselect {\n\t\tcase rawLatencies <- measurement:\n\t\tdefault:\n\t\t\t// Channel full, drop measurement to avoid blocking\n\t\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t\t}\n\t}()\n\n\tpeerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Track when PeerConnection is created for ICE connection latency measurement\n\tpeerConnectionCreatedTime := time.Now()\n\n\t// Track when ICE connects for DTLS handshake latency measurement\n\tvar iceConnectedTime time.Time\n\n\tpeerConnection.OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) {\n\t\tswitch connectionState { // nolint: exhaustive\n\t\tcase webrtc.ICEConnectionStateDisconnected, webrtc.ICEConnectionStateFailed:\n\t\t\tif closeErr := peerConnection.Close(); closeErr != nil {\n\t\t\t\tpanic(closeErr)\n\t\t\t}\n\t\tcase webrtc.ICEConnectionStateClosed:\n\t\t\tatomic.AddInt64(&peerConnectionCount, -1)\n\t\tcase webrtc.ICEConnectionStateConnected:\n\t\t\t// Track when ICE connects for DTLS measurement\n\t\t\ticeConnectedTime = time.Now()\n\n\t\t\t// Measure ICE connection latency from PeerConnection creation to ICE connected.\n\t\t\t// NOTE: This includes signaling processing time, network RTT for client to receive answer,\n\t\t\t// client processing time, and ICE check exchanges. This is NOT a pure RTT measurement.\n\t\t\ticeLatency := time.Since(peerConnectionCreatedTime)\n\t\t\ticeMeasurement := latencyMeasurement{\n\t\t\t\ttimestamp:  time.Now(),\n\t\t\t\tlatencyMs:  float64(iceLatency.Microseconds()) / 1000.0,\n\t\t\t\tmetricType: \"ice_connection\",\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase rawLatencies <- iceMeasurement:\n\t\t\tdefault:\n\t\t\t\t// Channel full, drop measurement to avoid blocking\n\t\t\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t\t\t}\n\n\t\t\tatomic.AddInt64(&peerConnectionCount, 1)\n\t\t}\n\t})\n\n\tpeerConnection.OnConnectionStateChange(func(connectionState webrtc.PeerConnectionState) {\n\t\tif connectionState == webrtc.PeerConnectionStateConnected && !iceConnectedTime.IsZero() {\n\t\t\t// Measure DTLS handshake latency (from ICE connected to PeerConnection connected)\n\t\t\tdtlsLatency := time.Since(iceConnectedTime)\n\t\t\tdtlsMeasurement := latencyMeasurement{\n\t\t\t\ttimestamp:  time.Now(),\n\t\t\t\tlatencyMs:  float64(dtlsLatency.Microseconds()) / 1000.0,\n\t\t\t\tmetricType: \"dtls_handshake\",\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase rawLatencies <- dtlsMeasurement:\n\t\t\tdefault:\n\t\t\t\t// Channel full, drop measurement to avoid blocking\n\t\t\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t\t\t}\n\t\t}\n\t})\n\n\tif _, err = peerConnection.AddTrack(outboundVideoTrack); err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar offer webrtc.SessionDescription\n\tif err = json.NewDecoder(r.Body).Decode(&offer); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Measure offer processing latency\n\tofferProcessingStartTime := time.Now()\n\tif err = peerConnection.SetRemoteDescription(offer); err != nil {\n\t\tpanic(err)\n\t}\n\tofferProcessingLatency := time.Since(offerProcessingStartTime)\n\tofferProcessingMeasurement := latencyMeasurement{\n\t\ttimestamp:  time.Now(),\n\t\tlatencyMs:  float64(offerProcessingLatency.Microseconds()) / 1000.0,\n\t\tmetricType: \"sdp_offer_processing\",\n\t}\n\tselect {\n\tcase rawLatencies <- offerProcessingMeasurement:\n\tdefault:\n\t\t// Channel full, drop measurement to avoid blocking\n\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t}\n\n\tgatherCompletePromise := webrtc.GatheringCompletePromise(peerConnection)\n\n\t// Measure answer creation latency\n\tanswerCreationStartTime := time.Now()\n\tanswer, err := peerConnection.CreateAnswer(nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tanswerCreationLatency := time.Since(answerCreationStartTime)\n\tanswerCreationMeasurement := latencyMeasurement{\n\t\ttimestamp:  time.Now(),\n\t\tlatencyMs:  float64(answerCreationLatency.Microseconds()) / 1000.0,\n\t\tmetricType: \"sdp_answer_creation\",\n\t}\n\tselect {\n\tcase rawLatencies <- answerCreationMeasurement:\n\tdefault:\n\t\t// Channel full, drop measurement to avoid blocking\n\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t}\n\n\tif err = peerConnection.SetLocalDescription(answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Track when ICE gathering starts\n\ticeGatheringStartTime := time.Now()\n\n\t<-gatherCompletePromise\n\n\t// Measure ICE gathering latency\n\ticeGatheringLatency := time.Since(iceGatheringStartTime)\n\ticeGatheringMeasurement := latencyMeasurement{\n\t\ttimestamp:  time.Now(),\n\t\tlatencyMs:  float64(iceGatheringLatency.Microseconds()) / 1000.0,\n\t\tmetricType: \"ice_gathering\",\n\t}\n\tselect {\n\tcase rawLatencies <- iceGatheringMeasurement:\n\tdefault:\n\t\t// Channel full, drop measurement to avoid blocking\n\t\tatomic.AddInt64(&droppedLatencyMeasurements, 1)\n\t}\n\n\tresponse, err := json.Marshal(*peerConnection.LocalDescription())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tif _, err := w.Write(response); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvar err error\n\toutboundVideoTrack, err = webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{\n\t\tMimeType: webrtc.MimeTypeVP8,\n\t}, \"pion\", \"pion\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tplayVideo()\n\t\t}\n\t}()\n\n\tgo reportBuilder()\n\tgo rawLatencyLogger()\n\n\thttp.Handle(\"/\", http.FileServer(http.Dir(\"./static\")))\n\thttp.HandleFunc(\"/doSignaling\", doSignaling)\n\n\tfmt.Println(\"Open http://localhost:8080 to access this demo\")\n\tpanic(http.ListenAndServe(\":8080\", nil)) // nolint: gosec\n}\n\nconst videoFileName = \"input.ivf\"\n\nfunc playVideo() {\n\tfile, err := os.Open(videoFileName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tivf, header, err := ivfreader.NewWith(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tticker := time.NewTicker(\n\t\ttime.Millisecond * time.Duration((float32(header.TimebaseNumerator)/float32(header.TimebaseDenominator))*1000),\n\t)\n\tdefer ticker.Stop()\n\tfor ; true; <-ticker.C {\n\t\tframe, _, err := ivf.ParseNextFrame()\n\t\tif errors.Is(err, io.EOF) {\n\t\t\treturn\n\t\t}\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif err = outboundVideoTrack.WriteSample(media.Sample{Data: frame, Duration: time.Second}); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "server/static/index.html",
    "content": "<html lang=\"en\">\n    <!--\n        SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>\n        SPDX-License-Identifier: MIT\n    -->\n<head>\n    <title>webrtc-bench</title>\n</head>\n\n<body>\n<h3><a href=\"index.html\">Video</a></h3>\n<div id=\"remoteVideos\"></div>\n<br/>\n\n<div>\n    <button onclick=\"window.doSignaling(true)\"> ICE Restart (reconnect)</button>\n</div>\n\n<h3> Logs </h3>\n<div id=\"logs\"></div>\n</body>\n\n<script>\n    let pc = new RTCPeerConnection()\n    pc.addTransceiver('video')\n\n    let log = msg => {\n        document.getElementById('logs').innerHTML += msg + '<br>'\n    }\n    pc.oniceconnectionstatechange = () => log(pc.iceConnectionState)\n    pc.ontrack = function (event) {\n        let el = document.createElement(event.track.kind)\n        el.srcObject = event.streams[0]\n        el.autoplay = true\n        el.controls = true\n\n        document.getElementById('remoteVideos').appendChild(el)\n    }\n\n    window.doSignaling = iceRestart => {\n        pc.createOffer({iceRestart})\n            .then(offer => {\n                pc.setLocalDescription(offer)\n\n                return fetch(`/doSignaling`, {\n                    method: 'post',\n                    headers: {\n                        'Accept': 'application/json, text/plain, */*',\n                        'Content-Type': 'application/json'\n                    },\n                    body: JSON.stringify(offer)\n                })\n            })\n            .then(res => res.json())\n            .then(res => pc.setRemoteDescription(res))\n            .catch(alert)\n    }\n\n    window.doSignaling(false)\n</script>\n</html>\n"
  }
]