Documentation
¶
Index ¶
- Constants
- Variables
- func AddStream(ctxFormat *avformat.Context) *avformat.Stream
- func CloneStream(i *Stream, ctxFormat *avformat.Context) (o *avformat.Stream, err error)
- func HandleLogs(eh *astiencoder.EventHandler)
- func LoggerEventHandlerAdapter(o LoggerEventHandlerAdapterOptions, i astikit.StdLogger, ...)
- func NewFrameRateEnforcerFiller(fn func(fm *avutil.Frame) error, c *astikit.Closer) (f *frameRateEnforcerFiller, err error)
- type AvError
- type Context
- type Decoder
- type DecoderOptions
- type Demuxer
- func (d *Demuxer) Close() error
- func (d *Demuxer) Connect(h PktHandler)
- func (d *Demuxer) ConnectForStream(h PktHandler, i *Stream)
- func (d *Demuxer) Disconnect(h PktHandler)
- func (d *Demuxer) DisconnectForStream(h PktHandler, i *Stream)
- func (d *Demuxer) Start(ctx context.Context, t astiencoder.CreateTaskFunc)
- func (d *Demuxer) Streams() (ss []*Stream)
- type DemuxerOptions
- type DemuxerReadFrameErrorHandler
- type Descriptor
- type Dict
- type Encoder
- func (e *Encoder) AddStream(ctxFormat *avformat.Context) (o *avformat.Stream, err error)
- func (e *Encoder) Close() error
- func (e *Encoder) Connect(h PktHandler)
- func (e *Encoder) Disconnect(h PktHandler)
- func (e *Encoder) FrameSize() int
- func (e *Encoder) HandleFrame(p FrameHandlerPayload)
- func (e *Encoder) Start(ctx context.Context, t astiencoder.CreateTaskFunc)
- type EncoderOptions
- type EventLog
- type Filterer
- func (f *Filterer) Close() error
- func (f *Filterer) Connect(h FrameHandler)
- func (f *Filterer) Disconnect(h FrameHandler)
- func (f *Filterer) HandleFrame(p FrameHandlerPayload)
- func (f *Filterer) OutputCtx() Context
- func (f *Filterer) SendCommand(target, cmd, arg string, flags int) (err error)
- func (f *Filterer) Start(ctx context.Context, t astiencoder.CreateTaskFunc)
- type FiltererOptions
- type Forwarder
- type ForwarderOptions
- type FrameHandler
- type FrameHandlerConnector
- type FrameHandlerPayload
- type FrameRestamper
- type LoggerEventHandlerAdapterOptions
- type Muxer
- type MuxerOptions
- type MuxerPktHandler
- type OutputContexter
- type PktCond
- type PktDumper
- type PktDumperHandlerArgs
- type PktDumperOptions
- type PktHandler
- type PktHandlerConnector
- type PktHandlerPayload
- type PktRestamper
- type PktRestamperStartFromZero
- type PktRestamperWithPktDuration
- type RateEnforcer
- func (r *RateEnforcer) Close() error
- func (r *RateEnforcer) Connect(h FrameHandler)
- func (r *RateEnforcer) Disconnect(h FrameHandler)
- func (r *RateEnforcer) HandleFrame(p FrameHandlerPayload)
- func (r *RateEnforcer) OutputCtx() Context
- func (r *RateEnforcer) Start(ctx context.Context, t astiencoder.CreateTaskFunc)
- func (r *RateEnforcer) Switch(n astiencoder.Node)
- type RateEnforcerFiller
- type RateEnforcerOptions
- type Stream
- type Versions
Constants ¶
const ( EventNameLog = "astilibav.log" // First frame has been dispatched by node EventNameFirstFrameOut = "astilibav.first.frame.out" // First frame of new node has been received by the rate enforcer EventNameRateEnforcerSwitchedIn = "astilibav.rate.enforcer.switched.in" // First frame of new node has been dispatched by the rate enforcer EventNameRateEnforcerSwitchedOut = "astilibav.rate.enforcer.switched.out" )
Event names
const ( StatNameAverageDelay = "astilibav.average.delay" StatNameFilledRate = "astilibav.filled.rate" StatNameIncomingRate = "astilibav.incoming.rate" StatNameOutgoingRate = "astilibav.outgoing.rate" StatNameProcessedRate = "astilibav.processed.rate" StatNameWorkRatio = "astilibav.work.ratio" )
Stat names
Variables ¶
var PktDumpFile = func(pkt *avcodec.Packet, args PktDumperHandlerArgs) (err error) { // Create file var f *os.File if f, err = os.Create(args.Pattern); err != nil { err = fmt.Errorf("astilibav: creating file %s failed: %w", args.Pattern, err) return } defer f.Close() if _, err = f.Write(C.GoBytes(unsafe.Pointer(pkt.Data()), (C.int)(pkt.Size()))); err != nil { err = fmt.Errorf("astilibav: writing to file %s failed: %w", args.Pattern, err) return } return }
PktDumpFunc is a PktDumpFunc that dumps the packet to a file
var Version = Versions{ AvCodec: avcodec.AvcodecVersion(), AvDevice: avdevice.AvdeviceVersion(), AvFilter: avfilter.AvfilterVersion(), AvUtil: avutil.AvutilVersion(), Resample: swresample.SwresampleLicense(), SWScale: swscale.SwscaleVersion(), }
Version stores the versions
Functions ¶
func CloneStream ¶
CloneStream clones a stream and add it to the format ctx
func HandleLogs ¶ added in v0.11.0
func HandleLogs(eh *astiencoder.EventHandler)
TODO Process parent and update event's target
func LoggerEventHandlerAdapter ¶ added in v0.11.0
func LoggerEventHandlerAdapter(o LoggerEventHandlerAdapterOptions, i astikit.StdLogger, h *astiencoder.EventHandler)
Types ¶
type Context ¶
type Context struct {
// Shared
BitRate int
CodecID avcodec.CodecId
CodecName string
CodecType avcodec.MediaType
Dict *Dict
GlobalHeader bool
Index int
ThreadCount *int
TimeBase avutil.Rational
// Audio
ChannelLayout uint64
Channels int
SampleFmt avcodec.AvSampleFormat
SampleRate int
// Video
FrameRate avutil.Rational
GopSize int
Height int
PixelFormat avutil.PixelFormat
SampleAspectRatio avutil.Rational
Width int
}
Context represents parameters of an audio or a video context
func NewContextFromStream ¶
NewContextFromStream creates a new context from a stream
func (Context) Descriptor ¶ added in v0.14.0
func (ctx Context) Descriptor() Descriptor
type Decoder ¶
type Decoder struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Decoder represents an object capable of decoding packets
func NewDecoder ¶
func NewDecoder(o DecoderOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (d *Decoder, err error)
NewDecoder creates a new decoder
func (*Decoder) Connect ¶
func (d *Decoder) Connect(h FrameHandler)
Connect implements the FrameHandlerConnector interface
func (*Decoder) Disconnect ¶
func (d *Decoder) Disconnect(h FrameHandler)
Disconnect implements the FrameHandlerConnector interface
func (*Decoder) HandlePkt ¶
func (d *Decoder) HandlePkt(p PktHandlerPayload)
HandlePkt implements the PktHandler interface
type DecoderOptions ¶
type DecoderOptions struct {
CodecParams *avcodec.CodecParameters
Node astiencoder.NodeOptions
OutputCtx Context
}
DecoderOptions represents decoder options
type Demuxer ¶
type Demuxer struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Demuxer represents an object capable of demuxing packets out of an input
func NewDemuxer ¶
func NewDemuxer(o DemuxerOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (d *Demuxer, err error)
NewDemuxer creates a new demuxer
func (*Demuxer) Connect ¶
func (d *Demuxer) Connect(h PktHandler)
Connect implements the PktHandlerConnector interface
func (*Demuxer) ConnectForStream ¶
func (d *Demuxer) ConnectForStream(h PktHandler, i *Stream)
ConnectForStream connects the demuxer to a PktHandler for a specific stream
func (*Demuxer) Disconnect ¶
func (d *Demuxer) Disconnect(h PktHandler)
Disconnect implements the PktHandlerConnector interface
func (*Demuxer) DisconnectForStream ¶
func (d *Demuxer) DisconnectForStream(h PktHandler, i *Stream)
DisconnectForStream disconnects the demuxer from a PktHandler for a specific stream
type DemuxerOptions ¶
type DemuxerOptions struct {
// String content of the demuxer as you would use in ffmpeg
Dict *Dict
// If true, the demuxer will sleep between packets for the exact duration of the packet
EmulateRate bool
// Max duration of continuous packets of the same stream the demuxer receives has to be
// inferior to this value.
// Defaults to 1s
EmulateRateBufferDuration time.Duration
// Exact input format
Format *avformat.InputFormat
// If true, at the end of the input the demuxer will seek to its beginning and start over
// In this case the packets are restamped
Loop bool
// Basic node options
Node astiencoder.NodeOptions
// Context used to cancel probing
ProbeCtx context.Context
// Custom read frame error handler
// If handled is false, default error handling will be executed
ReadFrameErrorHandler DemuxerReadFrameErrorHandler
// URL of the input
URL string
}
DemuxerOptions represents demuxer options
type DemuxerReadFrameErrorHandler ¶ added in v0.14.0
type Descriptor ¶
Descriptor is an object that can describe a set of parameters
func NewDescriptor ¶ added in v0.14.0
func NewDescriptor(timeBase avutil.Rational) Descriptor
type Dict ¶ added in v0.6.0
type Dict struct {
// contains filtered or unexported fields
}
func NewDefaultDict ¶ added in v0.6.0
func NewDefaultDictf ¶ added in v0.6.0
type Encoder ¶
type Encoder struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Encoder represents an object capable of encoding frames
func NewEncoder ¶
func NewEncoder(o EncoderOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (e *Encoder, err error)
NewEncoder creates a new encoder
func (*Encoder) Connect ¶
func (e *Encoder) Connect(h PktHandler)
Connect implements the PktHandlerConnector interface
func (*Encoder) Disconnect ¶
func (e *Encoder) Disconnect(h PktHandler)
Disconnect implements the PktHandlerConnector interface
func (*Encoder) HandleFrame ¶
func (e *Encoder) HandleFrame(p FrameHandlerPayload)
HandleFrame implements the FrameHandler interface
type EncoderOptions ¶
type EncoderOptions struct {
Ctx Context
Node astiencoder.NodeOptions
}
EncoderOptions represents encoder options
type Filterer ¶
type Filterer struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Filterer represents an object capable of applying a filter to frames
func NewFilterer ¶
func NewFilterer(o FiltererOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (f *Filterer, err error)
NewFilterer creates a new filterer
func (*Filterer) Connect ¶
func (f *Filterer) Connect(h FrameHandler)
Connect implements the FrameHandlerConnector interface
func (*Filterer) Disconnect ¶
func (f *Filterer) Disconnect(h FrameHandler)
Disconnect implements the FrameHandlerConnector interface
func (*Filterer) HandleFrame ¶
func (f *Filterer) HandleFrame(p FrameHandlerPayload)
HandleFrame implements the FrameHandler interface
func (*Filterer) SendCommand ¶
SendCommand sends a command to the filterer
type FiltererOptions ¶
type FiltererOptions struct {
Content string
EmulateRate avutil.Rational
Inputs map[string]astiencoder.Node
Node astiencoder.NodeOptions
OutputCtx Context
Restamper FrameRestamper
}
FiltererOptions represents filterer options
type Forwarder ¶
type Forwarder struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Forwarder represents an object capable of forwarding frames
func NewForwarder ¶
func NewForwarder(o ForwarderOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (f *Forwarder)
NewForwarder creates a new forwarder
func (*Forwarder) Connect ¶
func (f *Forwarder) Connect(h FrameHandler)
Connect implements the FrameHandlerConnector interface
func (*Forwarder) Disconnect ¶
func (f *Forwarder) Disconnect(h FrameHandler)
Disconnect implements the FrameHandlerConnector interface
func (*Forwarder) HandleFrame ¶
func (f *Forwarder) HandleFrame(p FrameHandlerPayload)
HandleFrame implements the FrameHandler interface
type ForwarderOptions ¶
type ForwarderOptions struct {
Node astiencoder.NodeOptions
OutputCtx Context
Restamper FrameRestamper
}
ForwarderOptions represents forwarder options
type FrameHandler ¶
type FrameHandler interface {
astiencoder.Node
HandleFrame(p FrameHandlerPayload)
}
FrameHandler represents a node that can handle a frame
type FrameHandlerConnector ¶
type FrameHandlerConnector interface {
Connect(next FrameHandler)
Disconnect(next FrameHandler)
}
FrameHandlerConnector represents an object that can connect/disconnect with a frame handler
type FrameHandlerPayload ¶
type FrameHandlerPayload struct {
Descriptor Descriptor
Frame *avutil.Frame
Node astiencoder.Node
}
FrameHandlerPayload represents a FrameHandler payload
type FrameRestamper ¶
FrameRestamper represents an object capable of restamping frames
func NewFrameRestamperWithFrameDuration ¶
func NewFrameRestamperWithFrameDuration(frameDuration int64) FrameRestamper
NewFrameRestamperWithFrameDuration creates a new frame restamper that starts timestamps from 0 and increments them of frameDuration frameDuration must be a duration in frame time base
func NewFrameRestamperWithModulo ¶
func NewFrameRestamperWithModulo(frameDuration int64) FrameRestamper
NewFrameRestamperWithModulo creates a new frame restamper that makes sure that PTS % frame duration = 0 frameDuration must be a duration in frame time base
type LoggerEventHandlerAdapterOptions ¶ added in v0.11.0
type Muxer ¶
type Muxer struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
Muxer represents an object capable of muxing packets into an output
func NewMuxer ¶
func NewMuxer(o MuxerOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (m *Muxer, err error)
NewMuxer creates a new muxer
func (*Muxer) NewPktHandler ¶
func (m *Muxer) NewPktHandler(o *avformat.Stream) *MuxerPktHandler
NewHandler creates
type MuxerOptions ¶
type MuxerOptions struct {
Format *avformat.OutputFormat
FormatName string
Node astiencoder.NodeOptions
Restamper PktRestamper
URL string
}
MuxerOptions represents muxer options
type MuxerPktHandler ¶
type MuxerPktHandler struct {
*Muxer
// contains filtered or unexported fields
}
MuxerPktHandler is an object that can handle a pkt for the muxer
func (*MuxerPktHandler) HandlePkt ¶
func (h *MuxerPktHandler) HandlePkt(p PktHandlerPayload)
HandlePkt implements the PktHandler interface
type OutputContexter ¶ added in v0.8.0
type OutputContexter interface {
OutputCtx() Context
}
type PktDumper ¶
type PktDumper struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
PktDumper represents an object capable of dumping packets
func NewPktDumper ¶
func NewPktDumper(o PktDumperOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (d *PktDumper, err error)
NewPktDumper creates a new pk dumper
func (*PktDumper) HandlePkt ¶
func (d *PktDumper) HandlePkt(p PktHandlerPayload)
HandlePkt implements the PktHandler interface
type PktDumperHandlerArgs ¶
type PktDumperHandlerArgs struct {
Pattern string
}
PktDumperHandlerArgs represents pkt dumper handler args
type PktDumperOptions ¶
type PktDumperOptions struct {
Data map[string]interface{}
Handler func(pkt *avcodec.Packet, args PktDumperHandlerArgs) error
Node astiencoder.NodeOptions
Pattern string
}
PktDumperOptions represents pkt dumper options
type PktHandler ¶
type PktHandler interface {
astiencoder.Node
HandlePkt(p PktHandlerPayload)
}
PktHandler represents a node that can handle a pkt
type PktHandlerConnector ¶
type PktHandlerConnector interface {
Connect(next PktHandler)
Disconnect(next PktHandler)
}
PktHandlerConnector represents an object that can connect/disconnect with a pkt handler
type PktHandlerPayload ¶
type PktHandlerPayload struct {
Descriptor Descriptor
Node astiencoder.Node
Pkt *avcodec.Packet
}
PktHandlerPayload represents a PktHandler payload
type PktRestamper ¶
PktRestamper represents an object capable of restamping packets
type PktRestamperStartFromZero ¶ added in v0.14.0
type PktRestamperStartFromZero struct {
// contains filtered or unexported fields
}
func NewPktRestamperStartFromZero ¶
func NewPktRestamperStartFromZero() *PktRestamperStartFromZero
NewPktRestamperStartFromZero creates a new pkt restamper that starts timestamps from 0
func (*PktRestamperStartFromZero) Restamp ¶ added in v0.14.0
func (r *PktRestamperStartFromZero) Restamp(pkt *avcodec.Packet)
Restamp implements the Restamper interface
type PktRestamperWithPktDuration ¶ added in v0.14.0
type PktRestamperWithPktDuration struct {
// contains filtered or unexported fields
}
func NewPktRestamperWithPktDuration ¶
func NewPktRestamperWithPktDuration() *PktRestamperWithPktDuration
NewPktRestamperWithPktDuration creates a new pkt restamper that starts timestamps from 0 and increments them of the previous pkt.Duration()
func (*PktRestamperWithPktDuration) Add ¶ added in v0.14.0
func (r *PktRestamperWithPktDuration) Add(delta int64, idx int)
Add adds delta to the last item duration of the specified stream index
func (*PktRestamperWithPktDuration) Restamp ¶ added in v0.14.0
func (r *PktRestamperWithPktDuration) Restamp(pkt *avcodec.Packet)
Restamp implements the FrameRestamper interface
type RateEnforcer ¶
type RateEnforcer struct {
*astiencoder.BaseNode
// contains filtered or unexported fields
}
RateEnforcer represents an object capable of enforcing rate based on PTS
func NewRateEnforcer ¶
func NewRateEnforcer(o RateEnforcerOptions, eh *astiencoder.EventHandler, c *astikit.Closer, s *astiencoder.Stater) (r *RateEnforcer)
NewRateEnforcer creates a new rate enforcer
func (*RateEnforcer) Close ¶ added in v0.14.0
func (r *RateEnforcer) Close() error
Close closes the rate enforcer properly
func (*RateEnforcer) Connect ¶
func (r *RateEnforcer) Connect(h FrameHandler)
Connect implements the FrameHandlerConnector interface
func (*RateEnforcer) Disconnect ¶
func (r *RateEnforcer) Disconnect(h FrameHandler)
Disconnect implements the FrameHandlerConnector interface
func (*RateEnforcer) HandleFrame ¶
func (r *RateEnforcer) HandleFrame(p FrameHandlerPayload)
HandleFrame implements the FrameHandler interface
func (*RateEnforcer) OutputCtx ¶ added in v0.8.0
func (r *RateEnforcer) OutputCtx() Context
OutputCtx returns the output ctx
func (*RateEnforcer) Start ¶
func (r *RateEnforcer) Start(ctx context.Context, t astiencoder.CreateTaskFunc)
Start starts the rate enforcer
func (*RateEnforcer) Switch ¶
func (r *RateEnforcer) Switch(n astiencoder.Node)
Switch switches the source
type RateEnforcerFiller ¶ added in v0.13.0
type RateEnforcerOptions ¶
type RateEnforcerOptions struct {
AdaptSlotsToIncomingFrames bool
// Expressed in number of frames in the output framerate
Delay uint
Filler RateEnforcerFiller
Node astiencoder.NodeOptions
// Both FrameRate and TimeBase are mandatory
OutputCtx Context
Restamper FrameRestamper
}
RateEnforcerOptions represents rate enforcer options