segment

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

Cursor facilitiates concurrent access to a Segment

func (*Cursor) Serve

func (c *Cursor) Serve(rw http.ResponseWriter, req *http.Request, part int)

Serve the segment to a client.

If part < 0 then the whole segment is served, otherwise just the indicated part is.

func (*Cursor) Valid

func (c *Cursor) Valid() bool

Valid returns true if the segment exists

type MSN

type MSN int

MSN is a Media Sequence Number, it starts at 0 for the first segment and increments for every subsequent segment.

type PartMSN

type PartMSN struct {
	MSN  MSN // index of the last complete segment
	Part int // in-progress subpart of the next segment
}

PartMSN identifies a segment by MSN and a part thereof

func ParseName added in v1.3.0

func ParseName(name string) (id PartMSN, ok bool)

ParseName extracts the MSN and part number from a filename

func (PartMSN) Satisfies

func (m PartMSN) Satisfies(wanted PartMSN) bool

Satisfies returns true if the wanted MSN and part are complete

type Segment

type Segment struct {
	// contains filtered or unexported fields
}

Segment holds a single HLS segment which can be written to in parts

Methods of Segment are not safe for concurrent use. Use Cursor() to get a concurrent accessor.

func New

func New(name, workDir, ctype string, start time.Duration, dcn bool, programTime time.Time) (*Segment, error)

New creates a new HLS segment

func (*Segment) Append

func (s *Segment) Append(frag fragment.Fragment) error

Append a complete fragment to the segment. The buffer must not be modified afterwards.

func (*Segment) Cursor

func (s *Segment) Cursor() Cursor

Cursor returns a proxy with concurrent access to a Segment

func (*Segment) Discontinuous

func (s *Segment) Discontinuous() bool

Discontinuous returns whether the segment immediately follows a change in stream parameters

func (*Segment) Duration

func (s *Segment) Duration() time.Duration

Duration returns the duration of the segment if it has been finalized

func (*Segment) Final

func (s *Segment) Final() bool

Final returns whether the segment is complete

func (*Segment) Finalize

func (s *Segment) Finalize(nextSegment time.Duration)

Finalize a live segment, marking that no more parts will be added

func (*Segment) Format

func (s *Segment) Format(b *bytes.Buffer, includeParts bool)

Format a playlist fragment for this segment

func (*Segment) Parts

func (s *Segment) Parts() int

Parts returns how many parts are currently in the segment

func (*Segment) Release

func (s *Segment) Release()

Release the backing storage associated with the segment

func (*Segment) Size

func (s *Segment) Size() int64

Size returns how many bytes are currently in the segment

func (*Segment) Start

func (s *Segment) Start() time.Duration

Start returns the time at which the segment begins

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL