recorder

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0"
)

Functions

func Start

func Start()

Start is main infinite loop function used to start recording channels and checking streams to come out live

func TimeIn

func TimeIn(t time.Time, name string) (time.Time, error)

TimeIn is used to get local time

Types

type Recorder

type Recorder struct {
	Segments Segment
	Online   []string
	Client   *http.Client
}

func New

func New() *Recorder

New is used to create Recorder object and initializing http.Client

func (*Recorder) AddOnline

func (r *Recorder) AddOnline(u string)

AddOnline marks channel name being recorder right now by adding it to Channel struct

func (*Recorder) DownloadSegment

func (r *Recorder) DownloadSegment(log *log.Entry, filepath string, dlc chan *Segment)

DownloadSegment is mainly used as a goroutine which accepts new .ts chunks to be downloaded from GetPlaylist() function and then merges them into local file. Also updates and report total duration and bytes of current stream

func (*Recorder) GetPlaylist

func (r *Recorder) GetPlaylist(log *log.Entry, channel config.Channels, urlStr string, dlc chan *Segment)

GetPlaylist is an infinite loop function used to download m3u8 live playlist file from server then it parses and drops old chunks which are already downloaded. If new chunks are present they are being sent to DownloadSegment() function via channel to be downloaded. New chunks are marked as old after being sent by adding their unique filename in cache. When m3u8 live playlist link is expired (usually 24 hours) it tries to refresh it by generating a new one

func (*Recorder) IsOnline

func (r *Recorder) IsOnline(channel string) bool

IsOnline is used to check Online struct if specified channel is being recorder right now

func (*Recorder) Rec

func (r *Recorder) Rec(log *log.Entry, c *config.Config, channel config.Channels, hlsURL string)

Rec is used to create channel's foldera and to compose stream file name then executes 2 goroutines with 1 shared channel to send data from one to another

func (*Recorder) RefreshPlaylist

func (r *Recorder) RefreshPlaylist(log *log.Entry, channel config.Channels) (string, error)

RefreshPlaylist is used to update direct link to m3u8 live playlist

func (*Recorder) RemoveOnline

func (r *Recorder) RemoveOnline(u string)

RemoveOnline removes channel name from Online struct, usually invokes when stream ends.

func (*Recorder) WaitForRestart

func (r *Recorder) WaitForRestart(log *log.Entry, channel config.Channels) (string, error)

WaitForRestart is used to prevent making multiple stream files by writing stream to the same file in case of channel coming online again in a few minutes

type Segment

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

Jump to

Keyboard shortcuts

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