mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix track rtcp & paused.
This commit is contained in:
parent
fcf6822833
commit
3f375c037f
@ -33,33 +33,31 @@ type Track struct {
|
|||||||
videoChange func(string) (bool, error)
|
videoChange func(string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type option func(*Track)
|
type trackOption func(*Track)
|
||||||
|
|
||||||
func WithVideoAuto(auto bool) option {
|
func WithVideoAuto(auto bool) trackOption {
|
||||||
return func(t *Track) {
|
return func(t *Track) {
|
||||||
t.videoAuto = auto
|
t.videoAuto = auto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithRtcpChan(rtcp chan []rtcp.Packet) option {
|
func WithRtcpChan(rtcp chan []rtcp.Packet) trackOption {
|
||||||
return func(t *Track) {
|
return func(t *Track) {
|
||||||
t.rtcpCh = rtcp
|
t.rtcpCh = rtcp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTrack(logger zerolog.Logger, codec codec.RTPCodec, connection *webrtc.PeerConnection, opts ...option) (*Track, error) {
|
func NewTrack(logger zerolog.Logger, codec codec.RTPCodec, connection *webrtc.PeerConnection, opts ...trackOption) (*Track, error) {
|
||||||
id := codec.Type.String()
|
id := codec.Type.String()
|
||||||
track, err := webrtc.NewTrackLocalStaticSample(codec.Capability, id, "stream")
|
track, err := webrtc.NewTrackLocalStaticSample(codec.Capability, id, "stream")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger = logger.With().Str("id", id).Logger()
|
|
||||||
|
|
||||||
t := &Track{
|
t := &Track{
|
||||||
logger: logger,
|
logger: logger.With().Str("id", id).Logger(),
|
||||||
track: track,
|
track: track,
|
||||||
rtcpCh: make(chan []rtcp.Packet),
|
rtcpCh: nil,
|
||||||
sample: make(chan types.Sample),
|
sample: make(chan types.Sample),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +153,9 @@ func (t *Track) RemoveStream() {
|
|||||||
t.streamMu.Lock()
|
t.streamMu.Lock()
|
||||||
defer t.streamMu.Unlock()
|
defer t.streamMu.Unlock()
|
||||||
|
|
||||||
// if there is no stream, or paused, do nothing
|
// if there is no stream, or paused we don't need to remove the listener
|
||||||
if t.stream == nil || t.paused {
|
if t.stream == nil || t.paused {
|
||||||
|
t.stream = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user