Browse Source

record: rename recFormat into format (#2776)

pull/2775/head
Alessandro Ros 1 year ago committed by GitHub
parent
commit
5da2ded815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      internal/record/agent_instance.go
  2. 12
      internal/record/agent_test.go
  3. 2
      internal/record/format.go
  4. 46
      internal/record/format_fmp4.go
  5. 24
      internal/record/format_fmp4_part.go
  6. 24
      internal/record/format_fmp4_segment.go
  7. 18
      internal/record/format_fmp4_track.go
  8. 34
      internal/record/format_mpegts.go
  9. 12
      internal/record/format_mpegts_segment.go

6
internal/record/agent_instance.go

@ -24,7 +24,7 @@ type agentInstance struct { @@ -24,7 +24,7 @@ type agentInstance struct {
resolvedPath string
writer *asyncwriter.Writer
format recFormat
format format
terminate chan struct{}
done chan struct{}
@ -48,13 +48,13 @@ func (a *agentInstance) initialize() { @@ -48,13 +48,13 @@ func (a *agentInstance) initialize() {
switch a.wrapper.Format {
case conf.RecordFormatMPEGTS:
a.format = &recFormatMPEGTS{
a.format = &formatMPEGTS{
a: a,
}
a.format.initialize()
default:
a.format = &recFormatFMP4{
a.format = &formatFMP4{
a: a,
}
a.format.initialize()

12
internal/record/agent_test.go

@ -7,7 +7,7 @@ import ( @@ -7,7 +7,7 @@ import (
"time"
"github.com/bluenviron/gortsplib/v4/pkg/description"
"github.com/bluenviron/gortsplib/v4/pkg/format"
rtspformat "github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediacommon/pkg/codecs/h265"
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
"github.com/bluenviron/mediacommon/pkg/formats/fmp4"
@ -28,20 +28,20 @@ func TestAgent(t *testing.T) { @@ -28,20 +28,20 @@ func TestAgent(t *testing.T) {
desc := &description.Session{Medias: []*description.Media{
{
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H265{
Formats: []rtspformat.Format{&rtspformat.H265{
PayloadTyp: 96,
}},
},
{
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H264{
Formats: []rtspformat.Format{&rtspformat.H264{
PayloadTyp: 96,
PacketizationMode: 1,
}},
},
{
Type: description.MediaTypeAudio,
Formats: []format.Format{&format.MPEG4Audio{
Formats: []rtspformat.Format{&rtspformat.MPEG4Audio{
PayloadTyp: 96,
Config: &mpeg4audio.Config{
Type: 2,
@ -225,14 +225,14 @@ func TestAgentFMP4NegativeDTS(t *testing.T) { @@ -225,14 +225,14 @@ func TestAgentFMP4NegativeDTS(t *testing.T) {
desc := &description.Session{Medias: []*description.Media{
{
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H264{
Formats: []rtspformat.Format{&rtspformat.H264{
PayloadTyp: 96,
PacketizationMode: 1,
}},
},
{
Type: description.MediaTypeAudio,
Formats: []format.Format{&format.MPEG4Audio{
Formats: []rtspformat.Format{&rtspformat.MPEG4Audio{
PayloadTyp: 96,
Config: &mpeg4audio.Config{
Type: 2,

2
internal/record/rec_format.go → internal/record/format.go

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
package record
type recFormat interface {
type format interface {
initialize()
close()
}

46
internal/record/rec_format_fmp4.go → internal/record/format_fmp4.go

@ -5,7 +5,7 @@ import ( @@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/bluenviron/gortsplib/v4/pkg/format"
rtspformat "github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediacommon/pkg/codecs/ac3"
"github.com/bluenviron/mediacommon/pkg/codecs/av1"
"github.com/bluenviron/mediacommon/pkg/codecs/h264"
@ -96,19 +96,19 @@ func jpegExtractSize(image []byte) (int, int, error) { @@ -96,19 +96,19 @@ func jpegExtractSize(image []byte) (int, int, error) {
}
}
type recFormatFMP4 struct {
type formatFMP4 struct {
a *agentInstance
tracks []*recFormatFMP4Track
tracks []*formatFMP4Track
hasVideo bool
currentSegment *recFormatFMP4Segment
currentSegment *formatFMP4Segment
nextSequenceNumber uint32
}
func (f *recFormatFMP4) initialize() {
func (f *formatFMP4) initialize() {
nextID := 1
addTrack := func(codec fmp4.Codec) *recFormatFMP4Track {
addTrack := func(codec fmp4.Codec) *formatFMP4Track {
initTrack := &fmp4.InitTrack{
TimeScale: 90000,
Codec: codec,
@ -116,7 +116,7 @@ func (f *recFormatFMP4) initialize() { @@ -116,7 +116,7 @@ func (f *recFormatFMP4) initialize() {
initTrack.ID = nextID
nextID++
track := newRecFormatFMP4Track(f, initTrack)
track := newFormatFMP4Track(f, initTrack)
f.tracks = append(f.tracks, track)
return track
@ -135,7 +135,7 @@ func (f *recFormatFMP4) initialize() { @@ -135,7 +135,7 @@ func (f *recFormatFMP4) initialize() {
for _, media := range f.a.wrapper.Stream.Desc().Medias {
for _, forma := range media.Formats {
switch forma := forma.(type) {
case *format.AV1:
case *rtspformat.AV1:
codec := &fmp4.CodecAV1{
SequenceHeader: []byte{
8, 0, 0, 0, 66, 167, 191, 228, 96, 13, 0, 64,
@ -189,7 +189,7 @@ func (f *recFormatFMP4) initialize() { @@ -189,7 +189,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.VP9:
case *rtspformat.VP9:
codec := &fmp4.CodecVP9{
Width: 1280,
Height: 720,
@ -261,10 +261,10 @@ func (f *recFormatFMP4) initialize() { @@ -261,10 +261,10 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.VP8:
case *rtspformat.VP8:
// TODO
case *format.H265:
case *rtspformat.H265:
vps, sps, pps := forma.SafeParams()
if vps == nil || sps == nil || pps == nil {
@ -360,7 +360,7 @@ func (f *recFormatFMP4) initialize() { @@ -360,7 +360,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.H264:
case *rtspformat.H264:
sps, pps := forma.SafeParams()
if sps == nil || pps == nil {
@ -438,7 +438,7 @@ func (f *recFormatFMP4) initialize() { @@ -438,7 +438,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.MPEG4Video:
case *rtspformat.MPEG4Video:
config := forma.SafeParams()
if config == nil {
@ -499,7 +499,7 @@ func (f *recFormatFMP4) initialize() { @@ -499,7 +499,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.MPEG1Video:
case *rtspformat.MPEG1Video:
codec := &fmp4.CodecMPEG1Video{
Config: []byte{
0x00, 0x00, 0x01, 0xb3, 0x78, 0x04, 0x38, 0x35,
@ -551,7 +551,7 @@ func (f *recFormatFMP4) initialize() { @@ -551,7 +551,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.MJPEG:
case *rtspformat.MJPEG:
codec := &fmp4.CodecMJPEG{
Width: 800,
Height: 600,
@ -585,7 +585,7 @@ func (f *recFormatFMP4) initialize() { @@ -585,7 +585,7 @@ func (f *recFormatFMP4) initialize() {
})
})
case *format.Opus:
case *rtspformat.Opus:
codec := &fmp4.CodecOpus{
ChannelCount: func() int {
if forma.IsStereo {
@ -621,7 +621,7 @@ func (f *recFormatFMP4) initialize() { @@ -621,7 +621,7 @@ func (f *recFormatFMP4) initialize() {
return nil
})
case *format.MPEG4Audio:
case *rtspformat.MPEG4Audio:
codec := &fmp4.CodecMPEG4Audio{
Config: *forma.GetConfig(),
}
@ -653,7 +653,7 @@ func (f *recFormatFMP4) initialize() { @@ -653,7 +653,7 @@ func (f *recFormatFMP4) initialize() {
return nil
})
case *format.MPEG1Audio:
case *rtspformat.MPEG1Audio:
codec := &fmp4.CodecMPEG1Audio{
SampleRate: 32000,
ChannelCount: 2,
@ -701,7 +701,7 @@ func (f *recFormatFMP4) initialize() { @@ -701,7 +701,7 @@ func (f *recFormatFMP4) initialize() {
return nil
})
case *format.AC3:
case *rtspformat.AC3:
codec := &fmp4.CodecAC3{
SampleRate: forma.SampleRate,
ChannelCount: forma.ChannelCount,
@ -767,13 +767,13 @@ func (f *recFormatFMP4) initialize() { @@ -767,13 +767,13 @@ func (f *recFormatFMP4) initialize() {
return nil
})
case *format.G722:
case *rtspformat.G722:
// TODO
case *format.G711:
case *rtspformat.G711:
// TODO
case *format.LPCM:
case *rtspformat.LPCM:
codec := &fmp4.CodecLPCM{
LittleEndian: false,
BitDepth: forma.BitDepth,
@ -809,7 +809,7 @@ func (f *recFormatFMP4) initialize() { @@ -809,7 +809,7 @@ func (f *recFormatFMP4) initialize() {
}())
}
func (f *recFormatFMP4) close() {
func (f *formatFMP4) close() {
if f.currentSegment != nil {
f.currentSegment.close() //nolint:errcheck
}

24
internal/record/rec_format_fmp4_part.go → internal/record/format_fmp4_part.go

@ -15,7 +15,7 @@ import ( @@ -15,7 +15,7 @@ import (
func writePart(
f io.Writer,
sequenceNumber uint32,
partTracks map[*recFormatFMP4Track]*fmp4.PartTrack,
partTracks map[*formatFMP4Track]*fmp4.PartTrack,
) error {
fmp4PartTracks := make([]*fmp4.PartTrack, len(partTracks))
i := 0
@ -39,31 +39,31 @@ func writePart( @@ -39,31 +39,31 @@ func writePart(
return err
}
type recFormatFMP4Part struct {
s *recFormatFMP4Segment
type formatFMP4Part struct {
s *formatFMP4Segment
sequenceNumber uint32
startDTS time.Duration
created time.Time
partTracks map[*recFormatFMP4Track]*fmp4.PartTrack
partTracks map[*formatFMP4Track]*fmp4.PartTrack
endDTS time.Duration
}
func newRecFormatFMP4Part(
s *recFormatFMP4Segment,
func newFormatFMP4Part(
s *formatFMP4Segment,
sequenceNumber uint32,
startDTS time.Duration,
) *recFormatFMP4Part {
return &recFormatFMP4Part{
) *formatFMP4Part {
return &formatFMP4Part{
s: s,
startDTS: startDTS,
sequenceNumber: sequenceNumber,
created: timeNow(),
partTracks: make(map[*recFormatFMP4Track]*fmp4.PartTrack),
partTracks: make(map[*formatFMP4Track]*fmp4.PartTrack),
}
}
func (p *recFormatFMP4Part) close() error {
func (p *formatFMP4Part) close() error {
if p.s.fi == nil {
p.s.fpath = encodeRecordPath(&recordPathParams{time: p.created}, p.s.f.a.resolvedPath)
p.s.f.a.wrapper.Log(logger.Debug, "creating segment %s", p.s.fpath)
@ -92,7 +92,7 @@ func (p *recFormatFMP4Part) close() error { @@ -92,7 +92,7 @@ func (p *recFormatFMP4Part) close() error {
return writePart(p.s.fi, p.sequenceNumber, p.partTracks)
}
func (p *recFormatFMP4Part) record(track *recFormatFMP4Track, sample *sample) error {
func (p *formatFMP4Part) record(track *formatFMP4Track, sample *sample) error {
partTrack, ok := p.partTracks[track]
if !ok {
partTrack = &fmp4.PartTrack{
@ -108,6 +108,6 @@ func (p *recFormatFMP4Part) record(track *recFormatFMP4Track, sample *sample) er @@ -108,6 +108,6 @@ func (p *recFormatFMP4Part) record(track *recFormatFMP4Track, sample *sample) er
return nil
}
func (p *recFormatFMP4Part) duration() time.Duration {
func (p *formatFMP4Part) duration() time.Duration {
return p.endDTS - p.startDTS
}

24
internal/record/rec_format_fmp4_segment.go → internal/record/format_fmp4_segment.go

@ -13,7 +13,7 @@ import ( @@ -13,7 +13,7 @@ import (
var timeNow = time.Now
func writeInit(f io.Writer, tracks []*recFormatFMP4Track) error {
func writeInit(f io.Writer, tracks []*formatFMP4Track) error {
fmp4Tracks := make([]*fmp4.InitTrack, len(tracks))
for i, track := range tracks {
fmp4Tracks[i] = track.initTrack
@ -33,26 +33,26 @@ func writeInit(f io.Writer, tracks []*recFormatFMP4Track) error { @@ -33,26 +33,26 @@ func writeInit(f io.Writer, tracks []*recFormatFMP4Track) error {
return err
}
type recFormatFMP4Segment struct {
f *recFormatFMP4
type formatFMP4Segment struct {
f *formatFMP4
startDTS time.Duration
fpath string
fi *os.File
curPart *recFormatFMP4Part
curPart *formatFMP4Part
}
func newRecFormatFMP4Segment(
f *recFormatFMP4,
func newFormatFMP4Segment(
f *formatFMP4,
startDTS time.Duration,
) *recFormatFMP4Segment {
return &recFormatFMP4Segment{
) *formatFMP4Segment {
return &formatFMP4Segment{
f: f,
startDTS: startDTS,
}
}
func (s *recFormatFMP4Segment) close() error {
func (s *formatFMP4Segment) close() error {
var err error
if s.curPart != nil {
@ -74,9 +74,9 @@ func (s *recFormatFMP4Segment) close() error { @@ -74,9 +74,9 @@ func (s *recFormatFMP4Segment) close() error {
return err
}
func (s *recFormatFMP4Segment) record(track *recFormatFMP4Track, sample *sample) error {
func (s *formatFMP4Segment) record(track *formatFMP4Track, sample *sample) error {
if s.curPart == nil {
s.curPart = newRecFormatFMP4Part(s, s.f.nextSequenceNumber, sample.dts)
s.curPart = newFormatFMP4Part(s, s.f.nextSequenceNumber, sample.dts)
s.f.nextSequenceNumber++
} else if s.curPart.duration() >= s.f.a.wrapper.PartDuration {
err := s.curPart.close()
@ -86,7 +86,7 @@ func (s *recFormatFMP4Segment) record(track *recFormatFMP4Track, sample *sample) @@ -86,7 +86,7 @@ func (s *recFormatFMP4Segment) record(track *recFormatFMP4Track, sample *sample)
return err
}
s.curPart = newRecFormatFMP4Part(s, s.f.nextSequenceNumber, sample.dts)
s.curPart = newFormatFMP4Part(s, s.f.nextSequenceNumber, sample.dts)
s.f.nextSequenceNumber++
}

18
internal/record/rec_format_fmp4_track.go → internal/record/format_fmp4_track.go

@ -4,24 +4,24 @@ import ( @@ -4,24 +4,24 @@ import (
"github.com/bluenviron/mediacommon/pkg/formats/fmp4"
)
type recFormatFMP4Track struct {
f *recFormatFMP4
type formatFMP4Track struct {
f *formatFMP4
initTrack *fmp4.InitTrack
nextSample *sample
}
func newRecFormatFMP4Track(
f *recFormatFMP4,
func newFormatFMP4Track(
f *formatFMP4,
initTrack *fmp4.InitTrack,
) *recFormatFMP4Track {
return &recFormatFMP4Track{
) *formatFMP4Track {
return &formatFMP4Track{
f: f,
initTrack: initTrack,
}
}
func (t *recFormatFMP4Track) record(sample *sample) error {
func (t *formatFMP4Track) record(sample *sample) error {
// wait the first video sample before setting hasVideo
if t.initTrack.Codec.IsVideo() {
t.f.hasVideo = true
@ -34,7 +34,7 @@ func (t *recFormatFMP4Track) record(sample *sample) error { @@ -34,7 +34,7 @@ func (t *recFormatFMP4Track) record(sample *sample) error {
sample.Duration = uint32(durationGoToMp4(t.nextSample.dts-sample.dts, t.initTrack.TimeScale))
if t.f.currentSegment == nil {
t.f.currentSegment = newRecFormatFMP4Segment(t.f, sample.dts)
t.f.currentSegment = newFormatFMP4Segment(t.f, sample.dts)
// BaseTime is negative, this is not supported by fMP4. Reject the sample silently.
} else if (sample.dts - t.f.currentSegment.startDTS) < 0 {
return nil
@ -53,7 +53,7 @@ func (t *recFormatFMP4Track) record(sample *sample) error { @@ -53,7 +53,7 @@ func (t *recFormatFMP4Track) record(sample *sample) error {
return err
}
t.f.currentSegment = newRecFormatFMP4Segment(t.f, t.nextSample.dts)
t.f.currentSegment = newFormatFMP4Segment(t.f, t.nextSample.dts)
}
return nil

34
internal/record/rec_format_mpegts.go → internal/record/format_mpegts.go

@ -7,7 +7,7 @@ import ( @@ -7,7 +7,7 @@ import (
"io"
"time"
"github.com/bluenviron/gortsplib/v4/pkg/format"
rtspformat "github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediacommon/pkg/codecs/ac3"
"github.com/bluenviron/mediacommon/pkg/codecs/h264"
"github.com/bluenviron/mediacommon/pkg/codecs/h265"
@ -38,17 +38,17 @@ func (d *dynamicWriter) setTarget(w io.Writer) { @@ -38,17 +38,17 @@ func (d *dynamicWriter) setTarget(w io.Writer) {
d.w = w
}
type recFormatMPEGTS struct {
type formatMPEGTS struct {
a *agentInstance
dw *dynamicWriter
bw *bufio.Writer
mw *mpegts.Writer
hasVideo bool
currentSegment *recFormatMPEGTSSegment
currentSegment *formatMPEGTSSegment
}
func (f *recFormatMPEGTS) initialize() {
func (f *formatMPEGTS) initialize() {
var tracks []*mpegts.Track
addTrack := func(codec mpegts.Codec) *mpegts.Track {
@ -62,7 +62,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -62,7 +62,7 @@ func (f *recFormatMPEGTS) initialize() {
for _, media := range f.a.wrapper.Stream.Desc().Medias {
for _, forma := range media.Formats {
switch forma := forma.(type) {
case *format.H265:
case *rtspformat.H265:
track := addTrack(&mpegts.CodecH265{})
var dtsExtractor *h265.DTSExtractor
@ -90,7 +90,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -90,7 +90,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.recordH26x(track, dts, durationGoToMPEGTS(tunit.PTS), durationGoToMPEGTS(dts), randomAccess, tunit.AU)
})
case *format.H264:
case *rtspformat.H264:
track := addTrack(&mpegts.CodecH264{})
var dtsExtractor *h264.DTSExtractor
@ -118,7 +118,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -118,7 +118,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.recordH26x(track, dts, durationGoToMPEGTS(tunit.PTS), durationGoToMPEGTS(dts), idrPresent, tunit.AU)
})
case *format.MPEG4Video:
case *rtspformat.MPEG4Video:
track := addTrack(&mpegts.CodecMPEG4Video{})
firstReceived := false
@ -148,7 +148,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -148,7 +148,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.mw.WriteMPEG4Video(track, durationGoToMPEGTS(tunit.PTS), tunit.Frame)
})
case *format.MPEG1Video:
case *rtspformat.MPEG1Video:
track := addTrack(&mpegts.CodecMPEG1Video{})
firstReceived := false
@ -178,7 +178,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -178,7 +178,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.mw.WriteMPEG1Video(track, durationGoToMPEGTS(tunit.PTS), tunit.Frame)
})
case *format.Opus:
case *rtspformat.Opus:
track := addTrack(&mpegts.CodecOpus{
ChannelCount: func() int {
if forma.IsStereo {
@ -202,7 +202,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -202,7 +202,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.mw.WriteOpus(track, durationGoToMPEGTS(tunit.PTS), tunit.Packets)
})
case *format.MPEG4Audio:
case *rtspformat.MPEG4Audio:
track := addTrack(&mpegts.CodecMPEG4Audio{
Config: *forma.GetConfig(),
})
@ -221,7 +221,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -221,7 +221,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.mw.WriteMPEG4Audio(track, durationGoToMPEGTS(tunit.PTS), tunit.AUs)
})
case *format.MPEG1Audio:
case *rtspformat.MPEG1Audio:
track := addTrack(&mpegts.CodecMPEG1Audio{})
f.a.wrapper.Stream.AddReader(f.a.writer, media, forma, func(u unit.Unit) error {
@ -238,7 +238,7 @@ func (f *recFormatMPEGTS) initialize() { @@ -238,7 +238,7 @@ func (f *recFormatMPEGTS) initialize() {
return f.mw.WriteMPEG1Audio(track, durationGoToMPEGTS(tunit.PTS), tunit.Frames)
})
case *format.AC3:
case *rtspformat.AC3:
track := addTrack(&mpegts.CodecAC3{})
sampleRate := time.Duration(forma.SampleRate)
@ -279,16 +279,16 @@ func (f *recFormatMPEGTS) initialize() { @@ -279,16 +279,16 @@ func (f *recFormatMPEGTS) initialize() {
}())
}
func (f *recFormatMPEGTS) close() {
func (f *formatMPEGTS) close() {
if f.currentSegment != nil {
f.currentSegment.close() //nolint:errcheck
}
}
func (f *recFormatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAccess bool) error {
func (f *formatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAccess bool) error {
switch {
case f.currentSegment == nil:
f.currentSegment = newRecFormatMPEGTSSegment(f, dts)
f.currentSegment = newFormatMPEGTSSegment(f, dts)
case (!f.hasVideo || isVideo) &&
randomAccess &&
@ -298,7 +298,7 @@ func (f *recFormatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAc @@ -298,7 +298,7 @@ func (f *recFormatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAc
return err
}
f.currentSegment = newRecFormatMPEGTSSegment(f, dts)
f.currentSegment = newFormatMPEGTSSegment(f, dts)
case (dts - f.currentSegment.lastFlush) >= f.a.wrapper.PartDuration:
err := f.bw.Flush()
@ -312,7 +312,7 @@ func (f *recFormatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAc @@ -312,7 +312,7 @@ func (f *recFormatMPEGTS) setupSegment(dts time.Duration, isVideo bool, randomAc
return nil
}
func (f *recFormatMPEGTS) recordH26x(track *mpegts.Track, goDTS time.Duration,
func (f *formatMPEGTS) recordH26x(track *mpegts.Track, goDTS time.Duration,
pts int64, dts int64, randomAccess bool, au [][]byte,
) error {
f.hasVideo = true

12
internal/record/rec_format_mpegts_segment.go → internal/record/format_mpegts_segment.go

@ -8,8 +8,8 @@ import ( @@ -8,8 +8,8 @@ import (
"github.com/bluenviron/mediamtx/internal/logger"
)
type recFormatMPEGTSSegment struct {
f *recFormatMPEGTS
type formatMPEGTSSegment struct {
f *formatMPEGTS
startDTS time.Duration
lastFlush time.Duration
@ -18,8 +18,8 @@ type recFormatMPEGTSSegment struct { @@ -18,8 +18,8 @@ type recFormatMPEGTSSegment struct {
fi *os.File
}
func newRecFormatMPEGTSSegment(f *recFormatMPEGTS, startDTS time.Duration) *recFormatMPEGTSSegment {
s := &recFormatMPEGTSSegment{
func newFormatMPEGTSSegment(f *formatMPEGTS, startDTS time.Duration) *formatMPEGTSSegment {
s := &formatMPEGTSSegment{
f: f,
startDTS: startDTS,
lastFlush: startDTS,
@ -31,7 +31,7 @@ func newRecFormatMPEGTSSegment(f *recFormatMPEGTS, startDTS time.Duration) *recF @@ -31,7 +31,7 @@ func newRecFormatMPEGTSSegment(f *recFormatMPEGTS, startDTS time.Duration) *recF
return s
}
func (s *recFormatMPEGTSSegment) close() error {
func (s *formatMPEGTSSegment) close() error {
err := s.f.bw.Flush()
if s.fi != nil {
@ -49,7 +49,7 @@ func (s *recFormatMPEGTSSegment) close() error { @@ -49,7 +49,7 @@ func (s *recFormatMPEGTSSegment) close() error {
return err
}
func (s *recFormatMPEGTSSegment) Write(p []byte) (int, error) {
func (s *formatMPEGTSSegment) Write(p []byte) (int, error) {
if s.fi == nil {
s.fpath = encodeRecordPath(&recordPathParams{time: s.created}, s.f.a.resolvedPath)
s.f.a.wrapper.Log(logger.Debug, "creating segment %s", s.fpath)
Loading…
Cancel
Save