From 4f1f40923f8afeb42aa973b7bc63c3c159b6499d Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 3 Jan 2024 01:25:07 +0000 Subject: [PATCH] Update CI configs to v0.11.1 Update lint scripts and CI configs. --- .github/.ci.conf | 14 ++ .github/.gitignore | 4 + .github/fetch-scripts.sh | 31 ++++ .github/install-hooks.sh | 20 +++ .github/workflows/codeql-analysis.yml | 28 ++++ .github/workflows/lint.yaml | 77 ++-------- .github/workflows/release.yml | 24 +++ .github/workflows/renovate-go-sum-fix.yaml | 24 +++ .github/workflows/reuse.yml | 22 +++ .github/workflows/test.yaml | 43 ++++++ .github/workflows/tidy-check.yaml | 25 ++++ .gitignore | 30 +++- .golangci.yml | 39 +++-- .goreleaser.yml | 5 + .reuse/dep5 | 7 + LICENSE | 20 +-- LICENSES/MIT.txt | 9 ++ c-data-channels/Makefile | 7 +- c-data-channels/bridge.go | 17 ++- c-data-channels/data-channels.c | 5 +- c-data-channels/webrtc.go | 15 +- c-data-channels/webrtc.h | 137 ++++++++++++++++++ codecov.yml | 22 +++ example.html | 6 +- examples.go | 8 +- go.mod | 26 +++- go.sum | 4 - gocv-receive/jsfiddle/demo.css | 7 +- gocv-receive/jsfiddle/demo.details | 11 +- gocv-receive/jsfiddle/demo.html | 5 + gocv-receive/jsfiddle/demo.js | 3 + gocv-receive/main.go | 3 + gstreamer-receive/README.md | 2 +- gstreamer-receive/jsfiddle/demo.css | 7 +- gstreamer-receive/jsfiddle/demo.details | 11 +- gstreamer-receive/jsfiddle/demo.html | 4 + gstreamer-receive/jsfiddle/demo.js | 3 + gstreamer-receive/main.go | 8 + gstreamer-send-offer/main.go | 7 + gstreamer-send/README.md | 2 +- gstreamer-send/jsfiddle/demo.css | 7 +- gstreamer-send/jsfiddle/demo.details | 11 +- gstreamer-send/jsfiddle/demo.html | 5 + gstreamer-send/jsfiddle/demo.js | 3 + gstreamer-send/main.go | 7 + index.html | 18 ++- internal/gstreamer-sink/gst.c | 3 + internal/gstreamer-sink/gst.go | 5 +- internal/gstreamer-sink/gst.h | 3 + internal/gstreamer-sink/js.go | 7 + internal/gstreamer-src/gst.c | 3 + internal/gstreamer-src/gst.go | 11 +- internal/gstreamer-src/gst.h | 6 +- internal/gstreamer-src/js.go | 7 + internal/signal/http.go | 9 +- internal/signal/signal.go | 28 ++-- janus-gateway/streaming/main.go | 14 +- janus-gateway/video-room/main.go | 13 +- play-from-disk-h264/jsfiddle/demo.css | 7 +- play-from-disk-h264/jsfiddle/demo.details | 11 +- play-from-disk-h264/jsfiddle/demo.html | 5 + play-from-disk-h264/jsfiddle/demo.js | 3 + play-from-disk-h264/main.go | 9 +- renovate.json | 6 + rtmp-to-webrtc/main.go | 4 + save-to-webm/jsfiddle/demo.css | 7 +- save-to-webm/jsfiddle/demo.details | 11 +- save-to-webm/jsfiddle/demo.html | 5 + save-to-webm/jsfiddle/demo.js | 3 + save-to-webm/main.go | 10 +- sfu-ws/flutter/lib/main.dart | 3 + sfu-ws/index.html | 5 + sfu-ws/main.go | 13 +- sip-over-websocket-to-webrtc/main.go | 10 +- .../softphone/constants.go | 4 + .../softphone/inboundcall.go | 5 +- .../softphone/invite.go | 3 + .../softphone/rcmessage.go | 3 + .../softphone/register.go | 7 +- .../softphone/sipmessage.go | 3 + .../softphone/softphone.go | 9 +- .../softphone/utils.go | 3 + snapshot/index.html | 5 + snapshot/main.go | 9 +- twitch/main.go | 11 +- unreal-pixel-streaming/main.go | 7 + 86 files changed, 888 insertions(+), 195 deletions(-) create mode 100755 .github/.ci.conf create mode 100644 .github/.gitignore create mode 100755 .github/fetch-scripts.sh create mode 100755 .github/install-hooks.sh create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/renovate-go-sum-fix.yaml create mode 100644 .github/workflows/reuse.yml create mode 100644 .github/workflows/test.yaml create mode 100644 .github/workflows/tidy-check.yaml create mode 100644 .goreleaser.yml create mode 100644 .reuse/dep5 create mode 100644 LICENSES/MIT.txt create mode 100644 c-data-channels/webrtc.h create mode 100644 codecov.yml create mode 100644 internal/gstreamer-sink/js.go create mode 100644 internal/gstreamer-src/js.go create mode 100644 renovate.json diff --git a/.github/.ci.conf b/.github/.ci.conf new file mode 100755 index 00000000..4a9b2ec2 --- /dev/null +++ b/.github/.ci.conf @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +PRE_TEST_HOOK=_install_gstreamer_hook +PRE_LINT_HOOK=_install_gstreamer_hook + +function _install_gstreamer_hook(){ + set -e + + sudo apt-get update + sudo apt-get purge -y libunwind-14-dev + sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + +} diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 00000000..c3421a1a --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +.goassets diff --git a/.github/fetch-scripts.sh b/.github/fetch-scripts.sh new file mode 100755 index 00000000..f333841e --- /dev/null +++ b/.github/fetch-scripts.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +set -eu + +SCRIPT_PATH="$(realpath "$(dirname "$0")")" +GOASSETS_PATH="${SCRIPT_PATH}/.goassets" + +GOASSETS_REF=${GOASSETS_REF:-master} + +if [ -d "${GOASSETS_PATH}" ]; then + if ! git -C "${GOASSETS_PATH}" diff --exit-code; then + echo "${GOASSETS_PATH} has uncommitted changes" >&2 + exit 1 + fi + git -C "${GOASSETS_PATH}" fetch origin + git -C "${GOASSETS_PATH}" checkout ${GOASSETS_REF} + git -C "${GOASSETS_PATH}" reset --hard origin/${GOASSETS_REF} +else + git clone -b ${GOASSETS_REF} https://github.com/pion/.goassets.git "${GOASSETS_PATH}" +fi diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh new file mode 100755 index 00000000..8aa34be9 --- /dev/null +++ b/.github/install-hooks.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +SCRIPT_PATH="$(realpath "$(dirname "$0")")" + +. ${SCRIPT_PATH}/fetch-scripts.sh + +cp "${GOASSETS_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg" +cp "${GOASSETS_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit" +cp "${GOASSETS_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..ea9b825e --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,28 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: CodeQL + +on: + workflow_dispatch: + schedule: + - cron: '23 5 * * 0' + pull_request: + branches: + - master + paths: + - '**.go' + +jobs: + analyze: + uses: pion/.goassets/.github/workflows/codeql-analysis.reusable.yml@master diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e26b0313..5dd3a993 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,67 +1,20 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + name: Lint on: - push: - branches: - - master pull_request: - branches: - - master - schedule: - - cron: "0 0 * * 1" - jobs: - lint-commit-message: - name: Metadata - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Checkout .goassets - uses: actions/checkout@v3 - with: - repository: pion/.goassets - path: ${{ github.workspace }}/.github/.goassets - ref: ${{ inputs.goassets-ref }} - - - name: Commit Message - run: .github/.goassets/scripts/lint-commit-message.sh - - - name: File names - run: .github/.goassets/scripts/lint-filename.sh - - - name: Logging messages should not have trailing newlines - run: .github/.goassets/scripts/lint-no-trailing-newline-in-log-messages.sh - - - name: Go version in go.mod - run: .github/.goassets/scripts/lint-go-mod-version.sh - - lint-go: - name: Go - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-go@v4 - with: - go-version: 'stable' - - - name: Update packages - run: sudo apt-get update - - - name: Install GStreamer - run: | - sudo apt-get purge -y libunwind-14-dev - sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Build data-channels - run: cd c-data-channels && make - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.52.2 + lint: + uses: pion/.goassets/.github/workflows/lint.reusable.yml@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..01227e2a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: Release +on: + push: + tags: + - 'v*' + +jobs: + release: + uses: pion/.goassets/.github/workflows/release.reusable.yml@master + with: + go-version: '1.20' # auto-update/latest-go-version diff --git a/.github/workflows/renovate-go-sum-fix.yaml b/.github/workflows/renovate-go-sum-fix.yaml new file mode 100644 index 00000000..b7bb1b4f --- /dev/null +++ b/.github/workflows/renovate-go-sum-fix.yaml @@ -0,0 +1,24 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: Fix go.sum +on: + push: + branches: + - renovate/* + +jobs: + fix: + uses: pion/.goassets/.github/workflows/renovate-go-sum-fix.reusable.yml@master + secrets: + token: ${{ secrets.PIONBOT_PRIVATE_KEY }} diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 00000000..8633a12a --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,22 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: REUSE Compliance Check + +on: + push: + pull_request: + +jobs: + lint: + uses: pion/.goassets/.github/workflows/reuse.reusable.yml@master diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..31aada4a --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,43 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: Test +on: + push: + branches: + - master + pull_request: + +jobs: + test: + uses: pion/.goassets/.github/workflows/test.reusable.yml@master + strategy: + matrix: + go: ['1.20', '1.19'] # auto-update/supported-go-version-list + fail-fast: false + with: + go-version: ${{ matrix.go }} + + test-i386: + uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master + strategy: + matrix: + go: ['1.20', '1.19'] # auto-update/supported-go-version-list + fail-fast: false + with: + go-version: ${{ matrix.go }} + + test-wasm: + uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master + with: + go-version: '1.20' # auto-update/latest-go-version diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml new file mode 100644 index 00000000..4d346d4f --- /dev/null +++ b/.github/workflows/tidy-check.yaml @@ -0,0 +1,25 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: Go mod tidy +on: + pull_request: + push: + branches: + - master + +jobs: + tidy: + uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master + with: + go-version: '1.20' # auto-update/latest-go-version diff --git a/.gitignore b/.gitignore index d8784262..6e2f206a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,28 @@ -sfu-ws/cert.pem -sfu-ws/key.pem +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT -*.ogg +### JetBrains IDE ### +##################### +.idea/ + +### Emacs Temporary Files ### +############################# +*~ + +### Folders ### +############### +bin/ +vendor/ +node_modules/ + +### Files ### +############# *.ivf -*.h264 +*.ogg +tags +cover.out +*.sw[poe] +*.wasm +examples/sfu-ws/cert.pem +examples/sfu-ws/key.pem +wasm_exec.js diff --git a/.golangci.yml b/.golangci.yml index ef8f2214..6dd80c80 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,6 +6,8 @@ linters-settings: check-shadowing: true misspell: locale: US + exhaustive: + default-signifies-exhaustive: true gomodguard: blocked: modules: @@ -14,11 +16,11 @@ linters-settings: - errors forbidigo: forbid: + - ^fmt.Print(f|ln)?$ + - ^log.(Panic|Fatal|Print)(f|ln)?$ + - ^os.Exit$ + - ^panic$ - ^print(ln)?$ - revive: - rules: - - name: package-comments - disabled: true linters: enable: @@ -27,19 +29,25 @@ linters: - bodyclose # checks whether HTTP response body is closed successfully - contextcheck # check the function whether use a non-inherited context - decorder # check declaration order and count of types, constants, variables and functions - - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection - durationcheck # check for two durations multiplied together - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases - 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. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. + - 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. + - exhaustive # check exhaustiveness of enum switch statements - exportloopref # checks for pointers to enclosing loop variables - forbidigo # Forbids identifiers + - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. + - gochecknoglobals # Checks that no globals are present in Go code + - gochecknoinits # Checks that no init functions are present in Go code + - gocognit # Computes and checks the cognitive complexity of functions - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter - godox # Tool for detection of FIXME, TODO and other comment keywords + - goerr113 # Golang linter to check the errors handling expressions - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern @@ -54,7 +62,6 @@ linters: - importas # Enforces consistent import aliases - ineffassign # Detects when assignments to existing variables are not used - misspell # Finds commonly misspelled English words in comments - - nakedret # Finds naked returns in functions greater than a specified function length - nilerr # Finds the code that returns nil even if it checks that the error is not nil. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. - noctx # noctx finds sending http request without context.Context @@ -72,6 +79,7 @@ linters: - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace disable: + - depguard # Go linter that checks if package imports are in a list of acceptable packages - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - exhaustivestruct # Checks if all struct's fields are initialized @@ -85,6 +93,7 @@ linters: - maintidx # maintidx measures the maintainability index of each function. - makezero # Finds slice declarations with non-zero initial length - maligned # Tool to detect Go structs that would take less memory if their fields were sorted + - nakedret # Finds naked returns in functions greater than a specified function length - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity - nolintlint # Reports ill-formed or insufficient nolint directives @@ -102,28 +111,16 @@ linters: issues: exclude-use-default: false exclude-rules: - # Allow complex tests, better to be self contained - - path: _test\.go + # Allow complex tests and examples, better to be self contained + - path: (examples|main\.go|_test\.go) linters: - - gocognit - forbidigo - - # Allow complex main function in examples - - path: examples - text: "of func `main` is high" - linters: - gocognit - # Allow forbidden identifiers in examples - - path: examples - linters: - - forbidigo - # Allow forbidden identifiers in CLI commands - path: cmd linters: - forbidigo run: - skip-dirs: - - c-data-channels + skip-dirs-use-default: false diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..30093e9d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +builds: +- skip: true diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 00000000..7bb60710 --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Pion +Source: https://github.com/pion/ + +Files: README.md DESIGN.md **/README.md renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples.json **/.gitignore **/pubspec.yaml c-data-channels/webrtc.h +Copyright: 2023 The Pion community +License: MIT diff --git a/LICENSE b/LICENSE index 8b23445f..491caf6b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,9 @@ MIT License -Copyright (c) 2019 +Copyright (c) 2023 The Pion community -Permission 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: +Permission 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: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE 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. +THE 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. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 00000000..2071b23b --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission 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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE 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. diff --git a/c-data-channels/Makefile b/c-data-channels/Makefile index 6807af71..057d38d5 100644 --- a/c-data-channels/Makefile +++ b/c-data-channels/Makefile @@ -1,8 +1,11 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + c-data-channels: webrtc.so data-channels.c gcc -o $@ data-channels.c ./webrtc.so -webrtc.so: webrtc.go bridge.go +webrtc.so: webrtc.go bridge.go go build -o $@ -buildmode=c-shared $^ clean: - rm webrtc.so webrtc.h c-data-channels \ No newline at end of file + rm webrtc.so webrtc.h c-data-channels diff --git a/c-data-channels/bridge.go b/c-data-channels/bridge.go index e2b24d72..d8b4a1c6 100644 --- a/c-data-channels/bridge.go +++ b/c-data-channels/bridge.go @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +// c-data-channels shows how to mix C and Go code package main /* @@ -41,8 +45,11 @@ import ( "github.com/pion/webrtc/v3" ) +// nolint var store = map[C.GoDataChannel]*webrtc.DataChannel{} +// nolint +// //export GoRun func GoRun(f C.GoOnDataChannelFunc) { Run(func(d *webrtc.DataChannel) { @@ -55,6 +62,8 @@ func GoRun(f C.GoOnDataChannelFunc) { }) } +// nolint +// //export GoOnOpen func GoOnOpen(d C.GoDataChannel, f C.GoOnOpenFunc) { // get the actual DataChannel using a unique id @@ -64,6 +73,8 @@ func GoOnOpen(d C.GoDataChannel, f C.GoOnOpenFunc) { }) } +// nolint +// //export GoOnMessage func GoOnMessage(d C.GoDataChannel, f C.GoOnMessageFunc) { dc := store[d] @@ -84,12 +95,16 @@ func GoOnMessage(d C.GoDataChannel, f C.GoOnMessageFunc) { }) } +// nolint +// //export GoSendText func GoSendText(d C.GoDataChannel, t *C.char) { dc := store[d] - dc.SendText(C.GoString(t)) + _ = dc.SendText(C.GoString(t)) } +// nolint +// //export GoLabel func GoLabel(d C.GoDataChannel) *C.char { dc := store[d] diff --git a/c-data-channels/data-channels.c b/c-data-channels/data-channels.c index 73f030e6..d9e6e5c3 100644 --- a/c-data-channels/data-channels.c +++ b/c-data-channels/data-channels.c @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + #include "webrtc.h" #include #include @@ -66,4 +69,4 @@ char *rand_seq(int n) } b[n] = '\0'; return b; -} \ No newline at end of file +} diff --git a/c-data-channels/webrtc.go b/c-data-channels/webrtc.go index b87a9697..c3d1625e 100644 --- a/c-data-channels/webrtc.go +++ b/c-data-channels/webrtc.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package main import ( @@ -26,13 +29,13 @@ func Run(f func(*webrtc.DataChannel)) { // Create a new RTCPeerConnection peerConnection, err := webrtc.NewPeerConnection(config) if err != nil { - panic(err) + panic(err) //nolint } // Set the handler for ICE connection state // This will notify you when the peer has connected/disconnected peerConnection.OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) { - fmt.Printf("ICE Connection State has changed: %s\n", connectionState.String()) + fmt.Printf("ICE Connection State has changed: %s\n", connectionState.String()) //nolint }) // Register data channel creation handling @@ -45,13 +48,13 @@ func Run(f func(*webrtc.DataChannel)) { // Set the remote SessionDescription err = peerConnection.SetRemoteDescription(offer) if err != nil { - panic(err) + panic(err) //nolint } // Create an answer answer, err := peerConnection.CreateAnswer(nil) if err != nil { - panic(err) + panic(err) //nolint } // Create channel that is blocked until ICE Gathering is complete @@ -60,7 +63,7 @@ func Run(f func(*webrtc.DataChannel)) { // Sets the LocalDescription, and starts our UDP listeners err = peerConnection.SetLocalDescription(answer) if err != nil { - panic(err) + panic(err) //nolint } // Block until ICE Gathering is complete, disabling trickle ICE @@ -69,7 +72,7 @@ func Run(f func(*webrtc.DataChannel)) { <-gatherComplete // Output the answer in base64 so we can paste it in browser - fmt.Println(signal.Encode(*peerConnection.LocalDescription())) + fmt.Println(signal.Encode(*peerConnection.LocalDescription())) //nolint // Block forever select {} diff --git a/c-data-channels/webrtc.h b/c-data-channels/webrtc.h new file mode 100644 index 00000000..e985d4e5 --- /dev/null +++ b/c-data-channels/webrtc.h @@ -0,0 +1,137 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 7 "bridge.go" + +#include +#include +typedef struct GoDataChannelMessage +{ + // bool in cgo is really weird, so it's simpler to just use classic int as bool + int is_string; + void *data; + size_t data_len; +} GoDataChannelMessage; + +typedef uint16_t GoDataChannel; +typedef void (*GoOnDataChannelFunc)(GoDataChannel); +typedef void (*GoOnOpenFunc)(GoDataChannel); +typedef void (*GoOnMessageFunc)(GoDataChannel, GoDataChannelMessage); + +// Calling C function pointers is currently not supported, however you can +// declare Go variables which hold C function pointers and pass them back +// and forth between Go and C. C code may call function pointers received from Go. +// Reference: https://golang.org/cmd/cgo/#hdr-Go_references_to_C +inline void bridge_on_data_channel(GoOnDataChannelFunc cb, GoDataChannel d) +{ + cb(d); +} + +inline void bridge_on_open(GoOnOpenFunc cb, GoDataChannel d) +{ + cb(d); +} + +inline void bridge_on_message(GoOnMessageFunc cb, GoDataChannel d, GoDataChannelMessage msg) +{ + cb(d, msg); +} + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +// nolint +// +extern void GoRun(GoOnDataChannelFunc f); + +// nolint +// +extern void GoOnOpen(GoDataChannel d, GoOnOpenFunc f); + +// nolint +// +extern void GoOnMessage(GoDataChannel d, GoOnMessageFunc f); + +// nolint +// +extern void GoSendText(GoDataChannel d, char* t); + +// nolint +// +extern char* GoLabel(GoDataChannel d); + +#ifdef __cplusplus +} +#endif diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..263e4d45 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,22 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +coverage: + status: + project: + default: + # Allow decreasing 2% of total coverage to avoid noise. + threshold: 2% + patch: + default: + target: 70% + only_pulls: true + +ignore: + - "examples/*" + - "examples/**/*" diff --git a/example.html b/example.html index dcc3e5c9..bd445fb9 100644 --- a/example.html +++ b/example.html @@ -1,4 +1,8 @@ + @@ -17,7 +21,7 @@

