Added nil checking for the h264Format and g711Format.
This commit is contained in:
parent
670e27f9c4
commit
333a51f633
@ -11,7 +11,7 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
// CheckG711Format finds the H264 media and format.
|
||||
// CheckG711Format finds the G711 media and format.
|
||||
func CheckG711Format(desc *description.Session) (*format.G711, *description.Media, error) {
|
||||
var g711Format *format.G711
|
||||
g711Media := desc.FindFormat(&g711Format)
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/base"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtph264"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm"
|
||||
"github.com/pion/rtp"
|
||||
_ "github.com/zaf/g711"
|
||||
"log"
|
||||
@ -18,6 +20,8 @@ import (
|
||||
|
||||
var (
|
||||
resolutions = []string{"1280x720"}
|
||||
h264RTPDec *rtph264.Decoder
|
||||
g711RTPDec *rtplpcm.Decoder
|
||||
)
|
||||
|
||||
// ProcRTSP process RTSP protocol and writes H264 and PCM flows into TS container.
|
||||
@ -70,16 +74,20 @@ func ProcRTSP(period int, URI string) error {
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Create RTP -> H264 decoder.
|
||||
h264RTPDec, err := h264Format.CreateDecoder()
|
||||
if h264Format != nil {
|
||||
h264RTPDec, err = h264Format.CreateDecoder()
|
||||
if err != nil {
|
||||
return fmt.Errorf("create H264 decoder error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create RTP -> H264 decoder.
|
||||
g711RTPDec, err := g711Format.CreateDecoder()
|
||||
if g711Format != nil {
|
||||
g711RTPDec, err = g711Format.CreateDecoder()
|
||||
if err != nil {
|
||||
return fmt.Errorf("create G711 decoder error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user