重构输出流转发, TransStream不再持有Sink

This commit is contained in:
yangjiechina
2024-10-28 19:15:53 +08:00
parent 9090e28077
commit ec707c8dc1
27 changed files with 894 additions and 747 deletions

View File

@@ -12,11 +12,11 @@ type Sink struct {
stack *librtmp.Stack
}
func (s *Sink) Start() {
_ = s.stack.SendStreamBeginChunk(s.Conn)
func (s *Sink) StartStreaming(_ stream.TransStream) error {
return s.stack.SendStreamBeginChunk(s.Conn)
}
func (s *Sink) Flush() {
func (s *Sink) StopStreaming(_ stream.TransStream) {
_ = s.stack.SendStreamEOFChunk(s.Conn)
}
@@ -27,7 +27,7 @@ func (s *Sink) 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.SessionStateCreate, Protocol: stream.TransStreamRtmp, Conn: conn, DesiredAudioCodecId_: utils.AVCodecIdNONE, DesiredVideoCodecId_: utils.AVCodecIdNONE},
BaseSink: stream.BaseSink{ID: id, SourceID: sourceId, State: stream.SessionStateCreate, Protocol: stream.TransStreamRtmp, Conn: conn, DesiredAudioCodecId_: utils.AVCodecIdNONE, DesiredVideoCodecId_: utils.AVCodecIdNONE, TCPStreaming: true},
stack: stack,
}
}