{{ .Title }}

-

< Home

+

< Home

{{ template "demo.html" }} diff --git a/examples.go b/examples.go index ba172a3a..74771bee 100644 --- a/examples.go +++ b/examples.go @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +// examples hosts the HTML/JS for different examples package main import ( @@ -107,7 +111,7 @@ func serve(addr string) error { func getExamples() (*Examples, error) { file, err := os.Open("./examples.json") if err != nil { - return nil, fmt.Errorf("failed to list examples (please run in the examples folder): %v", err) + return nil, fmt.Errorf("failed to list examples (please run in the examples folder): %v", err) //nolint } defer func() { closeErr := file.Close() @@ -119,7 +123,7 @@ func getExamples() (*Examples, error) { var examples Examples err = json.NewDecoder(file).Decode(&examples) if err != nil { - return nil, fmt.Errorf("failed to parse examples: %v", err) + return nil, fmt.Errorf("failed to parse examples: %v", err) //nolint } for _, example := range examples { diff --git a/go.mod b/go.mod index c6fd93b6..71a55e2f 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,39 @@ module github.com/pion/example-webrtc-applications/v3 -go 1.13 +go 1.19 require ( github.com/at-wat/ebml-go v0.16.0 github.com/google/uuid v1.3.0 github.com/gorilla/websocket v1.4.2 github.com/notedit/janus-go v0.0.0-20210115013133-fdce1b146d0e - github.com/pion/ice/v2 v2.1.12 // indirect github.com/pion/rtcp v1.2.6 github.com/pion/rtp v1.7.1 github.com/pion/sdp/v2 v2.4.0 github.com/pion/webrtc/v3 v3.1.0-beta.3 - github.com/rs/xid v1.3.0 // indirect gocv.io/x/gocv v0.28.0 - golang.org/x/crypto v0.0.0-20210812204632-0ba0e8f03122 // indirect golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d +) + +require ( + github.com/pion/datachannel v1.4.21 // indirect + github.com/pion/dtls/v2 v2.0.9 // indirect + github.com/pion/ice/v2 v2.1.12 // indirect + github.com/pion/interceptor v0.0.15 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/mdns v0.0.5 // indirect + github.com/pion/randutil v0.1.0 // indirect + github.com/pion/sctp v1.7.12 // indirect + github.com/pion/sdp/v3 v3.0.4 // indirect + github.com/pion/srtp/v2 v2.0.5 // indirect + github.com/pion/stun v0.3.5 // indirect + github.com/pion/transport v0.12.3 // indirect + github.com/pion/turn/v2 v2.0.5 // indirect + github.com/pion/udp v0.1.1 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/rs/xid v1.3.0 // indirect + golang.org/x/crypto v0.0.0-20210812204632-0ba0e8f03122 // indirect golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index 21d1f04c..37c4e647 100644 --- a/go.sum +++ b/go.sum @@ -24,10 +24,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e/go.mod h1:eagM805MRKrioHYuU7iKLUyFPVKqVV6um5DAvCkUtXs= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/notedit/janus-go v0.0.0-20210115013133-fdce1b146d0e h1:L1QWI1FyFkgLOLSP/BlbkLiyLyqUuyxCCRJyULDinx8= github.com/notedit/janus-go v0.0.0-20210115013133-fdce1b146d0e/go.mod h1:BN/Txse3qz8tZOmCm2OfajB2wHVujWmX3o9nVdsI6gE= @@ -134,7 +132,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -156,7 +153,6 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/gocv-receive/jsfiddle/demo.css b/gocv-receive/jsfiddle/demo.css index 9e43d340..17524fc4 100644 --- a/gocv-receive/jsfiddle/demo.css +++ b/gocv-receive/jsfiddle/demo.css @@ -1,4 +1,9 @@ +/* + SPDX-FileCopyrightText: 2023 The Pion community + SPDX-License-Identifier: MIT +*/ + textarea { width: 500px; min-height: 75px; -} \ No newline at end of file +} diff --git a/gocv-receive/jsfiddle/demo.details b/gocv-receive/jsfiddle/demo.details index 94c4b55e..c9602308 100644 --- a/gocv-receive/jsfiddle/demo.details +++ b/gocv-receive/jsfiddle/demo.details @@ -1,5 +1,8 @@ --- - name: gocv-receive - description: Example of using Pion WebRTC with GoCV to do motion detection - authors: - - Sean DuBois +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: gocv-receive +description: Example of using Pion WebRTC with GoCV to do motion detection +authors: + - Sean DuBois diff --git a/gocv-receive/jsfiddle/demo.html b/gocv-receive/jsfiddle/demo.html index cba0be07..84036858 100644 --- a/gocv-receive/jsfiddle/demo.html +++ b/gocv-receive/jsfiddle/demo.html @@ -1,3 +1,8 @@ + + Browser base64 Session Description

