Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
merge pionv3.0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cnderrauber committed Mar 25, 2021
2 parents 9cd4caf + dab8a4a commit 0170f57
Show file tree
Hide file tree
Showing 19 changed files with 515 additions and 130 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.14", "1.15"]
go: ["1.15", "1.16"]
fail-fast: false
name: Go ${{ matrix.go }}
steps:
Expand All @@ -34,7 +34,8 @@ jobs:

- name: Setup go-acc
run: |
go get -u github.com/ory/go-acc
go get github.com/ory/go-acc
git checkout go.mod go.sum
- name: Run test
run: |
Expand All @@ -53,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.14", "1.15"]
go: ["1.15", "1.16"]
fail-fast: false
name: Go i386 ${{ matrix.go }}
steps:
Expand Down Expand Up @@ -109,7 +110,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.15
GO_VERSION: 1.16

- name: Set Go Root
run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV
Expand Down
12 changes: 10 additions & 2 deletions examples/broadcast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ Run `broadcast` OR run `main.go` in `github.com/pion/webrtc/examples/broadcast`
### Start a publisher

* Click `Publish a Broadcast`
* `curl localhost:8080/sdp -d "YOUR SDP"`. The `broadcast` application will respond with an offer, paste this into the second input field. Then press `Start Session`
* Copy the string in the first input labelled `Browser base64 Session Description`
* Run `curl localhost:8080/sdp -d "$BROWSER_OFFER"`. `$BROWSER_OFFER` is the value you copied in the last step.
* The `broadcast` terminal application will respond with an answer, paste this into the second input field in your browser.
* Press `Start Session`
* The connection state will be printed in the terminal and under `logs` in the browser.

### Join the broadcast
* Click `Join a Broadcast`
* `curl localhost:8080/sdp -d "YOUR SDP"`. The `broadcast` application will respond with an offer, paste this into the second input field. Then press `Start Session`
* Copy the string in the first input labelled `Browser base64 Session Description`
* Run `curl localhost:8080/sdp -d "$BROWSER_OFFER"`. `$BROWSER_OFFER` is the value you copied in the last step.
* The `broadcast` terminal application will respond with an answer, paste this into the second input field in your browser.
* Press `Start Session`
* The connection state will be printed in the terminal and under `logs` in the browser.

You can change the listening port using `-port 8011`

Expand Down
4 changes: 2 additions & 2 deletions examples/rtp-to-webrtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480,format=I420 ! vp8

#### ffmpeg
```
ffmpeg -re -f lavfi -i testsrc=size=640x480:rate=30 -vcodec libvpx -cpu-used 5 -deadline 1 -g 10 -error-resilient 1 -auto-alt-ref 1 -f rtp rtp://127.0.0.1:5004
ffmpeg -re -f lavfi -i testsrc=size=640x480:rate=30 -vcodec libvpx -cpu-used 5 -deadline 1 -g 10 -error-resilient 1 -auto-alt-ref 1 -f rtp rtp://127.0.0.1:5004?pkt_size=1200
```

If you wish to send audio replace both occurrences of `vp8` in `main.go` then run

```
ffmpeg -f lavfi -i "sine=frequency=1000" -c:a libopus -b:a 48000 -sample_fmt s16p -ssrc 1 -payload_type 111 -f rtp -max_delay 0 -application lowdelay rtp:/127.0.0.1:5004
ffmpeg -f lavfi -i "sine=frequency=1000" -c:a libopus -b:a 48000 -sample_fmt s16p -ssrc 1 -payload_type 111 -f rtp -max_delay 0 -application lowdelay rtp:/127.0.0.1:5004?pkt_size=1200
```

### Input rtp-to-webrtc's SessionDescription into your browser
Expand Down
37 changes: 37 additions & 0 deletions fmtp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package webrtc

import (
"strings"
)

type fmtp map[string]string

// parseFmtp parses fmtp string.
func parseFmtp(line string) fmtp {
f := fmtp{}
for _, p := range strings.Split(line, ";") {
pp := strings.SplitN(strings.TrimSpace(p), "=", 2)
key := strings.ToLower(pp[0])
var value string
if len(pp) > 1 {
value = pp[1]
}
f[key] = value
}
return f
}

// fmtpConsist checks that two FTMP parameters are not inconsistent.
func fmtpConsist(a, b fmtp) bool {
for k, v := range a {
if vb, ok := b[k]; ok && !strings.EqualFold(vb, v) {
return false
}
}
for k, v := range b {
if va, ok := a[k]; ok && !strings.EqualFold(va, v) {
return false
}
}
return true
}
107 changes: 107 additions & 0 deletions fmtp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package webrtc

