Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(ok bool)
- func Atoi(s string) (i int)
- func Before(s, sep string) string
- func Between(s, sub1, sub2 string) string
- func Caller() string
- func DecodeH264(fmtp string) (profile string, level byte)
- func FFmpegCodecName(name string) string
- func GetKind(name string) string
- func MarshalSDP(name string, medias []*Media) ([]byte, error)
- func MoveNode(dst, src *Node)
- func Now90000() uint32
- func RandString(size, base byte) string
- type Codec
- func (c *Codec) Clone() *Codec
- func (c *Codec) IsAudio() bool
- func (c *Codec) IsRTP() bool
- func (c *Codec) IsVideo() bool
- func (c *Codec) Kind() string
- func (c *Codec) MarshalJSON() ([]byte, error)
- func (c *Codec) Match(remote *Codec) bool
- func (c *Codec) PrintName() string
- func (c *Codec) String() (s string)
- type Consumer
- type EventFunc
- type Filter
- type HandlerFunc
- type Info
- type Listener
- type Media
- func (m *Media) Clone() *Media
- func (m *Media) Equal(media *Media) bool
- func (m *Media) MarshalJSON() ([]byte, error)
- func (m *Media) MatchAll() bool
- func (m *Media) MatchCodec(remote *Codec) *Codec
- func (m *Media) MatchMedia(remote *Media) (codec, remoteCodec *Codec)
- func (m *Media) String() string
- type Mode
- type Node
- type OnceBuffer
- type Packet
- type Producer
- type ReadBuffer
- type Receiver
- type Sender
- type SuperConsumer
- type SuperProducer
- type Waiter
- type Worker
- type WriteBuffer
Constants ¶
const ( DirectionRecvonly = "recvonly" DirectionSendonly = "sendonly" DirectionSendRecv = "sendrecv" )
const ( KindVideo = "video" KindAudio = "audio" )
const ( CodecH264 = "H264" // payloadType: 96 CodecH265 = "H265" CodecVP8 = "VP8" CodecVP9 = "VP9" CodecAV1 = "AV1" CodecJPEG = "JPEG" // payloadType: 26 CodecRAW = "RAW" CodecPCMU = "PCMU" // payloadType: 0 CodecPCMA = "PCMA" // payloadType: 8 CodecAAC = "MPEG4-GENERIC" CodecOpus = "OPUS" // payloadType: 111 CodecG722 = "G722" CodecMP3 = "MPA" // payload: 14, aka MPEG-1 Layer III CodecPCM = "L16" // Linear PCM (big endian) CodecPCML = "PCML" // Linear PCM (little endian) CodecELD = "ELD" // AAC-ELD CodecFLAC = "FLAC" CodecAll = "ALL" CodecAny = "ANY" )
const ( UnsupportedCodec = "unsupported codec" WrongMediaDirection = "wrong media direction" )
const ( BufferSize = 64 * 1024 // 64K ConnDialTimeout = time.Second * 3 ConnDeadline = time.Second * 5 ProbeTimeout = time.Second * 3 )
const ( BufferDisable = 0 BufferDrainAndClear = -1 )
const PayloadTypeRAW byte = 255
const ProbeSize = 5 * 1024 * 1024 // 5MB
ProbeSize in my tests MPEG-TS 40Mbit/s 4K-video require more than 1MB for probe
Variables ¶
var ErrCantGetTrack = errors.New("can't get track")
Functions ¶
func DecodeH264 ¶
func FFmpegCodecName ¶ added in v1.9.3
func Now90000 ¶ added in v1.5.0
func Now90000() uint32
Now90000 - timestamp for Video (clock rate = 90000 samples per second)
func RandString ¶
RandString base10 - numbers, base16 - hex, base36 - digits+letters base64 - URL safe symbols, base0 - crypto random
Types ¶
type Codec ¶
type Codec struct { Name string // H264, PCMU, PCMA, opus... ClockRate uint32 // 90000, 8000, 16000... Channels uint16 // 0, 1, 2 FmtpLine string PayloadType uint8 }
func UnmarshalCodec ¶
func (*Codec) MarshalJSON ¶ added in v1.9.3
MarshalJSON - return FFprobe compatible output
type Filter ¶ added in v1.9.3
type Filter func(handler HandlerFunc) HandlerFunc
Filter - a decorator for any HandlerFunc
type HandlerFunc ¶
type HandlerFunc func(packet *Packet)
HandlerFunc - process input packets (just like http.HandlerFunc)
type Info ¶
type Info struct { Type string `json:"type,omitempty"` URL string `json:"url,omitempty"` RemoteAddr string `json:"remote_addr,omitempty"` UserAgent string `json:"user_agent,omitempty"` SDP string `json:"sdp,omitempty"` Medias []*Media `json:"medias,omitempty"` Receivers []*Receiver `json:"receivers,omitempty"` Senders []*Sender `json:"senders,omitempty"` Recv int `json:"recv,omitempty"` Send int `json:"send,omitempty"` }
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener base struct for all classes with support feedback
type Media ¶
type Media struct { Kind string `json:"kind,omitempty"` // video or audio Direction string `json:"direction,omitempty"` // sendonly, recvonly Codecs []*Codec `json:"codecs,omitempty"` ID string `json:"id,omitempty"` // MID for WebRTC, Control for RTSP }
Media take best from: - deepch/vdk/format/rtsp/sdp.Media - pion/sdp.MediaDescription
func ParseQuery ¶
func UnmarshalMedia ¶
func UnmarshalMedia(md *sdp.MediaDescription) *Media
func (*Media) MarshalJSON ¶
func (*Media) MatchCodec ¶
func (*Media) MatchMedia ¶
type Node ¶ added in v1.9.3
type Node struct { Codec *Codec `json:"codec"` Input HandlerFunc `json:"-"` Output HandlerFunc `json:"-"` // contains filtered or unexported fields }
Node - Receiver or Sender or Filter (transform)
func (*Node) AppendChild ¶ added in v1.9.3
func (*Node) RemoveChild ¶ added in v1.9.3
func (*Node) WithParent ¶ added in v1.9.3
type OnceBuffer ¶ added in v1.7.0
type OnceBuffer struct {
// contains filtered or unexported fields
}
OnceBuffer will catch only first message
func (*OnceBuffer) Buffer ¶ added in v1.7.0
func (o *OnceBuffer) Buffer() []byte
func (*OnceBuffer) Len ¶ added in v1.7.0
func (o *OnceBuffer) Len() int
type Producer ¶
type Producer interface { // GetMedias - return Media(s) with local Media.Direction: // - recvonly for Producer Video/Audio // - sendonly for Producer backchannel GetMedias() []*Media // GetTrack - return Receiver, that can only produce rtp.Packet(s) GetTrack(media *Media, codec *Codec) (*Receiver, error) // Deprecated: rename to Run() Start() error // Deprecated: rename to Close() Stop() error }
type ReadBuffer ¶ added in v1.7.0
ReadBuffer support buffering and Seek over buffer positive BufferSize will enable buffering mode Seek to negative offset will clear buffer Seek with a positive BufferSize will continue buffering after the last read from the buffer Seek with a negative BufferSize will clear buffer after the last read from the buffer Read more than BufferSize will raise error
func NewReadBuffer ¶ added in v1.7.0
func NewReadBuffer(rd io.Reader) *ReadBuffer
func (*ReadBuffer) Close ¶ added in v1.7.0
func (r *ReadBuffer) Close() error
func (*ReadBuffer) Reset ¶ added in v1.7.0
func (r *ReadBuffer) Reset()
type Receiver ¶
type Receiver struct { Node // Deprecated: should be removed Media *Media `json:"-"` // Deprecated: should be removed ID byte `json:"-"` // Channel for RTSP, PayloadType for MPEG-TS Bytes int `json:"bytes,omitempty"` Packets int `json:"packets,omitempty"` }
func NewReceiver ¶
type Sender ¶
type Sender struct { Node // Deprecated: Media *Media `json:"-"` // Deprecated: Handler HandlerFunc `json:"-"` Bytes int `json:"bytes,omitempty"` Packets int `json:"packets,omitempty"` Drops int `json:"drops,omitempty"` // contains filtered or unexported fields }
func (*Sender) WithParent ¶ added in v1.9.3
type SuperConsumer ¶ added in v1.7.0
type SuperConsumer struct { Type string `json:"type,omitempty"` URL string `json:"url,omitempty"` RemoteAddr string `json:"remote_addr,omitempty"` UserAgent string `json:"user_agent,omitempty"` SDP string `json:"sdp,omitempty"` Medias []*Media `json:"medias,omitempty"` Senders []*Sender `json:"senders,omitempty"` Send int `json:"send,omitempty"` }
func (*SuperConsumer) AddTrack ¶ added in v1.7.0
func (s *SuperConsumer) AddTrack(media *Media, codec *Codec, track *Receiver) error
func (*SuperConsumer) Close ¶ added in v1.7.0
func (s *SuperConsumer) Close() error
func (*SuperConsumer) Codecs ¶ added in v1.7.0
func (s *SuperConsumer) Codecs() []*Codec
func (*SuperConsumer) GetMedias ¶ added in v1.7.0
func (s *SuperConsumer) GetMedias() []*Media
type SuperProducer ¶ added in v1.7.0
type SuperProducer struct { Type string `json:"type,omitempty"` URL string `json:"url,omitempty"` SDP string `json:"sdp,omitempty"` Medias []*Media `json:"medias,omitempty"` Receivers []*Receiver `json:"receivers,omitempty"` Recv int `json:"recv,omitempty"` }
func (*SuperProducer) Close ¶ added in v1.7.0
func (s *SuperProducer) Close() error
func (*SuperProducer) GetMedias ¶ added in v1.7.0
func (s *SuperProducer) GetMedias() []*Media
type Waiter ¶
Waiter support: - autotart on first Wait - block new waiters after last Done - safe Done after finish
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
type WriteBuffer ¶ added in v1.7.0
WriteBuffer by defaul Write(s) to bytes.Buffer. But after WriteTo to new io.Writer - calls Reset. Reset will flush current buffer data to new writer and starts to Write to new io.Writer WriteTo will be locked until Write fails or Close will be called.
func NewWriteBuffer ¶ added in v1.7.0
func NewWriteBuffer(wr io.Writer) *WriteBuffer
func (*WriteBuffer) Close ¶ added in v1.7.0
func (w *WriteBuffer) Close() error
func (*WriteBuffer) Reset ¶ added in v1.7.0
func (w *WriteBuffer) Reset(wr io.Writer)