Browse Source

修复payloadType问题

v4
dexter 2 years ago
parent
commit
5526f1e44c
  1. 4
      batcher.go
  2. 14
      main.go
  3. 4
      publisher.go

4
batcher.go

@ -80,7 +80,7 @@ func (suber *WebRTCBatcher) Start() (err error) {
} }
} else { } else {
go func() { go func() {
ticker := time.NewTicker(time.Millisecond * webrtcConfig.PLI) ticker := time.NewTicker(webrtcConfig.PLI)
for { for {
select { select {
case <-ticker.C: case <-ticker.C:
@ -92,7 +92,7 @@ func (suber *WebRTCBatcher) Start() (err error) {
} }
} }
}() }()
puber.VideoTrack = NewH264(puber.Stream) puber.VideoTrack = NewH264(puber.Stream, byte(codec.PayloadType))
for { for {
b := make([]byte, 1460) b := make([]byte, 1460)
if i, _, err := track.Read(b); err == nil { if i, _, err := track.Read(b); err == nil {

14
main.go

@ -55,10 +55,10 @@ type WebRTCConfig struct {
PortMin uint16 PortMin uint16
PortMax uint16 PortMax uint16
InvitePortFixed bool InvitePortFixed bool `default:"true"` // 设备将流发送的端口,是否固定 on 发送流到多路复用端口 如9000 off 自动从 mix_port - max_port 之间的值中 选一个可以用的端口
IceUdpMux int IceUdpMux int `default:"9000"` // 接收设备端rtp流的多路复用端口
PLI time.Duration PLI time.Duration `default:"2s"` // 视频流丢包后,发送PLI请求
m MediaEngine m MediaEngine
s SettingEngine s SettingEngine
api *API api *API
@ -168,13 +168,9 @@ func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) {
} }
} }
var webrtcConfig = &WebRTCConfig{ var webrtcConfig WebRTCConfig
InvitePortFixed: true, // 设备将流发送的端口,是否固定 on 发送流到多路复用端口 如9000 off 自动从 mix_port - max_port 之间的值中 选一个可以用的端口
IceUdpMux: 9000, // 接收设备端rtp流的多路复用端口
PLI: time.Second * 2,
}
var WebRTCPlugin = engine.InstallPlugin(webrtcConfig) var WebRTCPlugin = engine.InstallPlugin(&webrtcConfig)
func (conf *WebRTCConfig) Batch(w http.ResponseWriter, r *http.Request) { func (conf *WebRTCConfig) Batch(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/sdp") w.Header().Set("Content-Type", "application/sdp")

4
publisher.go

@ -48,7 +48,7 @@ func (puber *WebRTCPublisher) OnEvent(event any) {
} }
} else { } else {
go func() { go func() {
ticker := time.NewTicker(time.Millisecond * webrtcConfig.PLI) ticker := time.NewTicker(webrtcConfig.PLI)
for { for {
select { select {
case <-ticker.C: case <-ticker.C:
@ -61,7 +61,7 @@ func (puber *WebRTCPublisher) OnEvent(event any) {
} }
}() }()
if puber.Equal(v) { if puber.Equal(v) {
puber.VideoTrack = NewH264(puber.Stream) puber.VideoTrack = NewH264(puber.Stream, byte(codec.PayloadType))
} }
for { for {
b := make([]byte, 1460) b := make([]byte, 1460)

Loading…
Cancel
Save