Skip to content

Commit ce9d1f5

Browse files
ssabooniSean-Der
authored andcommitted
Update gstreamer-receive to be PayloadType aware
PayloadType was hardcoded before so if remote peer used a different PayloadType media woludn't play.
1 parent a35253a commit ce9d1f5

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@v2
4040

41+
- name: Update packages
42+
run: sudo apt-get update
43+
4144
- name: Install GStreamer
4245
run: sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
4346

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
7474
* [Jin Gong](https://github.com/cgojin)
7575
* [harkirat singh](https://github.com/hkirat)
7676
* [oasangqi](https://github.com/oasangqi)
77+
* [Shahin Sabooni](https://github.com/longlonghands)
7778

7879
### License
7980
MIT License - see [LICENSE](LICENSE) for full text

gstreamer-receive/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func gstreamerReceiveMain() {
4949

5050
codecName := strings.Split(track.Codec().RTPCodecCapability.MimeType, "/")[1]
5151
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), codecName)
52-
pipeline := gst.CreatePipeline(strings.ToLower(codecName))
52+
pipeline := gst.CreatePipeline(track.PayloadType(), strings.ToLower(codecName))
5353
pipeline.Start()
5454
buf := make([]byte, 1400)
5555
for {

internal/gstreamer-sink/gst.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ package gst
99
*/
1010
import "C"
1111
import (
12+
"fmt"
1213
"strings"
1314
"unsafe"
15+
16+
"github.com/pion/webrtc/v3"
1417
)
1518

1619
// StartMainLoop starts GLib's main loop
@@ -27,13 +30,13 @@ type Pipeline struct {
2730
}
2831

2932
// CreatePipeline creates a GStreamer Pipeline
30-
func CreatePipeline(codecName string) *Pipeline {
33+
func CreatePipeline(payloadType webrtc.PayloadType, codecName string) *Pipeline {
3134
pipelineStr := "appsrc format=time is-live=true do-timestamp=true name=src ! application/x-rtp"
3235
switch strings.ToLower(codecName) {
3336
case "vp8":
34-
pipelineStr += ", encoding-name=VP8-DRAFT-IETF-01 ! rtpvp8depay ! decodebin ! autovideosink"
37+
pipelineStr += fmt.Sprintf(", payload=%d, encoding-name=VP8-DRAFT-IETF-01 ! rtpvp8depay ! decodebin ! autovideosink", payloadType)
3538
case "opus":
36-
pipelineStr += ", payload=96, encoding-name=OPUS ! rtpopusdepay ! decodebin ! autoaudiosink"
39+
pipelineStr += fmt.Sprintf(", payload=%d, encoding-name=OPUS ! rtpopusdepay ! decodebin ! autoaudiosink", payloadType)
3740
case "vp9":
3841
pipelineStr += " ! rtpvp9depay ! decodebin ! autovideosink"
3942
case "h264":

0 commit comments

Comments
 (0)