|
|
|
@ -11,6 +11,7 @@ package logic
|
|
|
|
|
import (
|
|
|
|
|
"github.com/q191201771/lal/pkg/base"
|
|
|
|
|
"github.com/q191201771/lal/pkg/remux"
|
|
|
|
|
"github.com/q191201771/naza/pkg/nazaatomic"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CustomizePubSessionContext struct {
|
|
|
|
@ -19,6 +20,8 @@ type CustomizePubSessionContext struct {
|
|
|
|
|
streamName string
|
|
|
|
|
remuxer *remux.AvPacket2RtmpRemuxer
|
|
|
|
|
onRtmpMsg func(msg base.RtmpMsg)
|
|
|
|
|
|
|
|
|
|
disposeFlag nazaatomic.Bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCustomizePubSessionContext(streamName string) *CustomizePubSessionContext {
|
|
|
|
@ -42,16 +45,28 @@ func (ctx *CustomizePubSessionContext) StreamName() string {
|
|
|
|
|
return ctx.streamName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ctx *CustomizePubSessionContext) Dispose() {
|
|
|
|
|
ctx.disposeFlag.Store(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
func (ctx *CustomizePubSessionContext) WithOption(modOption func(option *base.AvPacketStreamOption)) {
|
|
|
|
|
ctx.remuxer.WithOption(modOption)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ctx *CustomizePubSessionContext) FeedAudioSpecificConfig(asc []byte) {
|
|
|
|
|
func (ctx *CustomizePubSessionContext) FeedAudioSpecificConfig(asc []byte) error {
|
|
|
|
|
if ctx.disposeFlag.Load() {
|
|
|
|
|
return base.ErrDisposedInStream
|
|
|
|
|
}
|
|
|
|
|
ctx.remuxer.InitWithAvConfig(asc, nil, nil, nil)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ctx *CustomizePubSessionContext) FeedAvPacket(packet base.AvPacket) {
|
|
|
|
|
func (ctx *CustomizePubSessionContext) FeedAvPacket(packet base.AvPacket) error {
|
|
|
|
|
if ctx.disposeFlag.Load() {
|
|
|
|
|
return base.ErrDisposedInStream
|
|
|
|
|
}
|
|
|
|
|
ctx.remuxer.FeedAvPacket(packet)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|