Browse Source

更新engine变化

v4
langhuihui 4 years ago
parent
commit
238e00fb1d
  1. 4
      go.mod
  2. 6
      go.sum
  3. 14
      main.go

4
go.mod

@ -3,9 +3,9 @@ module github.com/Monibuca/plugin-webrtc/v3
go 1.13
require (
github.com/Monibuca/engine/v3 v3.0.0-alpha4
github.com/Monibuca/engine/v3 v3.0.0-alpha5
github.com/Monibuca/utils/v3 v3.0.0-alpha4
github.com/pion/rtcp v1.2.6
github.com/pion/rtp v1.6.2
github.com/pion/webrtc/v3 v3.0.8
github.com/pion/webrtc/v3 v3.0.10
)

6
go.sum

@ -2,6 +2,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Monibuca/engine/v3 v3.0.0-alpha4 h1:kAStDd1p9tlSQeNyAAmb7vrPL2UCz7LFTzw5LdbGxBI=
github.com/Monibuca/engine/v3 v3.0.0-alpha4/go.mod h1:V0/kfen6K5O/RLXHPsZj4DF/LboDZ0OqfeCfn35bWMo=
github.com/Monibuca/engine/v3 v3.0.0-alpha5 h1:sXLg39SBkeiVkGcbcinXuRrYyClJvMVirxA5axiUD7s=
github.com/Monibuca/engine/v3 v3.0.0-alpha5/go.mod h1:V0/kfen6K5O/RLXHPsZj4DF/LboDZ0OqfeCfn35bWMo=
github.com/Monibuca/utils/v3 v3.0.0-alpha4 h1:pecYA89kWmtGOeY6R99d4T1epPJ1wc+jFrrJY13VD04=
github.com/Monibuca/utils/v3 v3.0.0-alpha4/go.mod h1:3xYmhQbgAZBHLyIMteUCd1va+1z/xnd72B585mCaT3c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -59,6 +61,8 @@ github.com/pion/dtls/v2 v2.0.4 h1:WuUcqi6oYMu/noNTz92QrF1DaFj4eXbhQ6dzaaAwOiI=
github.com/pion/dtls/v2 v2.0.4/go.mod h1:qAkFscX0ZHoI1E07RfYPoRw3manThveu+mlTDdOxoGI=
github.com/pion/dtls/v2 v2.0.5 h1:jgQJRK2IJ9eWQAcUEZN4M0tnCi5X/cERnxH9J8qOjR0=
github.com/pion/dtls/v2 v2.0.5/go.mod h1:QuDII+8FVvk9Dp5t5vYIMTo7hh7uBkra+8QIm7QGm10=
github.com/pion/dtls/v2 v2.0.6 h1:v0Cg/3o+PqRrSsbHoM2CQgUKvnwo8XgOVrr3XKP1/ek=
github.com/pion/dtls/v2 v2.0.6/go.mod h1:QuDII+8FVvk9Dp5t5vYIMTo7hh7uBkra+8QIm7QGm10=
github.com/pion/ice/v2 v2.0.15 h1:KZrwa2ciL9od8+TUVJiYTNsCW9J5lktBjGwW1MacEnQ=
github.com/pion/ice/v2 v2.0.15/go.mod h1:ZIiVGevpgAxF/cXiIVmuIUtCb3Xs4gCzCbXB6+nFkSI=
github.com/pion/interceptor v0.0.9 h1:fk5hTdyLO3KURQsf/+RjMpEm4NE3yeTY9Kh97b5BvwA=
@ -97,6 +101,8 @@ github.com/pion/udp v0.1.0 h1:uGxQsNyrqG3GLINv36Ff60covYmfrLoxzwnCsIYspXI=
github.com/pion/udp v0.1.0/go.mod h1:BPELIjbwE9PRbd/zxI/KYBnbo7B6+oA6YuEaNE8lths=
github.com/pion/webrtc/v3 v3.0.8 h1:Dgu/NZ6QAIvoNZU3qk/B35iPPx6TVHP506FfCE4SXCA=
github.com/pion/webrtc/v3 v3.0.8/go.mod h1:C5uzSMa9sGCtfVPLA+pB0eWoW/exZ0OV0KW7JJbkvp0=
github.com/pion/webrtc/v3 v3.0.10 h1:hti6k0DeN4tbQmAZiA8v6OvdkANQGw+R3nyqk9+dnz0=
github.com/pion/webrtc/v3 v3.0.10/go.mod h1:KdEZWLmBnxB2Qj4FtUb9vi1sIpqsHOisI7L6ggQBD0A=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

14
main.go

@ -158,9 +158,15 @@ func (rtc *WebRTC) Publish(streamPath string) bool {
var etrack engine.Track
if track.Kind() == RTPCodecTypeAudio {
//TODO: 判断音频格式
etrack = rtc.AudioTracks["pcma"]
at := engine.NewAudioTrack()
at.SoundFormat = 7
rtc.SetOriginAT(at)
etrack = at
} else {
etrack = rtc.VideoTracks["h264"]
vt := engine.NewVideoTrack()
vt.CodecID = 7
rtc.SetOriginVT(vt)
etrack = vt
}
var pack rtp.Packet
b := make([]byte, 1460)
@ -319,10 +325,10 @@ func run() {
rtc.PeerConnection.Close()
case ICEConnectionStateConnected:
if at != nil {
go sub.PlayAudio(sub.Context, at)
go sub.PlayAudio(at)
}
if vt != nil {
go sub.PlayVideo(sub.Context, vt)
go sub.PlayVideo(vt)
}
}
})

Loading…
Cancel
Save