mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-27 04:36:12 +08:00
Improve codec not matched error by including kind
This commit is contained in:
@@ -130,12 +130,15 @@ func formatError(consMedias, prodMedias []*core.Media, prodErrors []error) error
|
|||||||
|
|
||||||
// 2. Return "codecs not matched"
|
// 2. Return "codecs not matched"
|
||||||
if prodMedias != nil {
|
if prodMedias != nil {
|
||||||
var prod, cons string
|
var prod, cons map[string]string = make(map[string]string), make(map[string]string)
|
||||||
|
|
||||||
for _, media := range prodMedias {
|
for _, media := range prodMedias {
|
||||||
if media.Direction == core.DirectionRecvonly {
|
if media.Direction == core.DirectionRecvonly {
|
||||||
for _, codec := range media.Codecs {
|
for _, codec := range media.Codecs {
|
||||||
prod = appendString(prod, codec.PrintName())
|
if _, ok := prod[codec.Name]; !ok {
|
||||||
|
prod[media.Kind] = ""
|
||||||
|
}
|
||||||
|
prod[media.Kind] = appendString(prod[media.Kind], codec.PrintName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,18 +146,29 @@ func formatError(consMedias, prodMedias []*core.Media, prodErrors []error) error
|
|||||||
for _, media := range consMedias {
|
for _, media := range consMedias {
|
||||||
if media.Direction == core.DirectionSendonly {
|
if media.Direction == core.DirectionSendonly {
|
||||||
for _, codec := range media.Codecs {
|
for _, codec := range media.Codecs {
|
||||||
cons = appendString(cons, codec.PrintName())
|
if _, ok := cons[codec.Name]; !ok {
|
||||||
|
cons[media.Kind] = ""
|
||||||
|
}
|
||||||
|
cons[media.Kind] = appendString(cons[media.Kind], codec.PrintName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("streams: codecs not matched: " + prod + " => " + cons)
|
return errors.New("streams: codecs not matched: " + mapToString(prod) + " => " + mapToString(cons))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Return unknown error
|
// 3. Return unknown error
|
||||||
return errors.New("streams: unknown error")
|
return errors.New("streams: unknown error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mapToString(m map[string]string) string {
|
||||||
|
var s string
|
||||||
|
for k, v := range m {
|
||||||
|
s = appendString(s, "("+k+": "+v+")")
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
func appendString(s, elem string) string {
|
func appendString(s, elem string) string {
|
||||||
if strings.Contains(s, elem) {
|
if strings.Contains(s, elem) {
|
||||||
return s
|
return s
|
||||||
|
Reference in New Issue
Block a user