diff --git a/.github/generate-authors.sh b/.github/generate-authors.sh index 182e4f5e738..6152721515f 100755 --- a/.github/generate-authors.sh +++ b/.github/generate-authors.sh @@ -12,10 +12,10 @@ set -e SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -AUTHORS_PATH="$GITHUB_WORKSPACE/AUTHORS.txt" +GIT_WORKDIR=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)} +AUTHORS_PATH="${GIT_WORKDIR}/AUTHORS.txt" -if [ -f ${SCRIPT_PATH}/.ci.conf ] -then +if [ -f ${SCRIPT_PATH}/.ci.conf ]; then . ${SCRIPT_PATH}/.ci.conf fi @@ -31,8 +31,7 @@ EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion B CONTRIBUTORS=() shouldBeIncluded () { - for i in "${EXCLUDED_CONTRIBUTORS[@]}" - do + for i in "${EXCLUDED_CONTRIBUTORS[@]}"; do if [[ $1 =~ "$i" ]]; then return 1 fi @@ -42,25 +41,23 @@ shouldBeIncluded () { IFS=$'\n' #Only split on newline -for contributor in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf) -do - if shouldBeIncluded $contributor; then - CONTRIBUTORS+=("$contributor") +for CONTRIBUTOR in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf); do + if shouldBeIncluded ${CONTRIBUTOR}; then + CONTRIBUTORS+=("${CONTRIBUTOR}") fi done unset IFS if [ ${#CONTRIBUTORS[@]} -ne 0 ]; then - cat >$AUTHORS_PATH <<-'EOH' + cat >${AUTHORS_PATH} <<-'EOH' # Thank you to everyone that made Pion possible. If you are interested in contributing # we would love to have you https://github.com/pion/webrtc/wiki/Contributing # # This file is auto generated, using git to list all individuals contributors. # see `.github/generate-authors.sh` for the scripting EOH - for i in "${CONTRIBUTORS[@]}" - do - echo "$i" >> $AUTHORS_PATH + for i in "${CONTRIBUTORS[@]}"; do + echo "$i" >> ${AUTHORS_PATH} done exit 0 fi diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh index 73d20a4e4cb..cd899d4f6fb 100755 --- a/.github/install-hooks.sh +++ b/.github/install-hooks.sh @@ -11,6 +11,6 @@ SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -cp "$SCRIPT_PATH/hooks/commit-msg.sh" "$SCRIPT_PATH/../.git/hooks/commit-msg" -cp "$SCRIPT_PATH/hooks/pre-commit.sh" "$SCRIPT_PATH/../.git/hooks/pre-commit" -cp "$SCRIPT_PATH/hooks/pre-push.sh" "$SCRIPT_PATH/../.git/hooks/pre-push" +cp "${SCRIPT_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg" +cp "${SCRIPT_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit" +cp "${SCRIPT_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push" diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh index 010a332867b..2beb31d7122 100755 --- a/.github/lint-commit-message.sh +++ b/.github/lint-commit-message.sh @@ -58,7 +58,7 @@ if [ "$#" -eq 1 ]; then fi lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")" else - for commit in $(git rev-list --no-merges origin/master..); do - lint_commit_message "$(git log --format="%B" -n 1 $commit)" + for COMMIT in $(git rev-list --no-merges origin/master..); do + lint_commit_message "$(git log --format="%B" -n 1 ${COMMIT})" done fi diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh index 8ce5d096f5e..9dd988f598c 100755 --- a/.github/lint-disallowed-functions-in-library.sh +++ b/.github/lint-disallowed-functions-in-library.sh @@ -13,36 +13,31 @@ set -e # Disallow usages of functions that cause the program to exit in the library code SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -if [ -f ${SCRIPT_PATH}/.ci.conf ] -then +if [ -f ${SCRIPT_PATH}/.ci.conf ]; then . ${SCRIPT_PATH}/.ci.conf fi EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"} DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(' 'print(' 'println(') -files=$( - find "$SCRIPT_PATH/.." -name "*.go" \ +FILES=$( + find "${SCRIPT_PATH}/.." -name "*.go" \ | grep -v -e '^.*_test.go$' \ - | while read file - do - excluded=false - for ex in $EXCLUDE_DIRECTORIES - do - if [[ $file == */$ex/* ]] - then - excluded=true + | while read FILE; do + EXCLUDED=false + for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do + if [[ ${FILE} == */${EXCLUDE_DIRECTORY}/* ]]; then + EXCLUDED=true break fi done - $excluded || echo "$file" + ${EXCLUDED} || echo "${FILE}" done ) -for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}" -do - if grep -e "\s$disallowedFunction" $files | grep -v -e 'nolint'; then - echo "$disallowedFunction may only be used in example code" +for DISALLOWED_FUNCTION in "${DISALLOWED_FUNCTIONS[@]}"; do + if grep -e "\s${DISALLOWED_FUNCTION}" ${FILES} | grep -v -e 'nolint'; then + echo "${DISALLOWED_FUNCTION} may only be used in example code" exit 1 fi done diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh index 81b3f14f178..3e7d1b961de 100755 --- a/.github/lint-filename.sh +++ b/.github/lint-filename.sh @@ -14,11 +14,11 @@ set -e SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) GO_REGEX="^[a-zA-Z][a-zA-Z0-9_]*\.go$" -find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do - filename=$(basename -- "$fullpath") +find "${SCRIPT_PATH}/.." -name "*.go" | while read FULLPATH; do + FILENAME=$(basename -- "${FULLPATH}") - if ! [[ $filename =~ $GO_REGEX ]]; then - echo "$filename is not a valid filename for Go code, only alpha, numbers and underscores are supported" + if ! [[ ${FILENAME} =~ ${GO_REGEX} ]]; then + echo "${FILENAME} is not a valid filename for Go code, only alpha, numbers and underscores are supported" exit 1 fi done diff --git a/.github/lint-no-trailing-newline-in-log-messages.sh b/.github/lint-no-trailing-newline-in-log-messages.sh index 29cd4a28cd5..f0dad5994e1 100755 --- a/.github/lint-no-trailing-newline-in-log-messages.sh +++ b/.github/lint-no-trailing-newline-in-log-messages.sh @@ -13,29 +13,25 @@ set -e # Disallow usages of functions that cause the program to exit in the library code SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -if [ -f ${SCRIPT_PATH}/.ci.conf ] -then +if [ -f ${SCRIPT_PATH}/.ci.conf ]; then . ${SCRIPT_PATH}/.ci.conf fi -files=$( - find "$SCRIPT_PATH/.." -name "*.go" \ - | while read file - do - excluded=false - for ex in $EXCLUDE_DIRECTORIES - do - if [[ $file == */$ex/* ]] - then - excluded=true +FILES=$( + find "${SCRIPT_PATH}/.." -name "*.go" \ + | while read FILE; do + EXCLUDED=false + for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do + if [[ $file == */${EXCLUDE_DIRECTORY}/* ]]; then + EXCLUDED=true break fi done - $excluded || echo "$file" + ${EXCLUDED} || echo "${FILE}" done ) -if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then +if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' ${FILES} | grep -v -e 'nolint'; then echo "Log format strings should have trailing new-line" exit 1 fi \ No newline at end of file diff --git a/.github/workflows/examples-tests.yaml b/.github/workflows/examples-tests.yaml new file mode 100644 index 00000000000..1791be42e49 --- /dev/null +++ b/.github/workflows/examples-tests.yaml @@ -0,0 +1,19 @@ +name: Examples Tests +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + pion-to-pion-test: + name: Test + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + - name: test + run: cd examples/pion-to-pion && ./test.sh + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..b5b64e019bd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: release +on: + push: + tags: + - 'v*' + +jobs: + release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: '1.18' # auto-update/latest-go-version + - name: Build and release + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 300fac6a2a0..93d0406ac0f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.17", "1.18"] + go: ["1.17", "1.18"] # auto-update/supported-go-version-list fail-fast: false name: Go ${{ matrix.go }} steps: @@ -89,7 +89,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.17", "1.18"] + go: ["1.17", "1.18"] # auto-update/supported-go-version-list fail-fast: false name: Go i386 ${{ matrix.go }} steps: @@ -145,7 +145,7 @@ jobs: - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - env: - GO_VERSION: 1.17 + GO_VERSION: 1.17 # auto-update/latest-go-version - name: Set Go Root run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index fa52ce94373..ff2ef50dbda 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -29,6 +29,8 @@ jobs: uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v3 + with: + go-version: 1.17 # auto-update/latest-go-version - name: check run: | go mod download diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000000..2caa5fbd3b5 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,2 @@ +builds: +- skip: true diff --git a/AUTHORS.txt b/AUTHORS.txt index f73f8863000..62c49503302 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -60,6 +60,7 @@ donotanswer earle Egon Elbre Eric Daniels +Eric Fontaine feixiao Forest Johnson frank @@ -117,6 +118,7 @@ Michiel De Backker <38858977+backkem@users.noreply.github.com> Mike Coleman Mindgamesnl mission-liao +mr-shitij <21.shitijagrawal@gmail.com> mxmCherry Nam V. Do Nick Mykins @@ -150,6 +152,7 @@ ronan Ryan Shumate salmān aljammāz Sam Lancia +Sean DuBois Sean DuBois Sean DuBois Sean DuBois @@ -162,6 +165,7 @@ Simone Gotti Slugalisk soolaugust spaceCh1mp +stephanrotolante Suhas Gaddam Suzuki Takeo sylba2050 @@ -177,6 +181,7 @@ Will Forcey Will Watson Woodrow Douglass xsbchen +Yoon SeungYong Yuki Igarashi yusuke Yutaka Takeda diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 8cc51278ad1..c19fe39e068 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -91,7 +91,7 @@ func TestE2E_Audio(t *testing.T) { } var result string if err := page.RunScript( - "pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(answer)))", + "pc.setRemoteDescription(JSON.parse(answer))", map[string]interface{}{"answer": string(answerBytes)}, &result, ); err != nil { @@ -231,7 +231,7 @@ func TestE2E_DataChannel(t *testing.T) { } var result string if err := page.RunScript( - "pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(answer)))", + "pc.setRemoteDescription(JSON.parse(answer))", map[string]interface{}{"answer": string(answerBytes)}, &result, ); err != nil { diff --git a/examples/broadcast/README.md b/examples/broadcast/README.md index 07fe41e2be3..8fc5dd8362c 100644 --- a/examples/broadcast/README.md +++ b/examples/broadcast/README.md @@ -11,7 +11,7 @@ go get github.com/pion/webrtc/v3/examples/broadcast ``` ### Open broadcast example page -[jsfiddle.net](https://jsfiddle.net/ypcsbnu3/) You should see two buttons `Publish a Broadcast` and `Join a Broadcast` +[jsfiddle.net](https://jsfiddle.net/us4h58jx/) You should see two buttons `Publish a Broadcast` and `Join a Broadcast` ### Run Broadcast #### Linux/macOS diff --git a/examples/broadcast/jsfiddle/demo.js b/examples/broadcast/jsfiddle/demo.js index 946a5551ab7..49734bbc3c5 100644 --- a/examples/broadcast/jsfiddle/demo.js +++ b/examples/broadcast/jsfiddle/demo.js @@ -48,7 +48,7 @@ window.createSession = isPublisher => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/data-channels/README.md b/examples/data-channels/README.md index c9d9c45d351..49b9130b5cb 100644 --- a/examples/data-channels/README.md +++ b/examples/data-channels/README.md @@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/data-channels ``` ### Open data-channels example page -[jsfiddle.net](https://jsfiddle.net/t3johb5g/2/) +[jsfiddle.net](https://jsfiddle.net/e41tgovp/) ### Run data-channels, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's session description, press `Copy browser SDP to clipboard` or copy the base64 string manually and: diff --git a/examples/data-channels/jsfiddle/demo.js b/examples/data-channels/jsfiddle/demo.js index c0e88a69522..5dc394dcb4e 100644 --- a/examples/data-channels/jsfiddle/demo.js +++ b/examples/data-channels/jsfiddle/demo.js @@ -42,7 +42,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/ice-single-port/README.md b/examples/ice-single-port/README.md index 098d0a7f162..994d23756de 100644 --- a/examples/ice-single-port/README.md +++ b/examples/ice-single-port/README.md @@ -2,8 +2,8 @@ ice-single-port demonstrates Pion WebRTC's ability to serve many PeerConnections on a single port. Pion WebRTC has no global state, so by default ports can't be shared between two PeerConnections. -Using the SettingEngine a developer can manually share state between many PeerConnections and allow -multiple to use the same port +Using the SettingEngine, a developer can manually share state between many PeerConnections to allow +multiple PeerConnections to use the same port. ## Instructions @@ -21,8 +21,8 @@ cd webrtc/examples/ice-single-port Execute `go run *.go` ### Open the Web UI -Open [http://localhost:8080](http://localhost:8080). This will automatically open 5 PeerConnections. This page will print +Open [http://localhost:8080](http://localhost:8080). This will automatically open 10 PeerConnections. This page will print a Local/Remote line for each PeerConnection. Note that all 10 PeerConnections have different ports for their Local port. However for the remote they all will be using port 8443. -Congrats, you have used Pion WebRTC! Now start building something cool +Congrats, you have used Pion WebRTC! Now start building something cool. diff --git a/examples/ice-single-port/main.go b/examples/ice-single-port/main.go index 21f8e50a775..4de48c6900e 100644 --- a/examples/ice-single-port/main.go +++ b/examples/ice-single-port/main.go @@ -6,10 +6,10 @@ package main import ( "encoding/json" "fmt" - "net" "net/http" "time" + "github.com/pion/ice/v2" "github.com/pion/webrtc/v3" ) @@ -75,24 +75,19 @@ func doSignaling(w http.ResponseWriter, r *http.Request) { } func main() { - // Listen on UDP Port 8443, will be used for all WebRTC traffic - udpListener, err := net.ListenUDP("udp", &net.UDPAddr{ - IP: net.IP{0, 0, 0, 0}, - Port: 8443, - }) - if err != nil { - panic(err) - } - - fmt.Printf("Listening for WebRTC traffic at %s\n", udpListener.LocalAddr()) - // Create a SettingEngine, this allows non-standard WebRTC behavior settingEngine := webrtc.SettingEngine{} // Configure our SettingEngine to use our UDPMux. By default a PeerConnection has // no global state. The API+SettingEngine allows the user to share state between them. // In this case we are sharing our listening port across many. - settingEngine.SetICEUDPMux(webrtc.NewICEUDPMux(nil, udpListener)) + // Listen on UDP Port 8443, will be used for all WebRTC traffic + mux, err := ice.NewMultiUDPMuxFromPort(8443) + if err != nil { + panic(err) + } + fmt.Printf("Listening for WebRTC traffic at %d\n", 8443) + settingEngine.SetICEUDPMux(mux) // Create a new API using our SettingEngine api = webrtc.NewAPI(webrtc.WithSettingEngine(settingEngine)) diff --git a/examples/insertable-streams/README.md b/examples/insertable-streams/README.md index c4bf0795173..6f077f06aa0 100644 --- a/examples/insertable-streams/README.md +++ b/examples/insertable-streams/README.md @@ -19,7 +19,7 @@ go get github.com/pion/webrtc/v3/examples/insertable-streams ``` ### Open insertable-streams example page -[jsfiddle.net](https://jsfiddle.net/uqr80Lak/) you should see two text-areas and a 'Start Session' button. You will also have a 'Decrypt' checkbox. +[jsfiddle.net](https://jsfiddle.net/t5xoaryc/) you should see two text-areas and a 'Start Session' button. You will also have a 'Decrypt' checkbox. When unchecked the browser will not decrypt the incoming video stream, so it will stop playing or display certificates. ### Run insertable-streams with your browsers SessionDescription as stdin diff --git a/examples/insertable-streams/jsfiddle/demo.js b/examples/insertable-streams/jsfiddle/demo.js index ff2be92d135..9e9d5861558 100644 --- a/examples/insertable-streams/jsfiddle/demo.js +++ b/examples/insertable-streams/jsfiddle/demo.js @@ -60,7 +60,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/pion-to-pion/answer/Dockerfile b/examples/pion-to-pion/answer/Dockerfile index 899ff7f8009..5897317578a 100644 --- a/examples/pion-to-pion/answer/Dockerfile +++ b/examples/pion-to-pion/answer/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.19 ENV GO111MODULE=on -RUN go get -u github.com/pion/webrtc/v3/examples/pion-to-pion/answer +RUN go install github.com/pion/webrtc/v3/examples/pion-to-pion/answer@latest CMD ["answer"] diff --git a/examples/pion-to-pion/docker-compose.yml b/examples/pion-to-pion/docker-compose.yml index f36eb003b13..fff78574fe0 100644 --- a/examples/pion-to-pion/docker-compose.yml +++ b/examples/pion-to-pion/docker-compose.yml @@ -3,15 +3,11 @@ services: answer: container_name: answer build: ./answer - hostname: answer - restart: always - ports: - - 50000:50000 - + command: answer -offer-address offer:50000 + offer: - depends_on: - - answer container_name: offer + depends_on: + - answer build: ./offer - hostname: offer - restart: always \ No newline at end of file + command: offer -answer-address answer:60000 diff --git a/examples/pion-to-pion/offer/Dockerfile b/examples/pion-to-pion/offer/Dockerfile index f88ee6d02cb..a8f0f08e42a 100644 --- a/examples/pion-to-pion/offer/Dockerfile +++ b/examples/pion-to-pion/offer/Dockerfile @@ -1,6 +1,6 @@ FROM golang:1.19 ENV GO111MODULE=on -RUN go get -u github.com/pion/webrtc/v3/examples/pion-to-pion/offer +RUN go install github.com/pion/webrtc/v3/examples/pion-to-pion/offer@latest CMD ["offer"] diff --git a/examples/pion-to-pion/test.sh b/examples/pion-to-pion/test.sh new file mode 100755 index 00000000000..0ae41c3ddfb --- /dev/null +++ b/examples/pion-to-pion/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash -eu + +docker compose up -d + +function on_exit { + docker compose logs + docker compose rm -fsv +} + +trap on_exit EXIT + +TIMEOUT=10 +timeout $TIMEOUT docker compose logs -f | grep -q "answer | Message from DataChannel" +timeout $TIMEOUT docker compose logs -f | grep -q "offer | Message from DataChannel" diff --git a/examples/play-from-disk/README.md b/examples/play-from-disk/README.md index 15204ec9445..2dfe70e368f 100644 --- a/examples/play-from-disk/README.md +++ b/examples/play-from-disk/README.md @@ -20,7 +20,7 @@ go get github.com/pion/webrtc/v3/examples/play-from-disk ``` ### Open play-from-disk example page -[jsfiddle.net](https://jsfiddle.net/a1cz42op/) you should see two text-areas, 'Start Session' button and 'Copy browser SessionDescription to clipboard' +[jsfiddle.net](https://jsfiddle.net/8kup9mvn/) you should see two text-areas, 'Start Session' button and 'Copy browser SessionDescription to clipboard' ### Run play-from-disk with your browsers Session Description as stdin The `output.ivf` you created should be in the same directory as `play-from-disk`. In the jsfiddle press 'Copy browser Session Description to clipboard' or copy the base64 string manually. diff --git a/examples/play-from-disk/jsfiddle/demo.js b/examples/play-from-disk/jsfiddle/demo.js index f9afa945c9b..d3c3dd6360b 100644 --- a/examples/play-from-disk/jsfiddle/demo.js +++ b/examples/play-from-disk/jsfiddle/demo.js @@ -42,7 +42,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/reflect/README.md b/examples/reflect/README.md index 96e25a5aa9b..32a35faa0f4 100644 --- a/examples/reflect/README.md +++ b/examples/reflect/README.md @@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/reflect ``` ### Open reflect example page -[jsfiddle.net](https://jsfiddle.net/ogs7muqh/1/) you should see two text-areas and a 'Start Session' button. +[jsfiddle.net](https://jsfiddle.net/g643ft1k/) you should see two text-areas and a 'Start Session' button. ### Run reflect, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's Session Description. Press `Copy browser SDP to clipboard` or copy the base64 string manually. diff --git a/examples/reflect/jsfiddle/demo.js b/examples/reflect/jsfiddle/demo.js index 7c1b68580a9..ced45c4ce62 100644 --- a/examples/reflect/jsfiddle/demo.js +++ b/examples/reflect/jsfiddle/demo.js @@ -39,7 +39,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/rtcp-processing/README.md b/examples/rtcp-processing/README.md index 775bcc41b8f..5ee354b7662 100644 --- a/examples/rtcp-processing/README.md +++ b/examples/rtcp-processing/README.md @@ -16,7 +16,7 @@ go get github.com/pion/webrtc/v3/examples/rtcp-processing ``` ### Open rtcp-processing example page -[jsfiddle.net](https://jsfiddle.net/Le3zg7sd/) you should see two text-areas, 'Start Session' button and 'Copy browser SessionDescription to clipboard' +[jsfiddle.net](https://jsfiddle.net/zurq6j7x/) you should see two text-areas, 'Start Session' button and 'Copy browser SessionDescription to clipboard' ### Run rtcp-processing with your browsers Session Description as stdin In the jsfiddle press 'Copy browser Session Description to clipboard' or copy the base64 string manually. diff --git a/examples/rtcp-processing/jsfiddle/demo.js b/examples/rtcp-processing/jsfiddle/demo.js index 41cd47c1434..6f788f65bae 100644 --- a/examples/rtcp-processing/jsfiddle/demo.js +++ b/examples/rtcp-processing/jsfiddle/demo.js @@ -40,7 +40,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/rtp-forwarder/README.md b/examples/rtp-forwarder/README.md index 27f59613e06..a2d59036d6d 100644 --- a/examples/rtp-forwarder/README.md +++ b/examples/rtp-forwarder/README.md @@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/rtp-forwarder ``` ### Open rtp-forwarder example page -[jsfiddle.net](https://jsfiddle.net/xjcve6d3/) you should see your Webcam, two text-areas and `Copy browser SDP to clipboard`, `Start Session` buttons +[jsfiddle.net](https://jsfiddle.net/fm7btvr3/) you should see your Webcam, two text-areas and `Copy browser SDP to clipboard`, `Start Session` buttons ### Run rtp-forwarder, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's Session Description. Press `Copy browser SDP to clipboard` or copy the base64 string manually. diff --git a/examples/rtp-forwarder/jsfiddle/demo.js b/examples/rtp-forwarder/jsfiddle/demo.js index 1eba38b99d3..b7e8d925f54 100644 --- a/examples/rtp-forwarder/jsfiddle/demo.js +++ b/examples/rtp-forwarder/jsfiddle/demo.js @@ -32,7 +32,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/save-to-disk/README.md b/examples/save-to-disk/README.md index cf316e0053f..53ff188d846 100644 --- a/examples/save-to-disk/README.md +++ b/examples/save-to-disk/README.md @@ -11,7 +11,7 @@ go get github.com/pion/webrtc/v3/examples/save-to-disk ``` ### Open save-to-disk example page -[jsfiddle.net](https://jsfiddle.net/xjcve6d3/) you should see your Webcam, two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. +[jsfiddle.net](https://jsfiddle.net/s179hacu/) you should see your Webcam, two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. ### Run save-to-disk, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's Session Description. Press `Copy browser SDP to clipboard` or copy the base64 string manually. diff --git a/examples/save-to-disk/jsfiddle/demo.js b/examples/save-to-disk/jsfiddle/demo.js index d3ee36d9f7d..64eb3d2ba4e 100644 --- a/examples/save-to-disk/jsfiddle/demo.js +++ b/examples/save-to-disk/jsfiddle/demo.js @@ -33,7 +33,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/simulcast/README.md b/examples/simulcast/README.md index 7d7ed4b41d4..5077f01002d 100644 --- a/examples/simulcast/README.md +++ b/examples/simulcast/README.md @@ -13,7 +13,7 @@ go get github.com/pion/webrtc/v3/examples/simulcast ``` ### Open simulcast example page -[jsfiddle.net](https://jsfiddle.net/zLebmv41/1/) you should see two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. +[jsfiddle.net](https://jsfiddle.net/tz4d5bhj/) you should see two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. ### Run simulcast, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's Session Description. Press `Copy browser SDP to clipboard` or copy the base64 string manually. diff --git a/examples/simulcast/jsfiddle/demo.js b/examples/simulcast/jsfiddle/demo.js index cc0ebf3de89..b7fbc664925 100644 --- a/examples/simulcast/jsfiddle/demo.js +++ b/examples/simulcast/jsfiddle/demo.js @@ -85,7 +85,7 @@ window.startSession = () => { try { console.log('answer', JSON.parse(atob(sd))) - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/examples/swap-tracks/README.md b/examples/swap-tracks/README.md index c278f8a7fb9..d5771592c40 100644 --- a/examples/swap-tracks/README.md +++ b/examples/swap-tracks/README.md @@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/swap-tracks ``` ### Open swap-tracks example page -[jsfiddle.net](https://jsfiddle.net/39w24tr6/1/) you should see two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. +[jsfiddle.net](https://jsfiddle.net/1rx5on86/) you should see two text-areas and two buttons: `Copy browser SDP to clipboard`, `Start Session`. ### Run swap-tracks, with your browsers SessionDescription as stdin In the jsfiddle the top textarea is your browser's Session Description. Press `Copy browser SDP to clipboard` or copy the base64 string manually. diff --git a/examples/swap-tracks/jsfiddle/demo.js b/examples/swap-tracks/jsfiddle/demo.js index 7688b8ebf0d..52d3479e974 100644 --- a/examples/swap-tracks/jsfiddle/demo.js +++ b/examples/swap-tracks/jsfiddle/demo.js @@ -68,7 +68,7 @@ window.startSession = () => { } try { - pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd)))) + pc.setRemoteDescription(JSON.parse(atob(sd))) } catch (e) { alert(e) } diff --git a/go.mod b/go.mod index f1bd091a189..5edbea565df 100644 --- a/go.mod +++ b/go.mod @@ -5,21 +5,20 @@ go 1.13 require ( github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.17.0 // indirect - github.com/pion/datachannel v1.5.2 + github.com/pion/datachannel v1.5.5 github.com/pion/dtls/v2 v2.1.5 - github.com/pion/ice/v2 v2.2.10 + github.com/pion/ice/v2 v2.2.12 github.com/pion/interceptor v0.1.11 github.com/pion/logging v0.2.2 github.com/pion/randutil v0.1.0 github.com/pion/rtcp v1.2.10 github.com/pion/rtp v1.7.13 - github.com/pion/sctp v1.8.2 + github.com/pion/sctp v1.8.5 github.com/pion/sdp/v3 v3.0.6 github.com/pion/srtp/v2 v2.0.10 - github.com/pion/transport v0.13.1 + github.com/pion/transport v0.14.1 github.com/sclevine/agouti v3.0.0+incompatible - github.com/stretchr/testify v1.7.1 - golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect - golang.org/x/net v0.0.0-20220927171203-f486391704dc - golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect + github.com/stretchr/testify v1.8.1 + golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect + golang.org/x/net v0.3.0 ) diff --git a/go.sum b/go.sum index fc7a89f31da..2726646bac9 100644 --- a/go.sum +++ b/go.sum @@ -40,12 +40,12 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6E= -github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ= +github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew8= +github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0= github.com/pion/dtls/v2 v2.1.5 h1:jlh2vtIyUBShchoTDqpCCqiYCyRFJ/lvf/gQ8TALs+c= github.com/pion/dtls/v2 v2.1.5/go.mod h1:BqCE7xPZbPSubGasRoDFJeTsyJtdD1FanJYL0JGheqY= -github.com/pion/ice/v2 v2.2.10 h1:i8rn0iIN8wHlS9wosoHS3Du4hYwx+TjBEluisXYtQVE= -github.com/pion/ice/v2 v2.2.10/go.mod h1:J6HhupoMLTOv0yALipuOHEPoSMk7dm1ofwUI1KHVHk8= +github.com/pion/ice/v2 v2.2.12 h1:n3M3lUMKQM5IoofhJo73D3qVla+mJN2nVvbSPq32Nig= +github.com/pion/ice/v2 v2.2.12/go.mod h1:z2KXVFyRkmjetRlaVRgjO9U3ShKwzhlUylvxKfHfd5A= github.com/pion/interceptor v0.1.11 h1:00U6OlqxA3FFB50HSg25J/8cWi7P6FbSzw4eFn24Bvs= github.com/pion/interceptor v0.1.11/go.mod h1:tbtKjZY14awXd7Bq0mmWvgtHB5MDaRN7HV3OZ/uy7s8= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= @@ -59,9 +59,8 @@ github.com/pion/rtcp v1.2.10 h1:nkr3uj+8Sp97zyItdN60tE/S6vk4al5CPRR6Gejsdjc= github.com/pion/rtcp v1.2.10/go.mod h1:ztfEwXZNLGyF1oQDttz/ZKIBaeeg/oWbRYqzBM9TL1I= github.com/pion/rtp v1.7.13 h1:qcHwlmtiI50t1XivvoawdCGTP4Uiypzfrsap+bijcoA= github.com/pion/rtp v1.7.13/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= -github.com/pion/sctp v1.8.0/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s= -github.com/pion/sctp v1.8.2 h1:yBBCIrUMJ4yFICL3RIvR4eh/H2BTTvlligmSTy+3kiA= -github.com/pion/sctp v1.8.2/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s= +github.com/pion/sctp v1.8.5 h1:JCc25nghnXWOlSn3OVtEnA9PjQ2JsxQbG+CXZ1UkJKQ= +github.com/pion/sctp v1.8.5/go.mod h1:SUFFfDpViyKejTAdwD1d/HQsCu+V/40cCs2nZIvC3s0= github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw= github.com/pion/sdp/v3 v3.0.6/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw= github.com/pion/srtp/v2 v2.0.10 h1:b8ZvEuI+mrL8hbr/f1YiJFB34UMrOac3R3N1yq2UN0w= @@ -69,10 +68,10 @@ github.com/pion/srtp/v2 v2.0.10/go.mod h1:XEeSWaK9PfuMs7zxXyiN252AHPbH12NX5q/CFD github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg= github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA= github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= -github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A= github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g= -github.com/pion/transport v0.13.1 h1:/UH5yLeQtwm2VZIPjxwnNFxjS4DFhyLfS4GlfuKUzfA= github.com/pion/transport v0.13.1/go.mod h1:EBxbqzyv+ZrmDb82XswEE0BjfQFtuw1Nu6sjnjWCsGg= +github.com/pion/transport v0.14.1 h1:XSM6olwW+o8J4SCmOBb/BpwZypkHeyM0PGFCxNQBr40= +github.com/pion/transport v0.14.1/go.mod h1:4tGmbk00NeYA3rUa9+n+dzCCoKkcy3YlYb99Jn2fNnI= github.com/pion/turn/v2 v2.0.8 h1:KEstL92OUN3k5k8qxsXHpr7WWfrdp7iJZHx99ud8muw= github.com/pion/turn/v2 v2.0.8/go.mod h1:+y7xl719J8bAEVpSXBXvTxStjJv3hbz9YFflvkpcGPw= github.com/pion/udp v0.1.1 h1:8UAPvyqmsxK8oOjloDk4wUt63TzFe9WEJkg5lChlj7o= @@ -82,19 +81,26 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sclevine/agouti v3.0.0+incompatible h1:8IBJS6PWz3uTlMP3YBIR5f+KAldcGuOeFkFbUWfBgK4= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A= -golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI= +golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -102,17 +108,20 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20220927171203-f486391704dc h1:FxpXZdoBqT8RjqTy6i1E8nXHhW21wK7ptQ/EPIGxzPQ= -golang.org/x/net v0.0.0-20220927171203-f486391704dc/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -129,19 +138,26 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -167,5 +183,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/icegatherer.go b/icegatherer.go index 5e94368a939..a38f08b7471 100644 --- a/icegatherer.go +++ b/icegatherer.go @@ -108,6 +108,7 @@ func (g *ICEGatherer) createAgent() error { IPFilter: g.api.settingEngine.candidates.IPFilter, NAT1To1IPs: g.api.settingEngine.candidates.NAT1To1IPs, NAT1To1IPCandidateType: nat1To1CandiTyp, + IncludeLoopback: g.api.settingEngine.candidates.IncludeLoopbackCandidate, Net: g.api.settingEngine.vnet, MulticastDNSMode: mDNSMode, MulticastDNSHostName: g.api.settingEngine.candidates.MulticastDNSHostName, @@ -142,10 +143,7 @@ func (g *ICEGatherer) Gather() error { return err } - g.lock.Lock() - agent := g.agent - g.lock.Unlock() - + agent := g.getAgent() // it is possible agent had just been closed if agent == nil { return fmt.Errorf("%w: unable to gather", errICEAgentNotExist) @@ -205,7 +203,13 @@ func (g *ICEGatherer) GetLocalParameters() (ICEParameters, error) { return ICEParameters{}, err } - frag, pwd, err := g.agent.GetLocalUserCredentials() + agent := g.getAgent() + // it is possible agent had just been closed + if agent == nil { + return ICEParameters{}, fmt.Errorf("%w: unable to get local parameters", errICEAgentNotExist) + } + + frag, pwd, err := agent.GetLocalUserCredentials() if err != nil { return ICEParameters{}, err } @@ -222,7 +226,14 @@ func (g *ICEGatherer) GetLocalCandidates() ([]ICECandidate, error) { if err := g.createAgent(); err != nil { return nil, err } - iceCandidates, err := g.agent.GetLocalCandidates() + + agent := g.getAgent() + // it is possible agent had just been closed + if agent == nil { + return nil, fmt.Errorf("%w: unable to get local candidates", errICEAgentNotExist) + } + + iceCandidates, err := agent.GetLocalCandidates() if err != nil { return nil, err } diff --git a/icegatherer_test.go b/icegatherer_test.go index 9e37a59da6c..cdd1a9c3e45 100644 --- a/icegatherer_test.go +++ b/icegatherer_test.go @@ -53,8 +53,8 @@ func TestNewICEGatherer_Success(t *testing.T) { t.Error(err) } - if len(params.UsernameFragment) == 0 || - len(params.Password) == 0 { + if params.UsernameFragment == "" || + params.Password == "" { t.Fatalf("Empty local username or password frag") } @@ -98,3 +98,58 @@ func TestICEGather_mDNSCandidateGathering(t *testing.T) { <-gotMulticastDNSCandidate.Done() assert.NoError(t, gatherer.Close()) } + +func TestICEGatherer_AlreadyClosed(t *testing.T) { + // Limit runtime in case of deadlocks + lim := test.TimeOut(time.Second * 20) + defer lim.Stop() + + report := test.CheckRoutines(t) + defer report() + + opts := ICEGatherOptions{ + ICEServers: []ICEServer{{URLs: []string{"stun:stun.l.google.com:19302"}}}, + } + + t.Run("Gather", func(t *testing.T) { + gatherer, err := NewAPI().NewICEGatherer(opts) + assert.NoError(t, err) + + err = gatherer.createAgent() + assert.NoError(t, err) + + err = gatherer.Close() + assert.NoError(t, err) + + err = gatherer.Gather() + assert.ErrorIs(t, err, errICEAgentNotExist) + }) + + t.Run("GetLocalParameters", func(t *testing.T) { + gatherer, err := NewAPI().NewICEGatherer(opts) + assert.NoError(t, err) + + err = gatherer.createAgent() + assert.NoError(t, err) + + err = gatherer.Close() + assert.NoError(t, err) + + _, err = gatherer.GetLocalParameters() + assert.ErrorIs(t, err, errICEAgentNotExist) + }) + + t.Run("GetLocalCandidates", func(t *testing.T) { + gatherer, err := NewAPI().NewICEGatherer(opts) + assert.NoError(t, err) + + err = gatherer.createAgent() + assert.NoError(t, err) + + err = gatherer.Close() + assert.NoError(t, err) + + _, err = gatherer.GetLocalCandidates() + assert.ErrorIs(t, err, errICEAgentNotExist) + }) +} diff --git a/icemux.go b/icemux.go index 5d8f49dd351..8291a6c8b98 100644 --- a/icemux.go +++ b/icemux.go @@ -18,8 +18,8 @@ func NewICETCPMux(logger logging.LeveledLogger, listener net.Listener, readBuffe } // NewICEUDPMux creates a new instance of ice.UDPMuxDefault. It allows many PeerConnections to be served -// by a single UDP Port. net.UDPConn satisfies ice.UDPMuxConn, can be passed in directly. -func NewICEUDPMux(logger logging.LeveledLogger, udpConn ice.UDPMuxConn) ice.UDPMux { +// by a single UDP Port. +func NewICEUDPMux(logger logging.LeveledLogger, udpConn net.PacketConn) ice.UDPMux { return ice.NewUDPMuxDefault(ice.UDPMuxParams{ UDPConn: udpConn, Logger: logger, diff --git a/peerconnection.go b/peerconnection.go index b5075d4bb4a..9447a65dc31 100644 --- a/peerconnection.go +++ b/peerconnection.go @@ -21,6 +21,7 @@ import ( "github.com/pion/logging" "github.com/pion/rtcp" "github.com/pion/sdp/v3" + "github.com/pion/srtp/v2" "github.com/pion/webrtc/v3/internal/util" "github.com/pion/webrtc/v3/pkg/rtcerr" ) @@ -659,7 +660,13 @@ func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription } } for _, t := range currentTransceivers { - if t.Mid() != "" { + if mid := t.Mid(); mid != "" { + numericMid, errMid := strconv.Atoi(mid) + if errMid == nil { + if numericMid > pc.greaterMid { + pc.greaterMid = numericMid + } + } continue } pc.greaterMid++ @@ -1601,61 +1608,71 @@ func (pc *PeerConnection) handleIncomingSSRC(rtpStream io.Reader, ssrc SSRC) err // undeclaredMediaProcessor handles RTP/RTCP packets that don't match any a:ssrc lines func (pc *PeerConnection) undeclaredMediaProcessor() { - go func() { - var simulcastRoutineCount uint64 - for { - srtpSession, err := pc.dtlsTransport.getSRTPSession() - if err != nil { - pc.log.Warnf("undeclaredMediaProcessor failed to open SrtpSession: %v", err) - return - } + go pc.undeclaredRTPMediaProcessor() + go pc.undeclaredRTCPMediaProcessor() +} - stream, ssrc, err := srtpSession.AcceptStream() - if err != nil { - pc.log.Warnf("Failed to accept RTP %v", err) - return - } +func (pc *PeerConnection) undeclaredRTPMediaProcessor() { + var simulcastRoutineCount uint64 + for { + srtpSession, err := pc.dtlsTransport.getSRTPSession() + if err != nil { + pc.log.Warnf("undeclaredMediaProcessor failed to open SrtpSession: %v", err) + return + } - if pc.isClosed.get() { - if err = stream.Close(); err != nil { - pc.log.Warnf("Failed to close RTP stream %v", err) - } - continue - } + stream, ssrc, err := srtpSession.AcceptStream() + if err != nil { + pc.log.Warnf("Failed to accept RTP %v", err) + return + } - if atomic.AddUint64(&simulcastRoutineCount, 1) >= simulcastMaxProbeRoutines { - atomic.AddUint64(&simulcastRoutineCount, ^uint64(0)) - pc.log.Warn(ErrSimulcastProbeOverflow.Error()) - continue + if pc.isClosed.get() { + if err = stream.Close(); err != nil { + pc.log.Warnf("Failed to close RTP stream %v", err) } + continue + } - go func(rtpStream io.Reader, ssrc SSRC) { - pc.dtlsTransport.storeSimulcastStream(stream) - - if err := pc.handleIncomingSSRC(rtpStream, ssrc); err != nil { - pc.log.Errorf(incomingUnhandledRTPSsrc, ssrc, err) - } - atomic.AddUint64(&simulcastRoutineCount, ^uint64(0)) - }(stream, SSRC(ssrc)) + if atomic.AddUint64(&simulcastRoutineCount, 1) >= simulcastMaxProbeRoutines { + atomic.AddUint64(&simulcastRoutineCount, ^uint64(0)) + pc.log.Warn(ErrSimulcastProbeOverflow.Error()) + pc.dtlsTransport.storeSimulcastStream(stream) + continue } - }() - go func() { - for { - srtcpSession, err := pc.dtlsTransport.getSRTCPSession() - if err != nil { - pc.log.Warnf("undeclaredMediaProcessor failed to open SrtcpSession: %v", err) - return + go func(rtpStream io.Reader, ssrc SSRC) { + if err := pc.handleIncomingSSRC(rtpStream, ssrc); err != nil { + pc.log.Errorf(incomingUnhandledRTPSsrc, ssrc, err) + pc.dtlsTransport.storeSimulcastStream(stream) } + atomic.AddUint64(&simulcastRoutineCount, ^uint64(0)) + }(stream, SSRC(ssrc)) + } +} - _, ssrc, err := srtcpSession.AcceptStream() - if err != nil { - pc.log.Warnf("Failed to accept RTCP %v", err) - return - } - pc.log.Warnf("Incoming unhandled RTCP ssrc(%d), OnTrack will not be fired", ssrc) +func (pc *PeerConnection) undeclaredRTCPMediaProcessor() { + var unhandledStreams []*srtp.ReadStreamSRTCP + defer func() { + for _, s := range unhandledStreams { + _ = s.Close() } }() + for { + srtcpSession, err := pc.dtlsTransport.getSRTCPSession() + if err != nil { + pc.log.Warnf("undeclaredMediaProcessor failed to open SrtcpSession: %v", err) + return + } + + stream, ssrc, err := srtcpSession.AcceptStream() + if err != nil { + pc.log.Warnf("Failed to accept RTCP %v", err) + return + } + pc.log.Warnf("Incoming unhandled RTCP ssrc(%d), OnTrack will not be fired", ssrc) + unhandledStreams = append(unhandledStreams, stream) + } } // RemoteDescription returns pendingRemoteDescription if it is not null and diff --git a/peerconnection_renegotiation_test.go b/peerconnection_renegotiation_test.go index ef7e0e3aa00..e5382ff0c94 100644 --- a/peerconnection_renegotiation_test.go +++ b/peerconnection_renegotiation_test.go @@ -1192,3 +1192,44 @@ func TestPeerConnection_Regegotiation_ReuseTransceiver(t *testing.T) { closePairNow(t, pcOffer, pcAnswer) } + +func TestPeerConnection_Renegotiation_MidConflict(t *testing.T) { + lim := test.TimeOut(time.Second * 30) + defer lim.Stop() + + report := test.CheckRoutines(t) + defer report() + + offerPC, err := NewPeerConnection(Configuration{}) + assert.NoError(t, err) + answerPC, err := NewPeerConnection(Configuration{}) + assert.NoError(t, err) + _, err = offerPC.CreateDataChannel("test", nil) + assert.NoError(t, err) + + _, err = offerPC.AddTransceiverFromKind(RTPCodecTypeVideo, RtpTransceiverInit{Direction: RTPTransceiverDirectionSendonly}) + assert.NoError(t, err) + _, err = offerPC.AddTransceiverFromKind(RTPCodecTypeAudio, RtpTransceiverInit{Direction: RTPTransceiverDirectionSendonly}) + assert.NoError(t, err) + + offer, err := offerPC.CreateOffer(nil) + assert.NoError(t, err) + assert.NoError(t, offerPC.SetLocalDescription(offer)) + assert.NoError(t, answerPC.SetRemoteDescription(offer), offer.SDP) + answer, err := answerPC.CreateAnswer(nil) + assert.NoError(t, err) + assert.NoError(t, answerPC.SetLocalDescription(answer)) + assert.NoError(t, offerPC.SetRemoteDescription(answer)) + assert.Equal(t, SignalingStateStable, offerPC.SignalingState()) + + tr, err := offerPC.AddTransceiverFromKind(RTPCodecTypeVideo, RtpTransceiverInit{Direction: RTPTransceiverDirectionSendonly}) + assert.NoError(t, err) + assert.NoError(t, tr.SetMid("3")) + _, err = offerPC.AddTransceiverFromKind(RTPCodecTypeVideo, RtpTransceiverInit{Direction: RTPTransceiverDirectionSendrecv}) + assert.NoError(t, err) + _, err = offerPC.CreateOffer(nil) + assert.NoError(t, err) + + assert.NoError(t, offerPC.Close()) + assert.NoError(t, answerPC.Close()) +} diff --git a/pkg/media/h264reader/h264reader.go b/pkg/media/h264reader/h264reader.go index 7520a9b8cf0..d5e68f962a3 100644 --- a/pkg/media/h264reader/h264reader.go +++ b/pkg/media/h264reader/h264reader.go @@ -145,9 +145,8 @@ func (reader *H264Reader) NextNAL() (*NAL, error) { if nal.UnitType == NalUnitTypeSEI { reader.nalBuffer = nil continue - } else { - break } + break } reader.nalBuffer = append(reader.nalBuffer, readByte) diff --git a/renovate.json b/renovate.json index f1614058a70..f1bb98c6ad0 100644 --- a/renovate.json +++ b/renovate.json @@ -1,27 +1,6 @@ { + "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:base", - ":disableDependencyDashboard" - ], - "postUpdateOptions": [ - "gomodTidy" - ], - "commitBody": "Generated by renovateBot", - "packageRules": [ - { - "matchUpdateTypes": ["minor", "patch", "pin", "digest"], - "automerge": true - }, - { - "packagePatterns": ["^golang.org/x/"], - "schedule": ["on the first day of the month"] - } - ], - "ignorePaths": [ - ".github/workflows/generate-authors.yml", - ".github/workflows/lint.yaml", - ".github/workflows/renovate-go-mod-fix.yaml", - ".github/workflows/test.yaml", - ".github/workflows/tidy-check.yaml" + "github>pion/renovate-config" ] } diff --git a/settingengine.go b/settingengine.go index 74a6cb2121d..0c1e0c3a6f6 100644 --- a/settingengine.go +++ b/settingengine.go @@ -37,16 +37,17 @@ type SettingEngine struct { ICERelayAcceptanceMinWait *time.Duration } candidates struct { - ICELite bool - ICENetworkTypes []NetworkType - InterfaceFilter func(string) bool - IPFilter func(net.IP) bool - NAT1To1IPs []string - NAT1To1IPCandidateType ICECandidateType - MulticastDNSMode ice.MulticastDNSMode - MulticastDNSHostName string - UsernameFragment string - Password string + ICELite bool + ICENetworkTypes []NetworkType + InterfaceFilter func(string) bool + IPFilter func(net.IP) bool + NAT1To1IPs []string + NAT1To1IPCandidateType ICECandidateType + MulticastDNSMode ice.MulticastDNSMode + MulticastDNSHostName string + UsernameFragment string + Password string + IncludeLoopbackCandidate bool } replayProtection struct { DTLS *uint @@ -98,8 +99,8 @@ func (e *SettingEngine) SetSRTPProtectionProfiles(profiles ...dtls.SRTPProtectio } // SetICETimeouts sets the behavior around ICE Timeouts -// * disconnectedTimeout is the duration without network activity before a Agent is considered disconnected. Default is 5 Seconds -// * failedTimeout is the duration without network activity before a Agent is considered failed after disconnected. Default is 25 Seconds +// * disconnectedTimeout is the duration without network activity before an Agent is considered disconnected. Default is 5 Seconds +// * failedTimeout is the duration without network activity before an Agent is considered failed after disconnected. Default is 25 Seconds // * keepAliveInterval is how often the ICE Agent sends extra traffic if there is no activity, if media is flowing no traffic will be sent. Default is 2 seconds func (e *SettingEngine) SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval time.Duration) { e.timeout.ICEDisconnectedTimeout = &disconnectedTimeout @@ -195,6 +196,12 @@ func (e *SettingEngine) SetNAT1To1IPs(ips []string, candidateType ICECandidateTy e.candidates.NAT1To1IPCandidateType = candidateType } +// SetIncludeLoopbackCandidate enable pion to gather loopback candidates, it is useful +// for some VM have public IP mapped to loopback interface +func (e *SettingEngine) SetIncludeLoopbackCandidate(include bool) { + e.candidates.IncludeLoopbackCandidate = include +} + // SetAnsweringDTLSRole sets the DTLS role that is selected when offering // The DTLS role controls if the WebRTC Client as a client or server. This // may be useful when interacting with non-compliant clients or debugging issues. diff --git a/track_local_static.go b/track_local_static.go index 51e963d0c6d..5ca61dc35ff 100644 --- a/track_local_static.go +++ b/track_local_static.go @@ -128,18 +128,27 @@ var rtpPacketPool = sync.Pool{ }, } +func resetPacketPoolAllocation(localPacket *rtp.Packet) { + *localPacket = rtp.Packet{} + rtpPacketPool.Put(localPacket) +} + +func getPacketAllocationFromPool() *rtp.Packet { + ipacket := rtpPacketPool.Get() + return ipacket.(*rtp.Packet) //nolint:forcetypeassert +} + // WriteRTP writes a RTP Packet to the TrackLocalStaticRTP // If one PeerConnection fails the packets will still be sent to // all PeerConnections. The error message will contain the ID of the failed // PeerConnections so you can remove them func (s *TrackLocalStaticRTP) WriteRTP(p *rtp.Packet) error { - ipacket := rtpPacketPool.Get() - packet := ipacket.(*rtp.Packet) //nolint:forcetypeassert - defer func() { - *packet = rtp.Packet{} - rtpPacketPool.Put(ipacket) - }() + packet := getPacketAllocationFromPool() + + defer resetPacketPoolAllocation(packet) + *packet = *p + return s.writeRTP(packet) } @@ -166,12 +175,9 @@ func (s *TrackLocalStaticRTP) writeRTP(p *rtp.Packet) error { // all PeerConnections. The error message will contain the ID of the failed // PeerConnections so you can remove them func (s *TrackLocalStaticRTP) Write(b []byte) (n int, err error) { - ipacket := rtpPacketPool.Get() - packet := ipacket.(*rtp.Packet) //nolint:forcetypeassert - defer func() { - *packet = rtp.Packet{} - rtpPacketPool.Put(ipacket) - }() + packet := getPacketAllocationFromPool() + + defer resetPacketPoolAllocation(packet) if err = packet.Unmarshal(b); err != nil { return 0, err