import (
"reflect"
"testing"
)

func TestParseFmtp(t *testing.T) {
testCases := map[string]struct {
input string
expected fmtp
}{
"OneParam": {
input: "key-name=value",
expected: fmtp{
"key-name": "value",
},
},
"OneParamWithWhiteSpeces": {
input: "\tkey-name=value ",
expected: fmtp{
"key-name": "value",
},
},
"TwoParams": {
input: "key-name=value;key2=value2",
expected: fmtp{
"key-name": "value",
"key2": "value2",
},
},
"TwoParamsWithWhiteSpeces": {
input: "key-name=value; \n\tkey2=value2 ",
expected: fmtp{
"key-name": "value",
"key2": "value2",
},
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
f := parseFmtp(testCase.input)
if !reflect.DeepEqual(testCase.expected, f) {
t.Errorf("Expected Fmtp params: %v, got: %v", testCase.expected, f)
}
})
}
}

func TestFmtpConsist(t *testing.T) {
consistString := map[bool]string{true: "consist", false: "inconsist"}

testCases := map[string]struct {
a, b string
consist bool
}{
"Equal": {
a: "key1=value1;key2=value2;key3=value3",
b: "key1=value1;key2=value2;key3=value3",
consist: true,
},
"EqualWithWhitespaceVariants": {
a: "key1=value1;key2=value2;key3=value3",
b: " key1=value1; \nkey2=value2;\t\nkey3=value3",
consist: true,
},
"EqualWithCase": {
a: "key1=value1;key2=value2;key3=value3",
b: "key1=value1;key2=Value2;Key3=value3",
consist: true,
},
"OneHasExtraParam": {
a: "key1=value1;key2=value2;key3=value3",
b: "key1=value1;key2=value2;key3=value3;key4=value4",
consist: true,
},
"Inconsistent": {
a: "key1=value1;key2=value2;key3=value3",
b: "key1=value1;key2=different_value;key3=value3",
consist: false,
},
"Inconsistent_OneHasExtraParam": {
a: "key1=value1;key2=value2;key3=value3;key4=value4",
b: "key1=value1;key2=different_value;key3=value3",
consist: false,
},
}
for name, testCase := range testCases {
testCase := testCase
check := func(t *testing.T, a, b string) {
c := fmtpConsist(parseFmtp(a), parseFmtp(b))
if c != testCase.consist {
t.Errorf(
"'%s' and '%s' are expected to be %s, but treated as %s",
a, b, consistString[testCase.consist], consistString[c],
)
}
}
t.Run(name, func(t *testing.T) {
check(t, testCase.a, testCase.b)
})
t.Run(name+"_Reversed", func(t *testing.T) {
check(t, testCase.b, testCase.a)
})
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/pion/datachannel v1.4.21
github.com/pion/dtls/v2 v2.0.8
github.com/pion/ice/v2 v2.0.16
github.com/pion/interceptor v0.0.11
github.com/pion/interceptor v0.0.12
github.com/pion/logging v0.2.2
github.com/pion/randutil v0.1.0
github.com/pion/rtcp v1.2.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/pion/dtls/v2 v2.0.8 h1:reGe8rNIMfO/UAeFLqO61tl64t154Qfkr4U3Gzu1tsg=
github.com/pion/dtls/v2 v2.0.8/go.mod h1:QuDII+8FVvk9Dp5t5vYIMTo7hh7uBkra+8QIm7QGm10=
github.com/pion/ice/v2 v2.0.16 h1:K6bzD8ef9vMKbGMTHaUweHXEyuNGnvr2zdqKoLKZPn0=
github.com/pion/ice/v2 v2.0.16/go.mod h1:SJNJzC27gDZoOW0UoxIoC8Hf2PDxG28hQyNdSexDu38=
github.com/pion/interceptor v0.0.11 h1:YIEMghiTZYb88q6awk3N/8WUU5P+aVyKMuU3YZfTSmI=
github.com/pion/interceptor v0.0.11/go.mod h1:qzeuWuD/ZXvPqOnxNcnhWfkCZ2e1kwwslicyyPnhoK4=
github.com/pion/interceptor v0.0.12 h1:eC1iVneBIAQJEfaNAfDqAncJWhMDAnaXPRCJsltdokE=
github.com/pion/interceptor v0.0.12/go.mod h1:qzeuWuD/ZXvPqOnxNcnhWfkCZ2e1kwwslicyyPnhoK4=
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/mdns v0.0.5 h1:Q2oj/JB3NqfzY9xGZ1fPzZzK7sDSD8rZPOvcIQ10BCw=
Expand Down
Loading

0 comments on commit 0170f57

Please sign in to comment.