Archived
2
0

update to pion v3

This commit is contained in:
Marcel Battista
2021-02-14 16:30:24 +00:00
parent 00a785f4c5
commit a362df4976
14 changed files with 211 additions and 84 deletions

View File

@ -4,7 +4,6 @@ import (
"regexp"
"strconv"
"github.com/pion/webrtc/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -19,6 +18,7 @@ type Remote struct {
ScreenWidth int
ScreenHeight int
ScreenRate int
Bitrate string
}
func (Remote) Init(cmd *cobra.Command) error {
@ -47,6 +47,12 @@ func (Remote) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().String("bitrate", "", "set this video bitrate when possible")
if err := viper.BindPFlag("bitrate", cmd.PersistentFlags().Lookup("bitrate")); err != nil {
return err
}
// video codecs
cmd.PersistentFlags().Bool("vp8", false, "use VP8 video codec")
if err := viper.BindPFlag("vp8", cmd.PersistentFlags().Lookup("vp8")); err != nil {
@ -88,24 +94,24 @@ func (Remote) Init(cmd *cobra.Command) error {
}
func (s *Remote) Set() {
videoCodec := webrtc.VP8
videoCodec := "VP8"
if viper.GetBool("vp8") {
videoCodec = webrtc.VP8
videoCodec = "VP8"
} else if viper.GetBool("vp9") {
videoCodec = webrtc.VP9
videoCodec = "VP9"
} else if viper.GetBool("h264") {
videoCodec = webrtc.H264
videoCodec = "H264"
}
audioCodec := webrtc.Opus
audioCodec := "Opus"
if viper.GetBool("opus") {
audioCodec = webrtc.Opus
audioCodec = "Opus"
} else if viper.GetBool("g722") {
audioCodec = webrtc.G722
audioCodec = "G722"
} else if viper.GetBool("pcmu") {
audioCodec = webrtc.PCMU
audioCodec = "PCMU"
} else if viper.GetBool("pcma") {
audioCodec = webrtc.PCMA
audioCodec = "PCMA"
}
s.Device = viper.GetString("device")
@ -114,6 +120,7 @@ func (s *Remote) Set() {
s.Display = viper.GetString("display")
s.VideoCodec = videoCodec
s.VideoParams = viper.GetString("video")
s.Bitrate = viper.GetString("bitrate")
s.ScreenWidth = 1280
s.ScreenHeight = 720

View File

@ -5,8 +5,10 @@ const (
)
const (
SIGNAL_ANSWER = "signal/answer"
SIGNAL_PROVIDE = "signal/provide"
SIGNAL_ANSWER = "signal/answer"
SIGNAL_OFFER = "signal/offer"
SIGNAL_PROVIDE = "signal/provide"
SIGNAL_CANDIDATE = "signal/candidate"
)
const (

View File

@ -27,6 +27,11 @@ type SignalAnswer struct {
SDP string `json:"sdp"`
}
type SignalCandidate struct {
Event string `json:"event"`
Data string `json:"data"`
}
type MembersList struct {
Event string `json:"event"`
Memebers []*types.Member `json:"members"`

View File

@ -24,6 +24,7 @@ type Session interface {
Write(v interface{}) error
Send(v interface{}) error
SignalAnswer(sdp string) error
SignalCandidate(data string) error
}
type SessionManager interface {

View File

@ -1,8 +1,13 @@
package types
import (
"time"
)
type Sample struct {
Data []byte
Samples uint32
Data []byte
Timestamp time.Time
Duration time.Duration
}
type WebRTCManager interface {