diff --git a/gocv-receive/jsfiddle/demo.js b/gocv-receive/jsfiddle/demo.js index 9bf6c39a..f3bfe564 100644 --- a/gocv-receive/jsfiddle/demo.js +++ b/gocv-receive/jsfiddle/demo.js @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + /* eslint-env browser */ let pc = new RTCPeerConnection({ diff --git a/gocv-receive/main.go b/gocv-receive/main.go index 5f7994ab..f1386bca 100644 --- a/gocv-receive/main.go +++ b/gocv-receive/main.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + //go:build gocv // +build gocv diff --git a/gstreamer-receive/README.md b/gstreamer-receive/README.md index a707493f..f4034b67 100644 --- a/gstreamer-receive/README.md +++ b/gstreamer-receive/README.md @@ -1,5 +1,5 @@ # gstreamer-receive -gstreamer-receive is a simple application that shows how to receive media using pion-WebRTC and play live using GStreamer. +gstreamer-receive is a simple application that shows how to receive media using Pion WebRTC and play live using GStreamer. ## Instructions ### Install GStreamer diff --git a/gstreamer-receive/jsfiddle/demo.css b/gstreamer-receive/jsfiddle/demo.css index 9e43d340..17524fc4 100644 --- a/gstreamer-receive/jsfiddle/demo.css +++ b/gstreamer-receive/jsfiddle/demo.css @@ -1,4 +1,9 @@ +/* + SPDX-FileCopyrightText: 2023 The Pion community + SPDX-License-Identifier: MIT +*/ + textarea { width: 500px; min-height: 75px; -} \ No newline at end of file +} diff --git a/gstreamer-receive/jsfiddle/demo.details b/gstreamer-receive/jsfiddle/demo.details index 3a3ab37e..05b7527f 100644 --- a/gstreamer-receive/jsfiddle/demo.details +++ b/gstreamer-receive/jsfiddle/demo.details @@ -1,5 +1,8 @@ --- - name: gstreamer-receive - description: Example of using pion-WebRTC to play video using GStreamer - authors: - - Sean DuBois +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: gstreamer-receive +description: Example of using pion-WebRTC to play video using GStreamer +authors: + - Sean DuBois diff --git a/gstreamer-receive/jsfiddle/demo.html b/gstreamer-receive/jsfiddle/demo.html index 7612e161..978fe7f2 100644 --- a/gstreamer-receive/jsfiddle/demo.html +++ b/gstreamer-receive/jsfiddle/demo.html @@ -1,3 +1,7 @@ + Browser base64 Session Description

diff --git a/gstreamer-receive/jsfiddle/demo.js b/gstreamer-receive/jsfiddle/demo.js index a7b3f711..8aac62cc 100644 --- a/gstreamer-receive/jsfiddle/demo.js +++ b/gstreamer-receive/jsfiddle/demo.js @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + /* eslint-env browser */ let pc = new RTCPeerConnection({ diff --git a/gstreamer-receive/main.go b/gstreamer-receive/main.go index c403cb1a..7cae7bbb 100644 --- a/gstreamer-receive/main.go +++ b/gstreamer-receive/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// gstreamer-receive is a simple application that shows how to receive media using Pion WebRTC and play live using GStreamer. package main import ( @@ -104,6 +111,7 @@ func gstreamerReceiveMain() { select {} } +// nolint func init() { // This example uses Gstreamer's autovideosink element to display the received video // This element, along with some others, sometimes require that the process' main thread is used diff --git a/gstreamer-send-offer/main.go b/gstreamer-send-offer/main.go index 88f44fe0..87eed22d 100644 --- a/gstreamer-send-offer/main.go +++ b/gstreamer-send-offer/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// gstreamer-send-offer is a simple application that shows how to send video using Pion WebRTC and GStreamer package main import ( diff --git a/gstreamer-send/README.md b/gstreamer-send/README.md index a1e13468..f2dae1b2 100644 --- a/gstreamer-send/README.md +++ b/gstreamer-send/README.md @@ -1,5 +1,5 @@ # gstreamer-send -gstreamer-send is a simple application that shows how to send video to your browser using pion-WebRTC and GStreamer. +gstreamer-send is a simple application that shows how to send video to your browser using Pion WebRTC and GStreamer. ## Instructions ### Install GStreamer diff --git a/gstreamer-send/jsfiddle/demo.css b/gstreamer-send/jsfiddle/demo.css index 9e43d340..17524fc4 100644 --- a/gstreamer-send/jsfiddle/demo.css +++ b/gstreamer-send/jsfiddle/demo.css @@ -1,4 +1,9 @@ +/* + SPDX-FileCopyrightText: 2023 The Pion community + SPDX-License-Identifier: MIT +*/ + textarea { width: 500px; min-height: 75px; -} \ No newline at end of file +} diff --git a/gstreamer-send/jsfiddle/demo.details b/gstreamer-send/jsfiddle/demo.details index dccded8e..c70937bd 100644 --- a/gstreamer-send/jsfiddle/demo.details +++ b/gstreamer-send/jsfiddle/demo.details @@ -1,5 +1,8 @@ --- - name: gstreamer-send - description: Example of using pion-WebRTC to send video to your browser using GStreamer - authors: - - Sean DuBois +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: gstreamer-send +description: Example of using pion-WebRTC to send video to your browser using GStreamer +authors: + - Sean DuBois diff --git a/gstreamer-send/jsfiddle/demo.html b/gstreamer-send/jsfiddle/demo.html index 6dbbf255..8f26937e 100644 --- a/gstreamer-send/jsfiddle/demo.html +++ b/gstreamer-send/jsfiddle/demo.html @@ -1,3 +1,8 @@ + + Browser base64 Session Description

diff --git a/gstreamer-send/jsfiddle/demo.js b/gstreamer-send/jsfiddle/demo.js index 90d5e6b8..20ffb395 100644 --- a/gstreamer-send/jsfiddle/demo.js +++ b/gstreamer-send/jsfiddle/demo.js @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + /* eslint-env browser */ let pc = new RTCPeerConnection({ diff --git a/gstreamer-send/main.go b/gstreamer-send/main.go index c5b040b4..9b706b31 100644 --- a/gstreamer-send/main.go +++ b/gstreamer-send/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// gstreamer-send is a simple application that shows how to send video to your browser using Pion WebRTC and GStreamer. package main import ( diff --git a/index.html b/index.html index 79b38232..7192f0e4 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,8 @@ + @@ -10,13 +14,13 @@ font-weight: 400; margin: 4em 10%; } - + .container { display: flex; flex-wrap: wrap; justify-content: center; } - + .card { box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); transition: 0.3s; @@ -24,16 +28,16 @@ flex-grow: 1; max-width: 500px; } - + .card:hover { box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); } - + .content { line-height: 1.2em; padding: 0 16px; } - + .header { color:#ffffff; background-image: linear-gradient(225deg, #eb6562 0%, #E53935 100%); @@ -46,11 +50,11 @@

Pion WebRTC examples

-
+
{{range .}}
-

{{ .Title }}

+

{{ .Title }}

{{ .Description }}

diff --git a/internal/gstreamer-sink/gst.c b/internal/gstreamer-sink/gst.c index 322c507f..8c6a0b73 100644 --- a/internal/gstreamer-sink/gst.c +++ b/internal/gstreamer-sink/gst.c @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + #include "gst.h" #include diff --git a/internal/gstreamer-sink/gst.go b/internal/gstreamer-sink/gst.go index d5c9e342..28d8e9d3 100644 --- a/internal/gstreamer-sink/gst.go +++ b/internal/gstreamer-sink/gst.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + // Package gst provides an easy API to create an appsrc pipeline package gst @@ -45,7 +48,7 @@ func CreatePipeline(payloadType webrtc.PayloadType, codecName string) *Pipeline case "g722": pipelineStr += " clock-rate=8000 ! rtpg722depay ! decodebin ! autoaudiosink" default: - panic("Unhandled codec " + codecName) + panic("Unhandled codec " + codecName) //nolint } pipelineStrUnsafe := C.CString(pipelineStr) diff --git a/internal/gstreamer-sink/gst.h b/internal/gstreamer-sink/gst.h index 35a14f85..7e5c5e79 100644 --- a/internal/gstreamer-sink/gst.h +++ b/internal/gstreamer-sink/gst.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + #ifndef GST_H #define GST_H diff --git a/internal/gstreamer-sink/js.go b/internal/gstreamer-sink/js.go new file mode 100644 index 00000000..988bf0c2 --- /dev/null +++ b/internal/gstreamer-sink/js.go @@ -0,0 +1,7 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build js && wasm +// +build js,wasm + +package gst diff --git a/internal/gstreamer-src/gst.c b/internal/gstreamer-src/gst.c index 64d4cfa5..369bf486 100644 --- a/internal/gstreamer-src/gst.c +++ b/internal/gstreamer-src/gst.c @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + #include "gst.h" #include diff --git a/internal/gstreamer-src/gst.go b/internal/gstreamer-src/gst.go index 1b76e50d..cd47b60a 100644 --- a/internal/gstreamer-src/gst.go +++ b/internal/gstreamer-src/gst.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + // Package gst provides an easy API to create an appsink pipeline package gst @@ -19,6 +22,7 @@ import ( "github.com/pion/webrtc/v3/pkg/media" ) +// nolint func init() { go C.gstreamer_send_start_mainloop() } @@ -32,6 +36,7 @@ type Pipeline struct { clockRate float32 } +// nolint var ( pipelines = make(map[int]*Pipeline) pipelinesLock sync.Mutex @@ -78,7 +83,7 @@ func CreatePipeline(codecName string, tracks []*webrtc.TrackLocalStaticSample, p clockRate = pcmClockRate default: - panic("Unhandled codec " + codecName) + panic("Unhandled codec " + codecName) //nolint } pipelineStrUnsafe := C.CString(pipelineStr) @@ -118,11 +123,11 @@ func goHandlePipelineBuffer(buffer unsafe.Pointer, bufferLen C.int, duration C.i if ok { for _, t := range pipeline.tracks { if err := t.WriteSample(media.Sample{Data: C.GoBytes(buffer, bufferLen), Duration: time.Duration(duration)}); err != nil { - panic(err) + panic(err) //nolint } } } else { - fmt.Printf("discarding buffer, no pipeline with id %d", int(pipelineID)) + fmt.Printf("discarding buffer, no pipeline with id %d", int(pipelineID)) //nolint } C.free(buffer) } diff --git a/internal/gstreamer-src/gst.h b/internal/gstreamer-src/gst.h index dcdc6baf..ae15ee34 100644 --- a/internal/gstreamer-src/gst.h +++ b/internal/gstreamer-src/gst.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + #ifndef GST_H #define GST_H @@ -6,7 +9,8 @@ #include #include -extern void goHandlePipelineBuffer(void *buffer, int bufferLen, int samples, int pipelineId); +extern void goHandlePipelineBuffer(void *buffer, int bufferLen, int samples, + int pipelineId); GstElement *gstreamer_send_create_pipeline(char *pipeline); void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId); diff --git a/internal/gstreamer-src/js.go b/internal/gstreamer-src/js.go new file mode 100644 index 00000000..988bf0c2 --- /dev/null +++ b/internal/gstreamer-src/js.go @@ -0,0 +1,7 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build js && wasm +// +build js,wasm + +package gst diff --git a/internal/signal/http.go b/internal/signal/http.go index f024c2f0..06572171 100644 --- a/internal/signal/http.go +++ b/internal/signal/http.go @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package signal import ( "flag" "fmt" - "io/ioutil" + "io" "net/http" "strconv" ) @@ -15,7 +18,7 @@ func HTTPSDPServer() chan string { sdpChan := make(chan string) http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { - body, _ := ioutil.ReadAll(r.Body) + body, _ := io.ReadAll(r.Body) fmt.Fprintf(w, "done") sdpChan <- string(body) }) @@ -23,7 +26,7 @@ func HTTPSDPServer() chan string { go func() { err := http.ListenAndServe(":"+strconv.Itoa(*port), nil) // nolint:gosec if err != nil { - panic(err) + panic(err) //nolint } }() diff --git a/internal/signal/signal.go b/internal/signal/signal.go index 67f6a57c..a067bacd 100644 --- a/internal/signal/signal.go +++ b/internal/signal/signal.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + // Package signal contains helpers to exchange the SDP session // description between examples. package signal @@ -10,7 +13,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "strings" ) @@ -28,7 +30,7 @@ func MustReadStdin() string { in, err = r.ReadString('\n') if err != io.EOF { if err != nil { - panic(err) + panic(err) //nolint } } in = strings.TrimSpace(in) @@ -37,7 +39,7 @@ func MustReadStdin() string { } } - fmt.Println("") + fmt.Println("") //nolint return in } @@ -47,7 +49,7 @@ func MustReadStdin() string { func Encode(obj interface{}) string { b, err := json.Marshal(obj) if err != nil { - panic(err) + panic(err) //nolint } if compress { @@ -62,7 +64,7 @@ func Encode(obj interface{}) string { func Decode(in string, obj interface{}) { b, err := base64.StdEncoding.DecodeString(in) if err != nil { - panic(err) + panic(err) //nolint } if compress { @@ -71,7 +73,7 @@ func Decode(in string, obj interface{}) { err = json.Unmarshal(b, obj) if err != nil { - panic(err) + panic(err) //nolint } } @@ -80,15 +82,15 @@ func zip(in []byte) []byte { gz := gzip.NewWriter(&b) _, err := gz.Write(in) if err != nil { - panic(err) + panic(err) //nolint } err = gz.Flush() if err != nil { - panic(err) + panic(err) //nolint } err = gz.Close() if err != nil { - panic(err) + panic(err) //nolint } return b.Bytes() } @@ -97,15 +99,15 @@ func unzip(in []byte) []byte { var b bytes.Buffer _, err := b.Write(in) if err != nil { - panic(err) + panic(err) //nolint } r, err := gzip.NewReader(&b) if err != nil { - panic(err) + panic(err) //nolint } - res, err := ioutil.ReadAll(r) + res, err := io.ReadAll(r) if err != nil { - panic(err) + panic(err) //nolint } return res } diff --git a/janus-gateway/streaming/main.go b/janus-gateway/streaming/main.go index 0894ff46..676321ae 100644 --- a/janus-gateway/streaming/main.go +++ b/janus-gateway/streaming/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// example of how to connect Pion and Janus package main import ( @@ -90,9 +97,14 @@ func main() { } if msg.Jsep != nil { + sdpVal, ok := msg.Jsep["sdp"].(string) + if !ok { + panic("failed to cast") + } + offer := webrtc.SessionDescription{ Type: webrtc.SDPTypeOffer, - SDP: msg.Jsep["sdp"].(string), + SDP: sdpVal, } // Create a new RTCPeerConnection diff --git a/janus-gateway/video-room/main.go b/janus-gateway/video-room/main.go index e6ab4a39..2bbd354a 100644 --- a/janus-gateway/video-room/main.go +++ b/janus-gateway/video-room/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// example of how to connect Pion and Janus package main import ( @@ -137,9 +144,13 @@ func main() { } if msg.Jsep != nil { + sdpVal, ok := msg.Jsep["sdp"].(string) + if !ok { + panic("failed to cast") + } err = peerConnection.SetRemoteDescription(webrtc.SessionDescription{ Type: webrtc.SDPTypeAnswer, - SDP: msg.Jsep["sdp"].(string), + SDP: sdpVal, }) if err != nil { panic(err) diff --git a/play-from-disk-h264/jsfiddle/demo.css b/play-from-disk-h264/jsfiddle/demo.css index 9e43d340..17524fc4 100644 --- a/play-from-disk-h264/jsfiddle/demo.css +++ b/play-from-disk-h264/jsfiddle/demo.css @@ -1,4 +1,9 @@ +/* + SPDX-FileCopyrightText: 2023 The Pion community + SPDX-License-Identifier: MIT +*/ + textarea { width: 500px; min-height: 75px; -} \ No newline at end of file +} diff --git a/play-from-disk-h264/jsfiddle/demo.details b/play-from-disk-h264/jsfiddle/demo.details index 271b5d68..75cd6c99 100644 --- a/play-from-disk-h264/jsfiddle/demo.details +++ b/play-from-disk-h264/jsfiddle/demo.details @@ -1,5 +1,8 @@ --- - name: play-from-disk-h264 - description: play-from-disk-h264 demonstrates how to send video to your browser from a file saved to disk. - authors: - - Sean DuBois +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: play-from-disk-h264 +description: play-from-disk-h264 demonstrates how to send video to your browser from a file saved to disk. +authors: + - Sean DuBois diff --git a/play-from-disk-h264/jsfiddle/demo.html b/play-from-disk-h264/jsfiddle/demo.html index 6dbbf255..8f26937e 100644 --- a/play-from-disk-h264/jsfiddle/demo.html +++ b/play-from-disk-h264/jsfiddle/demo.html @@ -1,3 +1,8 @@ + + Browser base64 Session Description

diff --git a/play-from-disk-h264/jsfiddle/demo.js b/play-from-disk-h264/jsfiddle/demo.js index c1531219..55e3f9bd 100644 --- a/play-from-disk-h264/jsfiddle/demo.js +++ b/play-from-disk-h264/jsfiddle/demo.js @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + /* eslint-env browser */ let pc = new RTCPeerConnection({ diff --git a/play-from-disk-h264/main.go b/play-from-disk-h264/main.go index a5756ad9..cd05bcce 100644 --- a/play-from-disk-h264/main.go +++ b/play-from-disk-h264/main.go @@ -1,10 +1,15 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + //go:build !js // +build !js +// play-from-disk demonstrates how to send video and/or audio to your browser from files saved to disk. package main import ( "context" + "errors" "fmt" "io" "os" @@ -103,7 +108,7 @@ func main() { //nolint ticker := time.NewTicker(h264FrameDuration) for ; true; <-ticker.C { nal, h264Err := h264.NextNAL() - if h264Err == io.EOF { + if errors.Is(h264Err, io.EOF) { fmt.Printf("All video frames parsed and sent") os.Exit(0) } @@ -167,7 +172,7 @@ func main() { //nolint ticker := time.NewTicker(oggPageDuration) for ; true; <-ticker.C { pageData, pageHeader, oggErr := ogg.ParseNextPage() - if oggErr == io.EOF { + if errors.Is(oggErr, io.EOF) { fmt.Printf("All audio pages parsed and sent") os.Exit(0) } diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..f1bb98c6 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>pion/renovate-config" + ] +} diff --git a/rtmp-to-webrtc/main.go b/rtmp-to-webrtc/main.go index d661aa0d..cb2c59e5 100644 --- a/rtmp-to-webrtc/main.go +++ b/rtmp-to-webrtc/main.go @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + //go:build !js // +build !js +// rtmp-to-webrtc demonstrates how you could re-stream media from a RTMP server to WebRTC. package main import ( diff --git a/save-to-webm/jsfiddle/demo.css b/save-to-webm/jsfiddle/demo.css index 9e43d340..17524fc4 100644 --- a/save-to-webm/jsfiddle/demo.css +++ b/save-to-webm/jsfiddle/demo.css @@ -1,4 +1,9 @@ +/* + SPDX-FileCopyrightText: 2023 The Pion community + SPDX-License-Identifier: MIT +*/ + textarea { width: 500px; min-height: 75px; -} \ No newline at end of file +} diff --git a/save-to-webm/jsfiddle/demo.details b/save-to-webm/jsfiddle/demo.details index ebf86708..82ae0ef5 100644 --- a/save-to-webm/jsfiddle/demo.details +++ b/save-to-webm/jsfiddle/demo.details @@ -1,5 +1,8 @@ --- - name: save-to-webm - description: Example of using Pion WebRTC to save video to disk in an WebM container - authors: - - Sean DuBois +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: save-to-webm +description: Example of using Pion WebRTC to save video to disk in an WebM container +authors: + - Sean DuBois diff --git a/save-to-webm/jsfiddle/demo.html b/save-to-webm/jsfiddle/demo.html index cba0be07..84036858 100644 --- a/save-to-webm/jsfiddle/demo.html +++ b/save-to-webm/jsfiddle/demo.html @@ -1,3 +1,8 @@ + + Browser base64 Session Description

diff --git a/save-to-webm/jsfiddle/demo.js b/save-to-webm/jsfiddle/demo.js index f40aae86..8c671a03 100644 --- a/save-to-webm/jsfiddle/demo.js +++ b/save-to-webm/jsfiddle/demo.js @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + /* eslint-env browser */ let pc = new RTCPeerConnection({ diff --git a/save-to-webm/main.go b/save-to-webm/main.go index 08e24d12..032d5260 100644 --- a/save-to-webm/main.go +++ b/save-to-webm/main.go @@ -1,6 +1,14 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// save-to-webm is a simple application that shows how to receive audio and video using Pion and then save to WebM container. package main import ( + "errors" "fmt" "io" "os" @@ -202,7 +210,7 @@ func createWebRTCConn(saver *webmSaver) *webrtc.PeerConnection { // Read RTP packets being sent to Pion rtp, _, readErr := track.ReadRTP() if readErr != nil { - if readErr == io.EOF { + if errors.Is(readErr, io.EOF) { return } panic(readErr) diff --git a/sfu-ws/flutter/lib/main.dart b/sfu-ws/flutter/lib/main.dart index 7c7855a8..5d127c5b 100644 --- a/sfu-ws/flutter/lib/main.dart +++ b/sfu-ws/flutter/lib/main.dart @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + import 'dart:async'; import 'dart:convert'; import 'package:flutter_webrtc/flutter_webrtc.dart'; diff --git a/sfu-ws/index.html b/sfu-ws/index.html index 48b498ee..ee062edd 100644 --- a/sfu-ws/index.html +++ b/sfu-ws/index.html @@ -1,5 +1,10 @@ + + diff --git a/sfu-ws/main.go b/sfu-ws/main.go index e173cc9c..e242ba85 100644 --- a/sfu-ws/main.go +++ b/sfu-ws/main.go @@ -1,11 +1,18 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// sfu-ws is a many-to-many websocket based SFU package main import ( "encoding/json" "flag" - "io/ioutil" "log" "net/http" + "os" "sync" "text/template" "time" @@ -15,6 +22,7 @@ import ( "github.com/pion/webrtc/v3" ) +// nolint var ( addr = flag.String("addr", ":8080", "http service address") upgrader = websocket.Upgrader{ @@ -47,7 +55,7 @@ func main() { trackLocals = map[string]*webrtc.TrackLocalStaticRTP{} // Read index.html from disk into memory, serve whenever anyone requests / - indexHTML, err := ioutil.ReadFile("index.html") + indexHTML, err := os.ReadFile("index.html") if err != nil { panic(err) } @@ -283,6 +291,7 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) { } case webrtc.PeerConnectionStateClosed: signalPeerConnections() + default: } }) diff --git a/sip-over-websocket-to-webrtc/main.go b/sip-over-websocket-to-webrtc/main.go index e7eca06e..99bad8dc 100644 --- a/sip-over-websocket-to-webrtc/main.go +++ b/sip-over-websocket-to-webrtc/main.go @@ -1,15 +1,23 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// sip-over-websocket-to-webrtc demonstrates how to connect to a SIP Server via Websocket package main import ( "flag" "fmt" - "github.com/pion/example-webrtc-applications/v3/sip-to-webrtc/softphone" + "github.com/pion/example-webrtc-applications/v3/sip-over-websocket-to-webrtc/softphone" "github.com/pion/sdp/v2" "github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3/pkg/media/oggwriter" ) +// nolint var ( username = flag.String("username", "1000", "Extension you wish to register as") password = flag.String("password", "", "Password for the extension you wish to register as") diff --git a/sip-over-websocket-to-webrtc/softphone/constants.go b/sip-over-websocket-to-webrtc/softphone/constants.go index 4e7419d0..4da391fb 100644 --- a/sip-over-websocket-to-webrtc/softphone/constants.go +++ b/sip-over-websocket-to-webrtc/softphone/constants.go @@ -1,5 +1,9 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone +// nolint var responseCodes = map[int]string{ 100: "Trying", 180: "Ringing", diff --git a/sip-over-websocket-to-webrtc/softphone/inboundcall.go b/sip-over-websocket-to-webrtc/softphone/inboundcall.go index fa4bd877..334c4363 100644 --- a/sip-over-websocket-to-webrtc/softphone/inboundcall.go +++ b/sip-over-websocket-to-webrtc/softphone/inboundcall.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import ( @@ -19,7 +22,7 @@ func (softphone *Softphone) OpenToInvite() { var msg Msg if err := xml.Unmarshal([]byte(inviteMessage.headers["P-rc"]), &msg); err != nil { - log.Panic(err) + log.Panic(err) // nolint } sipMessage := SIPMessage{} sipMessage.method = "MESSAGE" diff --git a/sip-over-websocket-to-webrtc/softphone/invite.go b/sip-over-websocket-to-webrtc/softphone/invite.go index 9fccbb8b..90a92121 100644 --- a/sip-over-websocket-to-webrtc/softphone/invite.go +++ b/sip-over-websocket-to-webrtc/softphone/invite.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import ( diff --git a/sip-over-websocket-to-webrtc/softphone/rcmessage.go b/sip-over-websocket-to-webrtc/softphone/rcmessage.go index c592fcc7..3bfdc6c9 100644 --- a/sip-over-websocket-to-webrtc/softphone/rcmessage.go +++ b/sip-over-websocket-to-webrtc/softphone/rcmessage.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import "encoding/xml" diff --git a/sip-over-websocket-to-webrtc/softphone/register.go b/sip-over-websocket-to-webrtc/softphone/register.go index 9a388c1d..d01e5c68 100644 --- a/sip-over-websocket-to-webrtc/softphone/register.go +++ b/sip-over-websocket-to-webrtc/softphone/register.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import ( @@ -20,7 +23,7 @@ func (softphone *Softphone) register() { conn, _, err := dialer.Dial(url.String(), nil) if err != nil { - log.Fatal(err) + log.Fatal(err) // nolint } softphone.wsConn = conn @@ -29,7 +32,7 @@ func (softphone *Softphone) register() { for { _, bytes, err := conn.ReadMessage() if err != nil { - log.Fatal(err) + log.Fatal(err) // nolint } message := string(bytes) diff --git a/sip-over-websocket-to-webrtc/softphone/sipmessage.go b/sip-over-websocket-to-webrtc/softphone/sipmessage.go index 5b80f8a6..b717708f 100644 --- a/sip-over-websocket-to-webrtc/softphone/sipmessage.go +++ b/sip-over-websocket-to-webrtc/softphone/sipmessage.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import ( diff --git a/sip-over-websocket-to-webrtc/softphone/softphone.go b/sip-over-websocket-to-webrtc/softphone/softphone.go index 24b6050d..14fa37b3 100644 --- a/sip-over-websocket-to-webrtc/softphone/softphone.go +++ b/sip-over-websocket-to-webrtc/softphone/softphone.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + // Package softphone provides abstractions for SIP over Websocket package softphone @@ -65,14 +68,14 @@ func (softphone *Softphone) request(sipMessage SIPMessage, responseHandler func( } if err := softphone.wsConn.WriteMessage(1, []byte(sipMessage.ToString())); err != nil { - log.Fatal(err) + log.Fatal(err) // nolint } } func (softphone *Softphone) response(message string) { - log.Print("↑↑↑\n", message) + log.Print("↑↑↑\n", message) // nolint if err := softphone.wsConn.WriteMessage(1, []byte(message)); err != nil { - log.Fatal(err) + log.Fatal(err) // nolint } } diff --git a/sip-over-websocket-to-webrtc/softphone/utils.go b/sip-over-websocket-to-webrtc/softphone/utils.go index 4220c1d9..620543c0 100644 --- a/sip-over-websocket-to-webrtc/softphone/utils.go +++ b/sip-over-websocket-to-webrtc/softphone/utils.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package softphone import ( diff --git a/snapshot/index.html b/snapshot/index.html index 4ca33bde..7c4a1974 100644 --- a/snapshot/index.html +++ b/snapshot/index.html @@ -1,4 +1,9 @@ + + snapshot diff --git a/snapshot/main.go b/snapshot/main.go index c9268df3..e23a2da0 100644 --- a/snapshot/main.go +++ b/snapshot/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// snapshot shows how you can convert incoming video frames to jpeg and serve them via HTTP. package main import ( @@ -107,7 +114,7 @@ func signaling(w http.ResponseWriter, r *http.Request) { } } -func snapshot(w http.ResponseWriter, r *http.Request) { +func snapshot(w http.ResponseWriter, _ *http.Request) { // Initialized with 20 maxLate, my samples sometimes 10-15 packets sampleBuilder := samplebuilder.New(20, &codecs.VP8Packet{}, 90000) decoder := vp8.NewDecoder() diff --git a/twitch/main.go b/twitch/main.go index 8e3d3ab7..a90efa36 100644 --- a/twitch/main.go +++ b/twitch/main.go @@ -1,7 +1,15 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// Twitch is an example of ingesting WebRTC and streaming to Twitch package main import ( "bufio" + "errors" "fmt" "io" "os" @@ -17,6 +25,7 @@ import ( "github.com/pion/webrtc/v3/pkg/media/samplebuilder" ) +// nolint var ( audioWriter, videoWriter webm.BlockWriteCloser audioBuilder, videoBuilder *samplebuilder.SampleBuilder @@ -87,7 +96,7 @@ func main() { // Read RTP packets being sent to Pion rtp, _, readErr := track.ReadRTP() if readErr != nil { - if readErr == io.EOF { + if errors.Is(readErr, io.EOF) { return } panic(readErr) diff --git a/unreal-pixel-streaming/main.go b/unreal-pixel-streaming/main.go index 71028513..ec62da30 100644 --- a/unreal-pixel-streaming/main.go +++ b/unreal-pixel-streaming/main.go @@ -1,3 +1,10 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + +//go:build !js +// +build !js + +// unreal-pixel-streaming demonstrates how to connect to a Unreal Pixel Streaming instance and accept the inbound audio/video package main import (