mirror of
https://github.com/lkmio/lkm.git
synced 2025-09-27 03:26:01 +08:00
34 lines
834 B
Go
34 lines
834 B
Go
package rtmp
|
|
|
|
import (
|
|
"github.com/lkmio/avformat/librtmp"
|
|
"github.com/lkmio/avformat/utils"
|
|
"github.com/lkmio/lkm/stream"
|
|
"net"
|
|
)
|
|
|
|
type Sink struct {
|
|
stream.BaseSink
|
|
stack *librtmp.Stack
|
|
}
|
|
|
|
func (s *Sink) StartStreaming(_ stream.TransStream) error {
|
|
return s.stack.SendStreamBeginChunk()
|
|
}
|
|
|
|
func (s *Sink) StopStreaming(_ stream.TransStream) {
|
|
_ = s.stack.SendStreamEOFChunk()
|
|
}
|
|
|
|
func (s *Sink) Close() {
|
|
s.stack = nil
|
|
s.BaseSink.Close()
|
|
}
|
|
|
|
func NewSink(id stream.SinkID, sourceId string, conn net.Conn, stack *librtmp.Stack) stream.Sink {
|
|
return &Sink{
|
|
BaseSink: stream.BaseSink{ID: id, SourceID: sourceId, State: stream.SessionStateCreated, Protocol: stream.TransStreamRtmp, Conn: conn, DesiredAudioCodecId_: utils.AVCodecIdNONE, DesiredVideoCodecId_: utils.AVCodecIdNONE, TCPStreaming: true},
|
|
stack: stack,
|
|
}
|
|
}
|