Documentation
¶
Index ¶
- Constants
- type BaseMediaProcessor
- func (bmp *BaseMediaProcessor) BaseStart(interval time.Duration, loopFunc func(time.Duration))
- func (bmp *BaseMediaProcessor) CommonEventLoop(interval time.Duration, emitter func() *Event)
- func (bmp *BaseMediaProcessor) GetPipeline() any
- func (bmp *BaseMediaProcessor) Output() <-chan *Event
- func (bmp *BaseMediaProcessor) SetPipeline(p any)
- func (bmp *BaseMediaProcessor) Stop()
- type Configuration
- type Event
- func (e *Event) GetBody() []byte
- func (e *Event) GetContentType() string
- func (e *Event) GetField(key string) any
- func (e *Event) GetFieldByteSlice(key string) []byte
- func (e *Event) GetFieldInt(key string) (int, error)
- func (e *Event) GetFieldString(key string) string
- func (e *Event) GetFields() map[string]any
- func (e *Event) GetHeader(key string) any
- func (e *Event) GetHeaderByteSlice(key string) []byte
- func (e *Event) GetHeaderInt(key string) (int, error)
- func (e *Event) GetHeaderString(key string) string
- func (e *Event) GetHeaders() map[string]any
- func (e *Event) GetMethod() string
- func (e *Event) GetPath() string
- func (e *Event) GetTimestamp() time.Time
- type MediaPipeline
- type MediaProcessor
- type SinkConfiguration
Constants ¶
const ( DefaultChunkBytes = 16000 DefaultMaxBytes = 1440000 DefaultTrimBytes = 1120000 DefaultProcessingInterval = 2000 DefaultMediaType = "audio" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseMediaProcessor ¶
type BaseMediaProcessor struct {
Lock sync.Mutex
ChunkBytes int
MaxBytes int
TrimBytes int
ChunkBuf []byte
NewBytes int
OutputChannel chan *Event
StopChannel chan struct{}
// contains filtered or unexported fields
}
BaseMediaProcessor is the abstract base for all media processors It provides common fields and functionality for accumulating and emitting data
func NewBaseMediaProcessor ¶
func NewBaseMediaProcessor(chunkBytes, maxBytes, trimBytes int) *BaseMediaProcessor
NewBaseMediaProcessor creates a new base media processor with default channels
func (*BaseMediaProcessor) BaseStart ¶
func (bmp *BaseMediaProcessor) BaseStart(interval time.Duration, loopFunc func(time.Duration))
BaseStart starts the processor's event loop Subclasses should override the loop method for specific behavior
func (*BaseMediaProcessor) CommonEventLoop ¶
func (bmp *BaseMediaProcessor) CommonEventLoop(interval time.Duration, emitter func() *Event)
CommonEventLoop provides the standard event loop behavior Used by both audio and video processors
func (*BaseMediaProcessor) GetPipeline ¶
func (bmp *BaseMediaProcessor) GetPipeline() any
GetPipeline returns the underlying media pipeline processor
func (*BaseMediaProcessor) Output ¶
func (bmp *BaseMediaProcessor) Output() <-chan *Event
Output returns the output channel for processed events
func (*BaseMediaProcessor) SetPipeline ¶
func (bmp *BaseMediaProcessor) SetPipeline(p any)
SetPipeline sets the underlying media pipeline processor
func (*BaseMediaProcessor) Stop ¶
func (bmp *BaseMediaProcessor) Stop()
Stop signals the processor to stop processing
type Configuration ¶
type Configuration struct {
trigger.Configuration
RTSPURL string `mapstructure:"rtsp_url"`
ChunkBytes int `mapstructure:"chunk_bytes"`
MaxBytes int `mapstructure:"max_bytes"`
TrimBytes int `mapstructure:"trim_bytes"`
ProcessingInterval time.Duration `mapstructure:"processing_interval"`
MediaType string `mapstructure:"media_type"` // "audio" or "video"
// Output map[string]any `mapstructure:"output"`
Sink *SinkConfiguration `mapstructure:"sink"`
}
func NewConfiguration ¶
func NewConfiguration(id string, triggerConfiguration *functionconfig.Trigger, runtimeConfiguration *runtime.Configuration) (*Configuration, error)
type Event ¶
type Event struct {
nuclio.AbstractEvent
Body []byte
Attributes map[string]any
Timestamp time.Time
}
Event wraps audio packet data from RTSP stream
func (*Event) GetContentType ¶
GetContentType returns the content type of the audio packet
func (*Event) GetFieldByteSlice ¶
GetFieldByteSlice returns an attribute value as a byte slice
func (*Event) GetFieldInt ¶
GetFieldInt returns an attribute value as an int
func (*Event) GetFieldString ¶
GetFieldString returns an attribute value as a string
func (*Event) GetHeaderByteSlice ¶
GetHeaderByteSlice returns a header value as a byte slice
func (*Event) GetHeaderInt ¶
GetHeaderInt returns a header value as an int
func (*Event) GetHeaderString ¶
GetHeaderString returns a header value as a string
func (*Event) GetHeaders ¶
GetHeaders returns all attributes as headers
func (*Event) GetTimestamp ¶
GetTimestamp returns the packet timestamp
type MediaPipeline ¶
MediaPipeline handles RTP depacketization and format-specific processing
func NewMediaPipeline ¶
func NewMediaPipeline(medias []*description.Media) (*MediaPipeline, error)
NewMediaPipeline creates a media pipeline for processing RTP streams
func (*MediaPipeline) ProcessRTP ¶
ProcessRTP handles generic RTP packet processing (audio, H265, etc.)
type MediaProcessor ¶
type MediaProcessor interface {
// Start begins processing with specified interval
Start(interval time.Duration)
// Stop signals the processor to stop
Stop()
// ProcessRTP decodes an RTP packet based on format type
ProcessRTP(pkt *rtp.Packet, forma format.Format) (any, error)
// Push adds data to be processed
Push(data any)
// Output returns the channel for processed events
Output() <-chan *Event
// SetPipeline sets the underlying media pipeline processor
SetPipeline(p any)
}
MediaProcessor defines the interface for processing media data (audio or video) It handles both RTP packet depacketization and buffered event emission
type SinkConfiguration ¶
type SinkConfiguration struct {
Kind string `mapstructure:"kind"`
Attributes map[string]any `mapstructure:"attributes"`
}
SinkConfiguration holds the sink config for the trigger (optional)