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")
|
conn.Connection.Source = query.Get("source")
|
||||||
|
|
||||||
if err := stream.AddConsumer(conn); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,26 +130,11 @@ 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
|
return &CodecNotMatchedError{
|
||||||
|
producerMedias: prodMedias,
|
||||||
for _, media := range prodMedias {
|
consumerMedias: consMedias,
|
||||||
if media.Direction == core.DirectionRecvonly {
|
|
||||||
for _, codec := range media.Codecs {
|
|
||||||
prod = appendString(prod, codec.PrintName())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// 3. Return unknown error
|
||||||
return errors.New("streams: unknown error")
|
return errors.New("streams: unknown error")
|
||||||
@@ -164,3 +149,30 @@ func appendString(s, elem string) string {
|
|||||||
}
|
}
|
||||||
return s + ", " + elem
|
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