Created
January 29, 2021 17:56
-
-
Save Sean-Der/2e33a0940cc6cfbb45805209931e7eee 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/rtp-to-webrtc/main.go b/examples/rtp-to-webrtc/main.go | |
| index 71c3be4..e94636a 100644 | |
| --- a/examples/rtp-to-webrtc/main.go | |
| +++ b/examples/rtp-to-webrtc/main.go | |
| @@ -7,10 +7,8 @@ import ( | |
| "net" | |
| "github.com/pion/rtp" | |
| - "github.com/pion/rtp/codecs" | |
| "github.com/pion/webrtc/v3" | |
| "github.com/pion/webrtc/v3/examples/internal/signal" | |
| - "github.com/pion/webrtc/v3/pkg/media/samplebuilder" | |
| ) | |
| func main() { | |
| @@ -37,7 +35,7 @@ func main() { | |
| }() | |
| // Create a video track | |
| - videoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "video/vp8"}, "video", "pion") | |
| + videoTrack, err := webrtc.NewTrackLocalStaticRTP(webrtc.RTPCodecCapability{MimeType: "video/h264"}, "video", "pion") | |
| if err != nil { | |
| panic(err) | |
| } | |
| @@ -95,8 +93,6 @@ func main() { | |
| // Output the answer in base64 so we can paste it in browser | |
| fmt.Println(signal.Encode(*peerConnection.LocalDescription())) | |
| - videoBuilder := samplebuilder.New(10, &codecs.VP8Packet{}, 90000) | |
| - | |
| // Read RTP packets forever and send them to the WebRTC Client | |
| for { | |
| inboundRTPPacket := make([]byte, 1500) // UDP MTU | |
| @@ -111,16 +107,8 @@ func main() { | |
| panic(err) | |
| } | |
| - videoBuilder.Push(packet) | |
| - for { | |
| - sample := videoBuilder.Pop() | |
| - if sample == nil { | |
| - break | |
| - } | |
| - | |
| - if writeErr := videoTrack.WriteSample(*sample); writeErr != nil { | |
| - panic(writeErr) | |
| - } | |
| + if writeErr := videoTrack.WriteRTP(packet); writeErr != nil { | |
| + panic(writeErr) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment