Checkpoint audio-only Skald fork work
This commit is contained in:
+28
-111
@@ -216,39 +216,6 @@ func fmtpValue(fmtp, key string) string {
|
||||
|
||||
func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, error) {
|
||||
switch strings.ToLower(codec.MimeType) {
|
||||
case "video/vp8":
|
||||
return 96, nil
|
||||
case "video/vp9":
|
||||
profile := fmtpValue(codec.SDPFmtpLine, "profile-id")
|
||||
switch profile {
|
||||
case "", "0":
|
||||
return 98, nil
|
||||
case "2":
|
||||
return 100, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("unknown VP9 profile %v", profile)
|
||||
|
||||
}
|
||||
case "video/av1":
|
||||
return 35, nil
|
||||
case "video/h264":
|
||||
profile := fmtpValue(codec.SDPFmtpLine, "profile-level-id")
|
||||
if profile == "" {
|
||||
return 102, nil
|
||||
}
|
||||
if len(profile) < 4 {
|
||||
return 0, errors.New("malforned H.264 profile")
|
||||
}
|
||||
switch strings.ToLower(profile[:4]) {
|
||||
case "4200":
|
||||
return 102, nil
|
||||
case "42e0":
|
||||
return 108, nil
|
||||
default:
|
||||
return 0, fmt.Errorf(
|
||||
"unknown H.264 profile %v", profile,
|
||||
)
|
||||
}
|
||||
case "audio/opus":
|
||||
return 111, nil
|
||||
case "audio/g722":
|
||||
@@ -262,89 +229,48 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
|
||||
}
|
||||
}
|
||||
|
||||
// VideoRTCPFeedback are the RTCP feedback types that we expect for video
|
||||
// tracks.
|
||||
var VideoRTCPFeedback = []webrtc.RTCPFeedback{
|
||||
{"goog-remb", ""},
|
||||
{"nack", ""},
|
||||
{"nack", "pli"},
|
||||
{"ccm", "fir"},
|
||||
}
|
||||
|
||||
// AudioRTCPFeedback is like VideoRTCPFeedback but for audio tracks.
|
||||
// AudioRTCPFeedback is the RTCP feedback for audio tracks.
|
||||
var AudioRTCPFeedback = []webrtc.RTCPFeedback(nil)
|
||||
|
||||
func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
|
||||
var codecs []webrtc.RTPCodecCapability
|
||||
|
||||
switch name {
|
||||
case "vp8":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"video/VP8", 90000, 0,
|
||||
"",
|
||||
VideoRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "vp9":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"video/VP9", 90000, 0,
|
||||
"profile-id=0",
|
||||
VideoRTCPFeedback,
|
||||
},
|
||||
{
|
||||
"video/VP9", 90000, 0,
|
||||
"profile-id=2",
|
||||
VideoRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "av1":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"video/AV1", 90000, 0,
|
||||
"",
|
||||
VideoRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "h264":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"video/H264", 90000, 0,
|
||||
"level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",
|
||||
VideoRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "opus":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"audio/opus", 48000, 2,
|
||||
"minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1",
|
||||
AudioRTCPFeedback,
|
||||
MimeType: "audio/opus",
|
||||
ClockRate: 48000,
|
||||
Channels: 2,
|
||||
SDPFmtpLine: "minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1",
|
||||
RTCPFeedback: AudioRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "g722":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"audio/G722", 8000, 1,
|
||||
"",
|
||||
AudioRTCPFeedback,
|
||||
MimeType: "audio/G722",
|
||||
ClockRate: 8000,
|
||||
Channels: 1,
|
||||
RTCPFeedback: AudioRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "pcmu":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"audio/PCMU", 8000, 1,
|
||||
"",
|
||||
AudioRTCPFeedback,
|
||||
MimeType: "audio/PCMU",
|
||||
ClockRate: 8000,
|
||||
Channels: 1,
|
||||
RTCPFeedback: AudioRTCPFeedback,
|
||||
},
|
||||
}
|
||||
case "pcma":
|
||||
codecs = []webrtc.RTPCodecCapability{
|
||||
{
|
||||
"audio/PCMA", 8000, 1,
|
||||
"",
|
||||
AudioRTCPFeedback,
|
||||
MimeType: "audio/PCMA",
|
||||
ClockRate: 8000,
|
||||
Channels: 1,
|
||||
RTCPFeedback: AudioRTCPFeedback,
|
||||
},
|
||||
}
|
||||
default:
|
||||
@@ -384,11 +310,7 @@ func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error) {
|
||||
m := webrtc.MediaEngine{}
|
||||
|
||||
for _, codec := range codecs {
|
||||
tpe := webrtc.RTPCodecTypeVideo
|
||||
if strings.HasPrefix(strings.ToLower(codec.MimeType), "audio/") {
|
||||
tpe = webrtc.RTPCodecTypeAudio
|
||||
}
|
||||
err := m.RegisterCodec(codec, tpe)
|
||||
err := m.RegisterCodec(codec, webrtc.RTPCodecTypeAudio)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
continue
|
||||
@@ -401,11 +323,6 @@ func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error) {
|
||||
s.SetEphemeralUDPPortRange(UDPMin, UDPMax)
|
||||
}
|
||||
|
||||
err := webrtc.ConfigureSimulcastExtensionHeaders(&m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ir := interceptor.Registry{}
|
||||
|
||||
return webrtc.NewAPI(
|
||||
@@ -417,7 +334,7 @@ func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error) {
|
||||
|
||||
func APIFromNames(names []string) (*webrtc.API, error) {
|
||||
if len(names) == 0 {
|
||||
names = []string{"vp8", "opus"}
|
||||
names = []string{"opus"}
|
||||
}
|
||||
var codecs []webrtc.RTPCodecParameters
|
||||
for _, n := range names {
|
||||
@@ -543,14 +460,14 @@ func GetNames() []string {
|
||||
return names
|
||||
}
|
||||
|
||||
type SubGroup struct {
|
||||
type SubHall struct {
|
||||
Name string
|
||||
Clients int
|
||||
}
|
||||
|
||||
func GetSubGroups(parent string) []SubGroup {
|
||||
func GetSubHalls(parent string) []SubHall {
|
||||
prefix := parent + "/"
|
||||
subgroups := make([]SubGroup, 0)
|
||||
subhalls := make([]SubHall, 0)
|
||||
|
||||
Range(func(g *Hall) bool {
|
||||
if strings.HasPrefix(g.name, prefix) {
|
||||
@@ -558,13 +475,13 @@ func GetSubGroups(parent string) []SubGroup {
|
||||
count := len(g.clients)
|
||||
g.mu.Unlock()
|
||||
if count > 0 {
|
||||
subgroups = append(subgroups,
|
||||
SubGroup{g.name, count})
|
||||
subhalls = append(subhalls,
|
||||
SubHall{g.name, count})
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
return subgroups
|
||||
return subhalls
|
||||
}
|
||||
|
||||
func Get(name string) *Hall {
|
||||
@@ -929,7 +846,7 @@ type Configuration struct {
|
||||
AllowOrigin []string `json:"allowOrigin,omitempty"`
|
||||
AllowAdminOrigin []string `json:"allowAdminOrigin,omitempty"`
|
||||
ProxyURL string `json:"proxyURL,omitempty"`
|
||||
WritableGroups bool `json:"writableGroups,omitempty"`
|
||||
WritableHalls bool `json:"writableHalls,omitempty"`
|
||||
Users map[string]UserDescription `json:"users,omitempty"`
|
||||
|
||||
// obsolete fields
|
||||
@@ -1173,7 +1090,7 @@ func (g *Hall) Status(authentified bool, base *url.URL) Status {
|
||||
if authentified {
|
||||
conf, err := GetConfiguration()
|
||||
if err == nil {
|
||||
d.CanChangePassword = conf.WritableGroups
|
||||
d.CanChangePassword = conf.WritableHalls
|
||||
}
|
||||
}
|
||||
return d
|
||||
|
||||
Reference in New Issue
Block a user