Last active
July 4, 2018 21:49
-
-
Save Sean-Der/ae0ddf7fff4196066f2026667a2e09d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/examples/gstreamer-send/gst/gst.go b/examples/gstreamer-send/gst/gst.go | |
| index 2887df2..20feaaf 100644 | |
| --- a/examples/gstreamer-send/gst/gst.go | |
| +++ b/examples/gstreamer-send/gst/gst.go | |
| @@ -39,7 +39,7 @@ func CreatePipeline(codec webrtc.TrackType, in chan<- webrtc.RTCSample) *Pipelin | |
| case webrtc.VP9: | |
| pipelineStr = "videotestsrc ! vp9enc ! " + pipelineStr | |
| case webrtc.H264: | |
| - pipelineStr = "videotestsrc ! x264enc speed-preset=veryfast key-int-max=60 ! video/x-h264,stream-format=byte-stream ! " + pipelineStr | |
| + pipelineStr = "videotestsrc ! x264enc speed-preset=veryfast key-int-max=2 aud=false ! video/x-h264,profile=baseline ! rtph264pay pt=100 ssrc=2147483647 config-interval=1 ! " + pipelineStr | |
| case webrtc.Opus: | |
| pipelineStr = "audiotestsrc ! opusenc ! " + pipelineStr | |
| default: | |
| diff --git a/examples/gstreamer-send/main.go b/examples/gstreamer-send/main.go | |
| index 4d057c3..53fedb4 100644 | |
| --- a/examples/gstreamer-send/main.go | |
| +++ b/examples/gstreamer-send/main.go | |
| @@ -30,12 +30,6 @@ func main() { | |
| // Create a new RTCPeerConnection | |
| peerConnection := &webrtc.RTCPeerConnection{} | |
| - // Create a audio track | |
| - opusIn, err := peerConnection.AddTrack(webrtc.Opus, 48000) | |
| - if err != nil { | |
| - panic(err) | |
| - } | |
| - | |
| // Create a video track | |
| vp8In, err := peerConnection.AddTrack(webrtc.H264, 90000) | |
| if err != nil { | |
| @@ -63,7 +57,6 @@ func main() { | |
| fmt.Println(base64.StdEncoding.EncodeToString([]byte(localDescriptionStr))) | |
| // Start pushing buffers on these tracks | |
| - gst.CreatePipeline(webrtc.Opus, opusIn).Start() | |
| gst.CreatePipeline(webrtc.H264, vp8In).Start() | |
| select {} | |
| } | |
| diff --git a/internal/sdp/util.go b/internal/sdp/util.go | |
| index 3d3508f..673a20d 100644 | |
| --- a/internal/sdp/util.go | |
| +++ b/internal/sdp/util.go | |
| @@ -65,6 +65,7 @@ func BaseSessionDescription(b *SessionBuilder) *SessionDescription { | |
| "rtpmap:96 VP8/90000", | |
| "rtpmap:98 VP9/90000", | |
| "rtpmap:100 H264/90000", | |
| + "a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", | |
| }, | |
| } | |
| diff --git a/rtcpeerconnection.go b/rtcpeerconnection.go | |
| index 74c6fd2..1e09be0 100644 | |
| --- a/rtcpeerconnection.go | |
| +++ b/rtcpeerconnection.go | |
| @@ -12,7 +12,6 @@ import ( | |
| "github.com/pions/webrtc/internal/util" | |
| "github.com/pions/webrtc/pkg/ice" | |
| "github.com/pions/webrtc/pkg/rtp" | |
| - "github.com/pions/webrtc/pkg/rtp/codecs" | |
| "github.com/pkg/errors" | |
| ) | |
| @@ -136,34 +135,18 @@ func (r *RTCPeerConnection) AddTrack(mediaType TrackType, clockRate uint32) (sam | |
| trackInput := make(chan RTCSample, 15) | |
| go func() { | |
| - ssrc := rand.Uint32() | |
| - sdpTrack := &sdp.SessionBuilderTrack{SSRC: ssrc} | |
| - var payloader rtp.Payloader | |
| - var payloadType uint8 | |
| - switch mediaType { | |
| - case Opus: | |
| - sdpTrack.IsAudio = true | |
| - payloader = &codecs.OpusPayloader{} | |
| - payloadType = 111 | |
| - | |
| - case VP8: | |
| - payloader = &codecs.VP8Payloader{} | |
| - payloadType = 96 | |
| - | |
| - case H264: | |
| - payloader = &codecs.H264Payloader{} | |
| - payloadType = 100 | |
| - } | |
| - | |
| + sdpTrack := &sdp.SessionBuilderTrack{SSRC: 2147483647} | |
| r.localTracks = append(r.localTracks, sdpTrack) | |
| - packetizer := rtp.NewPacketizer(1500, payloadType, ssrc, payloader, rtp.NewRandomSequencer(), clockRate) | |
| for { | |
| + var packet rtp.Packet | |
| + | |
| in := <-trackInput | |
| - packets := packetizer.Packetize(in.Data, in.Samples) | |
| - for _, p := range packets { | |
| - for _, port := range r.ports { | |
| - port.Send(p) | |
| - } | |
| + err := packet.Unmarshal(in.Data) | |
| + if err != nil { | |
| + panic(err) | |
| + } | |
| + for _, port := range r.ports { | |
| + port.Send(&packet) | |
| } | |
| } | |
| }() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment