Skip to content

Commit be2864c

Browse files
committed
Code refactoring after #1588
1 parent c9bdac2 commit be2864c

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pkg/rtsp/helpers.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,11 @@ func UnmarshalSDP(rawSDP []byte) ([]*core.Media, error) {
7777
}
7878
case core.CodecH265:
7979
if codec.FmtpLine != "" {
80-
// All three parameters are needed for a valid fmtp line. If we're missing one
81-
// then discard the entire line. The bitstream should contain the data in NAL units
82-
//
83-
// Some camera brands (notable Hikvision) don't include the vps property, rendering the entire
84-
// line invalid, because the sps property references the non-existent vps proper. This invalid
85-
// data will cause FFmpeg to crash with a `Could not write header (incorrect codec parameters ?): Invalid data found when processing input`
86-
// error when attempting to repackage the HEVC stream into outgoing RTSP stream. Removing the
87-
// fmtp line forces FFmpeg to rely on the bitstream directly, fixing this issue.
88-
valid := strings.Contains(codec.FmtpLine, "sprop-vps=")
89-
valid = valid && strings.Contains(codec.FmtpLine, "sprop-sps=")
90-
valid = valid && strings.Contains(codec.FmtpLine, "sprop-pps=")
91-
if !valid {
80+
// all three parameters are needed for a valid fmtp line
81+
// https://github.com/AlexxIT/go2rtc/pull/1588
82+
if !strings.Contains(codec.FmtpLine, "sprop-vps=") ||
83+
!strings.Contains(codec.FmtpLine, "sprop-sps=") ||
84+
!strings.Contains(codec.FmtpLine, "sprop-pps=") {
9285
codec.FmtpLine = ""
9386
}
9487
}

0 commit comments

Comments
 (0)