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