Skip to content

Commit 9cf19de

Browse files
committed
Extract from Pion WebRTC
New repo that contains applications that use 3rd party libraries
1 parent cdb236c commit 9cf19de

26 files changed

+185
-243
lines changed

.github/assert-contributors.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Unshallow the repo, this check doesn't work with this enabled
5+
# https://github.com/travis-ci/travis-ci/issues/3412
6+
if [ -f $(git rev-parse --git-dir)/shallow ]; then
7+
git fetch --unshallow || true
8+
fi
9+
10+
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
11+
12+
EXCLUDED_CONTIBUTORS=('John R. Bradley')
13+
MISSING_CONTIBUTORS=()
14+
15+
shouldBeIncluded () {
16+
for i in "${EXCLUDED_CONTIBUTORS[@]}"
17+
do
18+
if [ "$i" == "$1" ] ; then
19+
return 1
20+
fi
21+
done
22+
return 0
23+
}
24+
25+
26+
IFS=$'\n' #Only split on newline
27+
for contributor in $(git log --format='%aN' | sort -u)
28+
do
29+
if shouldBeIncluded $contributor; then
30+
if ! grep -q "$contributor" "$SCRIPT_PATH/../README.md"; then
31+
MISSING_CONTIBUTORS+=("$contributor")
32+
fi
33+
fi
34+
done
35+
unset IFS
36+
37+
if [ ${#MISSING_CONTIBUTORS[@]} -ne 0 ]; then
38+
echo "Please add the following contributors to the README"
39+
for i in "${MISSING_CONTIBUTORS[@]}"
40+
do
41+
echo "$i"
42+
done
43+
exit 1
44+
fi

.github/lint-commit-message.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
display_commit_message_error() {
5+
cat << EndOfMessage
6+
$1
7+
8+
-------------------------------------------------
9+
The preceding commit message is invalid
10+
it failed '$2' of the following checks
11+
12+
* Separate subject from body with a blank line
13+
* Limit the subject line to 50 characters
14+
* Capitalize the subject line
15+
* Do not end the subject line with a period
16+
* Wrap the body at 72 characters
17+
EndOfMessage
18+
19+
exit 1
20+
}
21+
22+
lint_commit_message() {
23+
if [[ "$(echo "$1" | awk 'NR == 2 {print $1;}' | wc -c)" -ne 1 ]]; then
24+
display_commit_message_error "$1" 'Separate subject from body with a blank line'
25+
fi
26+
27+
if [[ "$(echo "$1" | head -n1 | wc -m)" -gt 50 ]]; then
28+
display_commit_message_error "$1" 'Limit the subject line to 50 characters'
29+
fi
30+
31+
if [[ ! $1 =~ ^[A-Z] ]]; then
32+
display_commit_message_error "$1" 'Capitalize the subject line'
33+
fi
34+
35+
if [[ "$(echo "$1" | awk 'NR == 1 {print substr($0,length($0),1)}')" == "." ]]; then
36+
display_commit_message_error "$1" 'Do not end the subject line with a period'
37+
fi
38+
39+
if [[ "$(echo "$1" | awk '{print length}' | sort -nr | head -1)" -gt 72 ]]; then
40+
display_commit_message_error "$1" 'Wrap the body at 72 characters'
41+
fi
42+
}
43+
44+
if [ "$#" -eq 1 ]; then
45+
if [ ! -f "$1" ]; then
46+
echo "$0 was passed one argument, but was not a valid file"
47+
exit 1
48+
fi
49+
lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")"
50+
else
51+
# TRAVIS_COMMIT_RANGE is empty for initial branch commit
52+
if [[ "${TRAVIS_COMMIT_RANGE}" != *"..."* ]]; then
53+
parent=$(git log -n 1 --format="%P" ${TRAVIS_COMMIT_RANGE})
54+
TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE}...$parent"
55+
fi
56+
57+
for commit in $(git rev-list ${TRAVIS_COMMIT_RANGE}); do
58+
lint_commit_message "$(git log --format="%B" -n 1 $commit)"
59+
done
60+
fi

.github/lint-filename.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
GO_REGEX="^[a-zA-Z_]+\.go$"
6+
7+
find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do
8+
filename=$(basename -- "$fullpath")
9+
10+
if ! [[ $filename =~ $GO_REGEX ]]; then
11+
echo "$filename is not a valid filename for Go code, only alpha and underscores are supported"
12+
exit 1
13+
fi
14+
done

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sfu-ws/cert.pem
2+
sfu-ws/key.pem

.golangci.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
linters-settings:
2+
govet:
3+
check-shadowing: true
4+
misspell:
5+
locale: US
6+
7+
linters:
8+
enable-all: true
9+
disable:
10+
- lll
11+
- gochecknoinits
12+
- gochecknoglobals
13+
14+
issues:
15+
exclude-use-default: false

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
env:
2+
- GO111MODULE=on
3+
4+
before_script:
5+
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0
6+
7+
script:
8+
- golangci-lint run
9+
- bash .github/assert-contributors.sh
10+
- bash .github/lint-commit-message.sh
11+
- bash .github/lint-filename.sh

README.md

+14-28
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,38 @@
11
<h1 align="center">
2-
Examples
2+
Examples WebRTC Applications
33
</h1>
44

5-
We've build an extensive collection of examples covering common use-cases. You can modify and extend these examples to quickly get started.
5+
The following are a collection of example applications built by Pion users. These applications show real world usage of Pion,
6+
and should serve as a good starting point for your next project. For more minimal examples check out [examples](https://github.com/pion/webrtc/tree/master/examples) in the Pion WebRTC repository
67

7-
### Overview
8-
#### Media API
8+
If you have a request please make an issue, we also love contributions more examples are always welcome.
9+
10+
Have any questions? Join [the Slack channel](https://pion.ly/slack) to follow development and speak with the maintainers.
11+
12+
## Examples
913
* [Gstreamer Receive](gstreamer-receive): The gstreamer-receive example shows how to receive media from the browser and play it live. This example uses GStreamer for rendering.
1014
* [Gstreamer Send](gstreamer-send): Example gstreamer-send shows how to send video to your browser. This example uses GStreamer to process the video.
1115
* [Gstreamer Send Offer](gstreamer-send-offer): Example gstreamer-send-offer is a variant of gstreamer-send that initiates the WebRTC connection by sending an offer.
12-
* [Save to Disk](save-to-disk): The save-to-disk example shows how to record your webcam and save the footage to disk on the server side.
1316
* [Janus Gateway](janus-gateway): Example janus-gateway is a collection of examples showing how to use Pion WebRTC with [janus-gateway](https://github.com/meetecho/janus-gateway).
14-
* [SFU Minimal](sfu-minimal): The SFU example demonstrates how to broadcast a video to multiple peers. A broadcaster uploads the video once and the server forwards it to all other peers.
1517
* [SFU Websocket](sfu-ws): The SFU example demonstrates how to broadcast a video to multiple peers. A broadcaster uploads the video once and the server forwards it to all other peers.
1618

17-
#### Data Channel API
18-
* [Data Channels](data-channels): The data-channels example shows how you can send/recv DataChannel messages from a web browser.
19-
* [Data Channels Create](data-channels-create): Example data-channels-create shows how you can send/recv DataChannel messages from a web browser. The difference with the data-channels example is that the data channel is initialized from the server side in this example.
20-
* [Data Channels Close](data-channels-close): Example data-channels-close is a variant of data-channels that allow playing with the life cycle of data channels.
21-
* [Data Channels Detach](data-channels-detach): The data-channels-detach example shows how you can send/recv DataChannel messages using the underlying DataChannel implementation directly. This provides a more idiomatic way of interacting with Data Channels.
22-
* [Data Channels Detach Create](data-channels-detach-create): Example data-channels-detach-create shows how you can send/recv DataChannel messages using the underlying DataChannel implementation directly. This provides a more idiomatic way of interacting with Data Channels. The difference with the data-channels-detach example is that the data channel is initialized in this example.
23-
* [Pion to Pion](pion-to-pion): Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page.
24-
* [ORTC](ortc): Example ortc shows how you an use the ORTC API for DataChannel communication.
25-
* [ORTC QUIC](ortc-quic): Example ortc-quic shows how you an use the ORTC API for QUIC DataChannel communication.
26-
* [Pion to Pion](pion-to-pion): Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page.
27-
2819

2920
### Usage
3021
We've made it easy to run the browser based examples on your local machine.
3122

3223
1. Build and run the example server:
3324
``` sh
34-
go get github.com/pion/webrtc
35-
cd $GOPATH/src/github.com/pion/webrtc/examples
25+
go get github.com/webrtc-example-applications
26+
cd $GOPATH/src/github.com/webrtc-example-applications
3627
go run examples.go
3728
```
3829

3930
2. Browse to [localhost](http://localhost) to browse through the examples.
4031

4132
Note that you can change the port of the server using the ``--address`` flag.
4233

43-
### WebAssembly
44-
Some of our examples have support for WebAssembly. The same examples server documented above can be used to run the WebAssembly examples. However, you have to compile them first. This is done as follows:
34+
### Contributing
35+
Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible:
4536

46-
1. If the example supports WebAssembly it will contain a `main.go` file under the `jsfiddle` folder.
47-
2. Build this `main.go` file as follows:
48-
```
49-
GOOS=js GOARCH=wasm go build -o demo.wasm
50-
```
51-
3. Start the example server. Refer to the [usage](#usage) section for how you can build the example server.
52-
4. Browse to [localhost](http://localhost). The page should now give you the option to run the example using the WebAssembly binary.
37+
### License
38+
MIT License - see [LICENSE](LICENSE) for full text

example.html

-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
<link rel="stylesheet" type="text/css" href="demo.css">
1414
{{ if .JS }}
1515
<script src="demo.js"></script>
16-
{{ else }}
17-
<script src="/wasm_exec.js"></script>
18-
<script>
19-
const go = new Go();
20-
WebAssembly.instantiateStreaming(fetch("demo.wasm"), go.importObject).then((result) => {
21-
go.run(result.instance);
22-
});
23-
</script>
2416
{{ end }}
2517
</head>
2618
<body>

examples.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type Example struct {
2222
Description string `json:"description"`
2323
Type string `json:"type"`
2424
IsJS bool
25-
IsWASM bool
2625
}
2726

2827
func main() {
@@ -50,15 +49,10 @@ func serve(addr string) error {
5049
// DIY 'mux' to avoid additional dependencies
5150
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
5251
url := r.URL.Path
53-
if url == "/wasm_exec.js" {
54-
http.FileServer(http.Dir("./vendor-wasm/golang.org/misc/wasm/")).ServeHTTP(w, r)
55-
return
56-
}
57-
5852
// Split up the URL. Expected parts:
5953
// 1: Base url
6054
// 2: "example"
61-
// 3: Example type: js or wasm
55+
// 3: Example type: js
6256
// 4: Example folder, e.g.: data-channels
6357
// 5: Static file as part of the example
6458
parts := strings.Split(url, "/")
@@ -134,10 +128,6 @@ func getExamples() (*Examples, error) {
134128
if _, err := os.Stat(js); !os.IsNotExist(err) {
135129
example.IsJS = true
136130
}
137-
wasm := filepath.Join(fiddle, "demo.wasm")
138-
if _, err := os.Stat(wasm); !os.IsNotExist(err) {
139-
example.IsWASM = true
140-
}
141131
}
142132

143133
return &examples, nil

gstreamer-receive/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This example requires you have GStreamer installed, these are the supported plat
1010
`pacman -S mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-libav mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-plugins-ugly`
1111
### Download gstreamer-receive
1212
```
13-
go get github.com/pion/webrtc/examples/gstreamer-receive
13+
go get github.com/pion/webrtc-example-applications/gstreamer-receive
1414
```
1515

1616
### Open gstreamer-receive example page

gstreamer-receive/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/pion/rtcp"
99
"github.com/pion/webrtc"
1010

11-
gst "github.com/pion/webrtc/examples/internal/gstreamer-sink"
12-
"github.com/pion/webrtc/examples/internal/signal"
11+
gst "github.com/pion/example-webrtc-applications/internal/gstreamer-sink"
12+
"github.com/pion/example-webrtc-applications/internal/signal"
1313
)
1414

1515
// gstreamerReceiveMain is launched in a goroutine because the main thread is needed

gstreamer-send-offer/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/pion/webrtc"
99

10-
gst "github.com/pion/webrtc/examples/internal/gstreamer-src"
11-
"github.com/pion/webrtc/examples/internal/signal"
10+
gst "github.com/pion/example-webrtc-applications/internal/gstreamer-src"
11+
"github.com/pion/example-webrtc-applications/internal/signal"
1212
)
1313

1414
func main() {

gstreamer-send/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This example requires you have GStreamer installed, these are the supported plat
1010
`pacman -S mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-libav mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-plugins-ugly`
1111
### Download gstreamer-send
1212
```
13-
go get github.com/pion/webrtc/examples/gstreamer-send
13+
go get github.com/pion/webrtc-example-applications/gstreamer-send
1414
```
1515

1616
### Open gstreamer-send example page

gstreamer-send/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/pion/webrtc"
99

10-
gst "github.com/pion/webrtc/examples/internal/gstreamer-src"
11-
"github.com/pion/webrtc/examples/internal/signal"
10+
gst "github.com/pion/example-webrtc-applications/internal/gstreamer-src"
11+
"github.com/pion/example-webrtc-applications/internal/signal"
1212
)
1313

1414
func main() {

index.html

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ <h3>{{ .Title }}</h3>
5555
<div class="content">
5656
<p>{{ .Description }}</p>
5757
{{ if .IsJS}}<p><a href="/example/js/{{ .Link }}/">Run JavaScript</a></p>{{ end }}
58-
{{ if .IsWASM}}<p><a href="/example/wasm/{{ .Link }}/">Run WASM</a></p>{{ end }}
5958
</div>
6059
</div>
6160
{{else}}

janus-gateway/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This example demonstrates how to download a video from a Janus streaming room. B
99
You should confirm that you can successfully watch `Opus/VP8 live stream coming from gstreamer (live)` in the stream demo web UI
1010

1111
### Running
12-
run `main.go` in `github.com/pion/webrtc/examples/janus-gateway/streaming`
12+
run `main.go` in `github.com/pion/webrtc-example-applications/janus-gateway/streaming`
1313

1414
If this worked you will see the following.
1515
```
@@ -24,7 +24,7 @@ You will see output.ivf in the current folder.
2424
This example demonstrates how to stream to a Janus video-room using pion-WebRTC
2525

2626
### Running
27-
run `main.go` in `github.com/pion/webrtc/examples/janus-gateway/video-room`
27+
run `main.go` in `github.com/pion/webrtc-example-applications/janus-gateway/video-room`
2828

2929
OSX
3030
```sh

janus-gateway/streaming/go.mod

-9
This file was deleted.

janus-gateway/streaming/go.sum

-20
This file was deleted.

janus-gateway/video-room/go.mod

-9
This file was deleted.

0 commit comments

Comments
 (0)