This commit is contained in:
Sense T
2022-10-02 11:29:57 +00:00
parent b945218c85
commit 708732a37b
8 changed files with 76 additions and 281 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/pion/mediadevices/pkg/codec/opus"
"github.com/pion/mediadevices/pkg/codec/x264"
"github.com/pion/mediadevices/pkg/driver"
"github.com/pion/mediadevices/pkg/prop"
"github.com/pion/webrtc/v3"
"github.com/sirupsen/logrus"
)
@@ -24,7 +23,7 @@ func New(o *Options) (*Connection, error) {
connection := &Connection{
option: o,
}
codecSelector, err := setupCodec(o.Video.BPS)
codecSelector, err := setupCodec(o.VideoBPS)
if err != nil {
return nil, err
}
@@ -45,10 +44,7 @@ func New(o *Options) (*Connection, error) {
}
s, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
Video: func(mtc *mediadevices.MediaTrackConstraints) {
mtc.Height = prop.Int(o.Video.Height)
mtc.Width = prop.Int(o.Video.Width)
},
Video: func(mtc *mediadevices.MediaTrackConstraints) {},
Audio: func(mtc *mediadevices.MediaTrackConstraints) {},
Codec: codecSelector,
})

View File

@@ -2,11 +2,7 @@ package webrtcconnection
type Options struct {
STUNServers []string `yaml:"stun_servers"`
Video struct {
Height int `yaml:"height"`
Width int `yaml:"width"`
BPS int `yaml:"bps"`
} `yaml:"video"`
VideoBPS int `yaml:"video_bps"`
}
func ExampleOptions() *Options {
@@ -15,9 +11,7 @@ func ExampleOptions() *Options {
"stun:stun.l.google.com:19302",
"stun:wetofu.me:3478",
},
VideoBPS: 500_000,
}
options.Video.BPS = 500_000
options.Video.Height = 768
options.Video.Width = 1024
return options
}