mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Allow group.API() to fail.
This commit is contained in:
parent
acca3f9bb3
commit
cd6920d7e2
2 changed files with 20 additions and 9 deletions
|
@ -120,7 +120,7 @@ var groups struct {
|
||||||
groups map[string]*Group
|
groups map[string]*Group
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) API() *webrtc.API {
|
func (g *Group) API() (*webrtc.API, error) {
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
codecs := g.description.Codecs
|
codecs := g.description.Codecs
|
||||||
g.mu.Unlock()
|
g.mu.Unlock()
|
||||||
|
@ -198,7 +198,7 @@ func payloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func APIFromCodecs(codecs []webrtc.RTPCodecCapability) *webrtc.API {
|
func APIFromCodecs(codecs []webrtc.RTPCodecCapability) (*webrtc.API, error) {
|
||||||
s := webrtc.SettingEngine{}
|
s := webrtc.SettingEngine{}
|
||||||
s.SetSRTPReplayProtectionWindow(512)
|
s.SetSRTPReplayProtectionWindow(512)
|
||||||
if !UseMDNS {
|
if !UseMDNS {
|
||||||
|
@ -229,7 +229,7 @@ func APIFromCodecs(codecs []webrtc.RTPCodecCapability) *webrtc.API {
|
||||||
log.Printf("%v", err)
|
log.Printf("%v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.RegisterCodec(
|
err = m.RegisterCodec(
|
||||||
webrtc.RTPCodecParameters{
|
webrtc.RTPCodecParameters{
|
||||||
RTPCodecCapability: webrtc.RTPCodecCapability{
|
RTPCodecCapability: webrtc.RTPCodecCapability{
|
||||||
MimeType: codec.MimeType,
|
MimeType: codec.MimeType,
|
||||||
|
@ -242,14 +242,18 @@ func APIFromCodecs(codecs []webrtc.RTPCodecCapability) *webrtc.API {
|
||||||
},
|
},
|
||||||
tpe,
|
tpe,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return webrtc.NewAPI(
|
return webrtc.NewAPI(
|
||||||
webrtc.WithSettingEngine(s),
|
webrtc.WithSettingEngine(s),
|
||||||
webrtc.WithMediaEngine(&m),
|
webrtc.WithMediaEngine(&m),
|
||||||
)
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func APIFromNames(names []string) *webrtc.API {
|
func APIFromNames(names []string) (*webrtc.API, error) {
|
||||||
if len(names) == 0 {
|
if len(names) == 0 {
|
||||||
names = []string{"vp8", "opus"}
|
names = []string{"vp8", "opus"}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,10 @@ func (down *rtpDownConnection) getTracks() []*rtpDownTrack {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDownConn(c group.Client, id string, remote conn.Up) (*rtpDownConnection, error) {
|
func newDownConn(c group.Client, id string, remote conn.Up) (*rtpDownConnection, error) {
|
||||||
api := c.Group().API()
|
api, err := c.Group().API()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
pc, err := api.NewPeerConnection(*ice.ICEConfiguration())
|
pc, err := api.NewPeerConnection(*ice.ICEConfiguration())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -463,7 +466,11 @@ func newUpConn(c group.Client, id string, label string, offer string) (*rtpUpCon
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pc, err := c.Group().API().NewPeerConnection(*ice.ICEConfiguration())
|
api, err := c.Group().API()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pc, err := api.NewPeerConnection(*ice.ICEConfiguration())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue