mirror of
https://github.com/pion/webrtc.git
synced 2025-10-22 06:39:29 +08:00
New Track API
The Pion WebRTC API has been dramatically redesigned. The design docs are located here [0] You can also read the release notes [1] on how to migrate your application. [0] https://github.com/pion/webrtc-v3-design [1] https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0
This commit is contained in:
@@ -66,9 +66,8 @@ func createPeerConnection(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Add a single video track
|
||||
func addVideo(w http.ResponseWriter, r *http.Request) {
|
||||
videoTrack, err := peerConnection.NewTrack(
|
||||
webrtc.DefaultPayloadTypeVP8,
|
||||
randutil.NewMathRandomGenerator().Uint32(),
|
||||
videoTrack, err := webrtc.NewTrackLocalStaticSample(
|
||||
webrtc.RTPCodecCapability{MimeType: "video/vp8"},
|
||||
fmt.Sprintf("video-%d", randutil.NewMathRandomGenerator().Uint32()),
|
||||
fmt.Sprintf("video-%d", randutil.NewMathRandomGenerator().Uint32()),
|
||||
)
|
||||
@@ -121,7 +120,7 @@ func main() {
|
||||
|
||||
// Read a video file from disk and write it to a webrtc.Track
|
||||
// When the video has been completely read this exits without error
|
||||
func writeVideoToTrack(t *webrtc.Track) {
|
||||
func writeVideoToTrack(t *webrtc.TrackLocalStaticSample) {
|
||||
// Open a IVF file and start reading using our IVFReader
|
||||
file, err := os.Open("output.ivf")
|
||||
if err != nil {
|
||||
@@ -144,7 +143,7 @@ func writeVideoToTrack(t *webrtc.Track) {
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
if err = t.WriteSample(media.Sample{Data: frame, Samples: 90000}); err != nil {
|
||||
if err = t.WriteSample(media.Sample{Data: frame, Duration: time.Second}); err != nil {
|
||||
fmt.Printf("Finish writing video track: %s ", err)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user