debug needed
This commit is contained in:
@@ -12,26 +12,41 @@ const DefaultStreamID = "ace-server"
|
||||
|
||||
type Connection struct {
|
||||
option *Options
|
||||
api *webrtc.API
|
||||
stream mediadevices.MediaStream
|
||||
}
|
||||
|
||||
func New(o *Options) *Connection {
|
||||
return &Connection{
|
||||
func New(o *Options) (*Connection, error) {
|
||||
connection := &Connection{
|
||||
option: o,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Connection) Regist(offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
|
||||
logrus.Debug("received offer ", offer.Type.String())
|
||||
codecSelector, err := setupCodec(c.option.Video.BPS, c.option.Audio.BPS)
|
||||
codecSelector, err := setupCodec(o.Video.BPS, o.Audio.BPS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
me := &webrtc.MediaEngine{}
|
||||
codecSelector.Populate(me)
|
||||
api := webrtc.NewAPI(webrtc.WithMediaEngine(me))
|
||||
|
||||
rtc, err := api.NewPeerConnection(webrtc.Configuration{
|
||||
connection.api = webrtc.NewAPI(webrtc.WithMediaEngine(me))
|
||||
|
||||
s, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
|
||||
Video: func(mtc *mediadevices.MediaTrackConstraints) {},
|
||||
Audio: func(mtc *mediadevices.MediaTrackConstraints) {},
|
||||
Codec: codecSelector,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
connection.stream = s
|
||||
|
||||
return connection, nil
|
||||
}
|
||||
|
||||
func (c *Connection) Regist(offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error) {
|
||||
logrus.Debug("received offer ", offer.Type.String())
|
||||
|
||||
rtc, err := c.api.NewPeerConnection(webrtc.Configuration{
|
||||
ICEServers: []webrtc.ICEServer{
|
||||
{
|
||||
URLs: c.option.STUNServers,
|
||||
@@ -53,21 +68,7 @@ func (c *Connection) Regist(offer *webrtc.SessionDescription) (*webrtc.SessionDe
|
||||
}
|
||||
})
|
||||
|
||||
s, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
|
||||
Video: func(mtc *mediadevices.MediaTrackConstraints) {
|
||||
/*
|
||||
mtc.Height = prop.IntExact(c.option.Video.Height)
|
||||
mtc.Width = prop.IntExact(c.option.Video.Width)
|
||||
*/
|
||||
},
|
||||
Audio: func(mtc *mediadevices.MediaTrackConstraints) {},
|
||||
Codec: codecSelector,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, track := range s.GetTracks() {
|
||||
for _, track := range c.stream.GetTracks() {
|
||||
track.OnEnded(func(err error) {
|
||||
logrus.Errorf("Track (ID: %s) ended with error: %v", track.ID(), err)
|
||||
})
|
||||
|
@@ -1,7 +0,0 @@
|
||||
package webrtcconnection
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
func init() {
|
||||
logrus.Info("webrtc connection module initialized")
|
||||
}
|
Reference in New Issue
Block a user