mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
Sample listeners chan (#33)
* switch to sample listeners. * add streamsink total bytes to metrics. * on rtcp to chan. * change logs. * streamsink add real bitrate. * add timing information to sample. * bitrate buckets. * switch to WriteSample.
This commit is contained in:
@ -200,8 +200,8 @@ func CheckPlugins(plugins []string) error {
|
||||
}
|
||||
|
||||
//export goHandlePipelineBuffer
|
||||
func goHandlePipelineBuffer(pipelineID C.int, buf unsafe.Pointer, bufLen C.int, duration C.guint64, deltaUnit C.gboolean) {
|
||||
defer C.free(buf)
|
||||
func goHandlePipelineBuffer(pipelineID C.int, buf C.gpointer, bufLen C.int, duration C.guint64, deltaUnit C.gboolean) {
|
||||
defer C.g_free(buf)
|
||||
|
||||
pipelinesLock.Lock()
|
||||
pipeline, ok := pipelines[int(pipelineID)]
|
||||
@ -209,7 +209,9 @@ func goHandlePipelineBuffer(pipelineID C.int, buf unsafe.Pointer, bufLen C.int,
|
||||
|
||||
if ok {
|
||||
pipeline.sample <- types.Sample{
|
||||
Data: C.GoBytes(buf, bufLen),
|
||||
Data: C.GoBytes(unsafe.Pointer(buf), bufLen),
|
||||
Length: int(bufLen),
|
||||
Timestamp: time.Now(),
|
||||
Duration: time.Duration(duration),
|
||||
DeltaUnit: deltaUnit == C.TRUE,
|
||||
}
|
||||
|
@ -17,11 +17,20 @@ var (
|
||||
)
|
||||
|
||||
type Sample struct {
|
||||
Data []byte
|
||||
// buffer with encoded media
|
||||
Data []byte
|
||||
Length int
|
||||
// timing information
|
||||
Timestamp time.Time
|
||||
Duration time.Duration
|
||||
// metadata
|
||||
DeltaUnit bool // this unit cannot be decoded independently.
|
||||
}
|
||||
|
||||
type SampleListener interface {
|
||||
WriteSample(Sample)
|
||||
}
|
||||
|
||||
type Receiver interface {
|
||||
SetStream(stream StreamSinkManager) (changed bool, err error)
|
||||
RemoveStream()
|
||||
@ -60,9 +69,9 @@ type StreamSinkManager interface {
|
||||
Codec() codec.RTPCodec
|
||||
Bitrate() int
|
||||
|
||||
AddListener(listener *func(sample Sample)) error
|
||||
RemoveListener(listener *func(sample Sample)) error
|
||||
MoveListenerTo(listener *func(sample Sample), targetStream StreamSinkManager) error
|
||||
AddListener(listener SampleListener) error
|
||||
RemoveListener(listener SampleListener) error
|
||||
MoveListenerTo(listener SampleListener, targetStream StreamSinkManager) error
|
||||
|
||||
ListenersCount() int
|
||||
Started() bool
|
||||
|
Reference in New Issue
Block a user