debug needed

This commit is contained in:
TonyChyi
2022-09-26 16:07:25 +08:00
parent bd0812cc42
commit 821c0cffb8
12 changed files with 148 additions and 171 deletions

View File

@@ -77,14 +77,10 @@ func makeControlCommand(t int) []qmp.Command {
}
func makeHMCommand(cmdTemplate string, args ...any) qmp.Command {
template := qmp.Command{
return qmp.Command{
Execute: "human-monitor-command",
Args: CommandLine{
Command: fmt.Sprintf(cmdTemplate, args...),
},
}
command := CommandLine{
Command: fmt.Sprintf(cmdTemplate, args...),
}
template.Args = command
return template
}

View File

@@ -1,7 +0,0 @@
package qemuconnection
import "github.com/sirupsen/logrus"
func init() {
logrus.Info("qemu client control events module loaded")
}

View File

@@ -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)
})

View File

@@ -1,7 +0,0 @@
package webrtcconnection
import "github.com/sirupsen/logrus"
func init() {
logrus.Info("webrtc connection module initialized")
}