mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
webrtc add interceptor.
This commit is contained in:
parent
9fcc310685
commit
58854d38dd
1
go.mod
1
go.mod
@ -11,6 +11,7 @@ require (
|
|||||||
github.com/magiconair/properties v1.8.4 // indirect
|
github.com/magiconair/properties v1.8.4 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||||
github.com/pelletier/go-toml v1.8.1 // indirect
|
github.com/pelletier/go-toml v1.8.1 // indirect
|
||||||
|
github.com/pion/interceptor v0.0.10 // indirect
|
||||||
github.com/pion/logging v0.2.2
|
github.com/pion/logging v0.2.2
|
||||||
github.com/pion/transport v0.12.3 // indirect
|
github.com/pion/transport v0.12.3 // indirect
|
||||||
github.com/pion/webrtc/v3 v3.0.15
|
github.com/pion/webrtc/v3 v3.0.15
|
||||||
|
@ -27,7 +27,7 @@ func VP8() RTPCodec {
|
|||||||
ClockRate: 90000,
|
ClockRate: 90000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "",
|
SDPFmtpLine: "",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/vpx/vp8enc.html
|
// https://gstreamer.freedesktop.org/documentation/vpx/vp8enc.html
|
||||||
// gstreamer1.0-plugins-good
|
// gstreamer1.0-plugins-good
|
||||||
@ -46,7 +46,7 @@ func VP9() RTPCodec {
|
|||||||
ClockRate: 90000,
|
ClockRate: 90000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "profile-id=0",
|
SDPFmtpLine: "profile-id=0",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/vpx/vp9enc.html
|
// https://gstreamer.freedesktop.org/documentation/vpx/vp9enc.html
|
||||||
// gstreamer1.0-plugins-good
|
// gstreamer1.0-plugins-good
|
||||||
@ -65,7 +65,7 @@ func H264() RTPCodec {
|
|||||||
ClockRate: 90000,
|
ClockRate: 90000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f",
|
SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/x264/index.html
|
// https://gstreamer.freedesktop.org/documentation/x264/index.html
|
||||||
// gstreamer1.0-plugins-ugly
|
// gstreamer1.0-plugins-ugly
|
||||||
@ -86,7 +86,7 @@ func Opus() RTPCodec {
|
|||||||
ClockRate: 48000,
|
ClockRate: 48000,
|
||||||
Channels: 2,
|
Channels: 2,
|
||||||
SDPFmtpLine: "",
|
SDPFmtpLine: "",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/opus/opusenc.html
|
// https://gstreamer.freedesktop.org/documentation/opus/opusenc.html
|
||||||
// gstreamer1.0-plugins-base
|
// gstreamer1.0-plugins-base
|
||||||
@ -104,7 +104,7 @@ func G722() RTPCodec {
|
|||||||
ClockRate: 8000,
|
ClockRate: 8000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "",
|
SDPFmtpLine: "",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/libav/avenc_g722.html
|
// https://gstreamer.freedesktop.org/documentation/libav/avenc_g722.html
|
||||||
// gstreamer1.0-libav
|
// gstreamer1.0-libav
|
||||||
@ -122,7 +122,7 @@ func PCMU() RTPCodec {
|
|||||||
ClockRate: 8000,
|
ClockRate: 8000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "",
|
SDPFmtpLine: "",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/mulaw/mulawenc.html
|
// https://gstreamer.freedesktop.org/documentation/mulaw/mulawenc.html
|
||||||
// gstreamer1.0-plugins-good
|
// gstreamer1.0-plugins-good
|
||||||
@ -140,7 +140,7 @@ func PCMA() RTPCodec {
|
|||||||
ClockRate: 8000,
|
ClockRate: 8000,
|
||||||
Channels: 0,
|
Channels: 0,
|
||||||
SDPFmtpLine: "",
|
SDPFmtpLine: "",
|
||||||
RTCPFeedback: nil,
|
RTCPFeedback: []webrtc.RTCPFeedback{},
|
||||||
},
|
},
|
||||||
// https://gstreamer.freedesktop.org/documentation/alaw/alawenc.html
|
// https://gstreamer.freedesktop.org/documentation/alaw/alawenc.html
|
||||||
// gstreamer1.0-plugins-good
|
// gstreamer1.0-plugins-good
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pion/interceptor"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"github.com/pion/webrtc/v3/pkg/media"
|
"github.com/pion/webrtc/v3/pkg/media"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
@ -120,8 +121,13 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
|||||||
settings := manager.apiSettings(logger)
|
settings := manager.apiSettings(logger)
|
||||||
configuration := manager.apiConfiguration()
|
configuration := manager.apiConfiguration()
|
||||||
|
|
||||||
|
registry := &interceptor.Registry{}
|
||||||
|
if err := webrtc.RegisterDefaultInterceptors(engine, registry); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Create NewAPI with MediaEngine and SettingEngine
|
// Create NewAPI with MediaEngine and SettingEngine
|
||||||
api := webrtc.NewAPI(webrtc.WithMediaEngine(engine), webrtc.WithSettingEngine(*settings))
|
api := webrtc.NewAPI(webrtc.WithMediaEngine(engine), webrtc.WithSettingEngine(settings), webrtc.WithInterceptorRegistry(registry))
|
||||||
|
|
||||||
connection, err := api.NewPeerConnection(*configuration)
|
connection, err := api.NewPeerConnection(*configuration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -401,8 +407,8 @@ func (manager *WebRTCManagerCtx) mediaEngine(videoID string) (*webrtc.MediaEngin
|
|||||||
return engine, nil
|
return engine, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *WebRTCManagerCtx) apiSettings(logger zerolog.Logger) *webrtc.SettingEngine {
|
func (manager *WebRTCManagerCtx) apiSettings(logger zerolog.Logger) webrtc.SettingEngine {
|
||||||
settings := &webrtc.SettingEngine{
|
settings := webrtc.SettingEngine{
|
||||||
LoggerFactory: loggerFactory{
|
LoggerFactory: loggerFactory{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
},
|
},
|
||||||
@ -412,6 +418,7 @@ func (manager *WebRTCManagerCtx) apiSettings(logger zerolog.Logger) *webrtc.Sett
|
|||||||
settings.SetEphemeralUDPPortRange(manager.config.EphemeralMin, manager.config.EphemeralMax)
|
settings.SetEphemeralUDPPortRange(manager.config.EphemeralMin, manager.config.EphemeralMax)
|
||||||
settings.SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval)
|
settings.SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval)
|
||||||
settings.SetNAT1To1IPs(manager.config.NAT1To1IPs, webrtc.ICECandidateTypeHost)
|
settings.SetNAT1To1IPs(manager.config.NAT1To1IPs, webrtc.ICECandidateTypeHost)
|
||||||
|
//settings.SetSRTPReplayProtectionWindow(512)
|
||||||
settings.SetLite(manager.config.ICELite)
|
settings.SetLite(manager.config.ICELite)
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
Loading…
Reference in New Issue
Block a user