mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-26 20:31:11 +08:00
Lower codec not matched error for ffmpeg to debug
This commit is contained in:
@@ -192,7 +192,14 @@ func tcpHandler(conn *rtsp.Conn) {
|
||||
conn.Connection.Source = query.Get("source")
|
||||
|
||||
if err := stream.AddConsumer(conn); err != nil {
|
||||
log.Warn().Err(err).Str("stream", name).Msg("[rtsp]")
|
||||
logEvent := log.Warn()
|
||||
|
||||
if _, ok := err.(*streams.CodecNotMatchedError); ok && strings.HasPrefix(query.Get("source"), "ffmpeg") {
|
||||
// lower codec not matched error for ffmpeg to debug
|
||||
logEvent = log.Debug()
|
||||
}
|
||||
|
||||
logEvent.Err(err).Str("stream", name).Msg("[rtsp]")
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -130,25 +130,10 @@ func formatError(consMedias, prodMedias []*core.Media, prodErrors []error) error
|
||||
|
||||
// 2. Return "codecs not matched"
|
||||
if prodMedias != nil {
|
||||
var prod, cons string
|
||||
|
||||
for _, media := range prodMedias {
|
||||
if media.Direction == core.DirectionRecvonly {
|
||||
for _, codec := range media.Codecs {
|
||||
prod = appendString(prod, codec.PrintName())
|
||||
}
|
||||
}
|
||||
return &CodecNotMatchedError{
|
||||
producerMedias: prodMedias,
|
||||
consumerMedias: consMedias,
|
||||
}
|
||||
|
||||
for _, media := range consMedias {
|
||||
if media.Direction == core.DirectionSendonly {
|
||||
for _, codec := range media.Codecs {
|
||||
cons = appendString(cons, codec.PrintName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("streams: codecs not matched: " + prod + " => " + cons)
|
||||
}
|
||||
|
||||
// 3. Return unknown error
|
||||
@@ -164,3 +149,30 @@ func appendString(s, elem string) string {
|
||||
}
|
||||
return s + ", " + elem
|
||||
}
|
||||
|
||||
type CodecNotMatchedError struct {
|
||||
producerMedias []*core.Media
|
||||
consumerMedias []*core.Media
|
||||
}
|
||||
|
||||
func (e *CodecNotMatchedError) Error() string {
|
||||
var prod, cons string
|
||||
|
||||
for _, media := range e.producerMedias {
|
||||
if media.Direction == core.DirectionRecvonly {
|
||||
for _, codec := range media.Codecs {
|
||||
prod = appendString(prod, codec.PrintName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, media := range e.consumerMedias {
|
||||
if media.Direction == core.DirectionSendonly {
|
||||
for _, codec := range media.Codecs {
|
||||
cons = appendString(cons, codec.PrintName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "streams: codecs not matched: " + prod + " => " + cons
|
||||
}
|
||||
|
Reference in New Issue
Block a user