hls

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHLS = errors.New("lal.hls: fxxk")

Functions

func CalcM3U8Duration added in v0.18.0

func CalcM3U8Duration(content []byte) (durationSec float64, err error)

@param content 传入m3u8文件内容

@return durationSec m3u8中所有ts的时间总和。注意,使用的是m3u8文件中描述的ts时间,而不是读取ts文件中实际音视频数据的时间。

func SplitFragment2TSPackets

func SplitFragment2TSPackets(content []byte) (ret [][]byte, err error)

Types

type Fragment added in v0.14.0

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

func (*Fragment) CloseFile added in v0.14.0

func (f *Fragment) CloseFile() error

func (*Fragment) OpenFile added in v0.14.0

func (f *Fragment) OpenFile(filename string) (err error)

func (*Fragment) WriteFile added in v0.15.0

func (f *Fragment) WriteFile(b []byte) (err error)

type Muxer

type Muxer struct {
	UniqueKey string
	// contains filtered or unexported fields
}

func NewMuxer

func NewMuxer(streamName string, config *MuxerConfig, observer MuxerObserver) *Muxer

@param observer 可以为nil,如果不为nil,TS流将回调给上层

func (*Muxer) Dispose added in v0.11.0

func (m *Muxer) Dispose()

func (*Muxer) FeedRTMPMessage

func (m *Muxer) FeedRTMPMessage(msg base.RTMPMsg)

@param msg 函数调用结束后,内部不持有msg中的内存块

func (*Muxer) OnFrame added in v0.15.0

func (m *Muxer) OnFrame(streamer *Streamer, frame *mpegts.Frame)

func (*Muxer) OutPath added in v0.17.0

func (m *Muxer) OutPath() string

func (*Muxer) Start

func (m *Muxer) Start()

type MuxerConfig

type MuxerConfig struct {
	Enable             bool   `json:"enable"`   // 如果false,说明hls功能没开,也即不写磁盘,但是MuxerObserver依然会回调
	OutPath            string `json:"out_path"` // m3u8和ts文件的输出根目录,注意,末尾需已'/'结束
	FragmentDurationMS int    `json:"fragment_duration_ms"`
	FragmentNum        int    `json:"fragment_num"`
}

type MuxerObserver added in v0.15.0

type MuxerObserver interface {
	// @param rawFrame TS流,回调结束后,内部不再使用该内存块
	// @param boundary 新的TS流接收者,应该从该标志为true时开始发送数据
	//
	OnTSPackets(rawFrame []byte, boundary bool)
}

type Server

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

func NewServer

func NewServer(addr string, outPath string) *Server

func (*Server) Dispose added in v0.10.0

func (s *Server) Dispose()

func (*Server) Listen added in v0.10.0

func (s *Server) Listen() (err error)

func (*Server) RunLoop

func (s *Server) RunLoop() error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Streamer added in v0.15.0

type Streamer struct {
	UniqueKey string
	// contains filtered or unexported fields
}

func NewStreamer added in v0.15.0

func NewStreamer(observer StreamerObserver) *Streamer

func (*Streamer) AudioCacheEmpty added in v0.15.0

func (s *Streamer) AudioCacheEmpty() bool

func (*Streamer) AudioSeqHeaderCached added in v0.15.0

func (s *Streamer) AudioSeqHeaderCached() bool

func (*Streamer) FeedRTMPMessage added in v0.15.0

func (s *Streamer) FeedRTMPMessage(msg base.RTMPMsg)

@param msg msg.Payload 调用结束后,函数内部不会持有这块内存

TODO chef: 可以考虑数据有问题时,返回给上层,直接主动关闭输入流的连接

func (*Streamer) FlushAudio added in v0.15.0

func (s *Streamer) FlushAudio()

吐出音频数据的三种情况: 1. 收到音频或视频时,音频缓存队列已达到一定长度 2. 打开一个新的TS文件切片时 3. 输入流关闭时

func (*Streamer) VideoSeqHeaderCached added in v0.15.0

func (s *Streamer) VideoSeqHeaderCached() bool

type StreamerObserver added in v0.15.0

type StreamerObserver interface {
	// @param streamer: 供上层获取streamer内部的一些状态,比如spspps是否已缓存,音频缓存队列是否有数据等
	//
	// @param frame:    各字段含义见mpegts.Frame结构体定义
	//                  frame.CC  注意,回调结束后,Streamer会保存frame.CC,上层在TS打包完成后,可通过frame.CC将cc值传递给Streamer
	//                  frame.Raw 回调结束后,这块内存可能会被内部重复使用
	//
	OnFrame(streamer *Streamer, frame *mpegts.Frame)
}

Jump to

Keyboard shortcuts

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