hls

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 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 Playlist

type Playlist struct {
	// Name video playlist name
	Name string `json:"name" validate:"required"`
	// CreatedAt when the playlist was created
	CreatedAt time.Time `json:"created_at" validate:"required"`
	// Version EXT-X-VERSION value
	Version int `json:"version"`
	// TargetSegDuration target segment duration
	TargetSegDuration float64 `json:"duration" validate:"required"`
	// MediaSequenceVal if specified, the "#EXT-X-MEDIA-SEQUENCE:" value
	MediaSequenceVal *int `json:"start_seq_num,omitempty"`
	// Segments list of TS segments associated with this playlist
	Segments []Segment `json:"segments" validate:"required,gt=0,dive"`
}

Playlist represents a HLS playlist

func (*Playlist) AddMediaSequenceVal

func (p *Playlist) AddMediaSequenceVal(reference time.Time)

AddMediaSequenceVal define a media sequence value for the playlist based on a reference time and the start time of the first segment in the playlist.

@param reference time.Time - reference time to compare against

func (Playlist) String

func (p Playlist) String(continuous bool) (string, error)

String toString function for Playlist

@param continuous bool - whether the playlist should skip the `#EXT-X-ENDLIST` header
@returns the string representation of a HLS Playlist

type PlaylistParser

type PlaylistParser interface {
	/*
		ParsePlaylist parse a HLS playlist to get the playlist properties, and the associated segments,

		The playlist is expected to be already parsed into a list of strings. The expected structure
		of a HLS playlist

		#EXTM3U
		#EXT-X-VERSION:6
		#EXT-X-TARGETDURATION:4
		#EXT-X-MEDIA-SEQUENCE:0
		#EXTINF:4.000000,
		vid-1684541470.ts
		#EXT-X-ENDLIST

			@param ctxt context.Context - execution context
			@param content []string - HLS playlist content
			@param timestamp time.Time - When the playlist is generated
			@param playlistName string - alias name assigned to associated with the playlist
			@param segmentBaseURI string - base URI of individual segments
			@returns parsed playlist
	*/
	ParsePlaylist(
		ctxt context.Context,
		content []string,
		timestamp time.Time,
		playlistName string,
		segmentBaseURI string,
	) (Playlist, error)
}

PlaylistParser HLS playlist parser

func NewPlaylistParser

func NewPlaylistParser() PlaylistParser

NewPlaylistParser define new playlist parser

@returns parser

type Segment

type Segment struct {
	// Name segment name
	Name string `json:"name" validate:"required" gorm:"column:name;not null;primaryKey"`
	// StartTime when segment was first seen
	StartTime time.Time `json:"start" validate:"required" gorm:"column:start_ts;not null"`
	// EndTime end of segment timestamp
	EndTime time.Time `json:"end" validate:"required" gorm:"column:end_ts;not null;primaryKey"`
	// Length segment length in time
	Length float64 `json:"length" validate:"required" gorm:"column:length;not null"`
	// URI video segment storage URI
	URI string `json:"uri" validate:"required,uri" gorm:"column:uri;not null"`
}

Segment represents a HLS TS segment

func (Segment) GetDuration

func (s Segment) GetDuration() time.Duration

GetDuration helper function to convert `Length` to a `time.Duration` field.

@returns segment duration

func (Segment) String

func (s Segment) String() string

String toString function

Jump to

Keyboard shortcuts

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