Add support tapo source
This commit is contained in:
@@ -2,6 +2,7 @@ package streamer
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
@@ -50,3 +51,31 @@ func Contains(medias []*Media, media *Media, codec *Codec) bool {
|
||||
}
|
||||
return ok1 && ok2
|
||||
}
|
||||
|
||||
type Probe struct {
|
||||
deadline time.Time
|
||||
items map[interface{}]struct{}
|
||||
}
|
||||
|
||||
func NewProbe(enable bool) *Probe {
|
||||
if enable {
|
||||
return &Probe{
|
||||
deadline: time.Now().Add(time.Second * 3),
|
||||
items: map[interface{}]struct{}{},
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Active return true if probe enabled and not finish
|
||||
func (p *Probe) Active() bool {
|
||||
return len(p.items) < 2 && time.Now().Before(p.deadline)
|
||||
}
|
||||
|
||||
// Append safe to run if Probe is nil
|
||||
func (p *Probe) Append(v interface{}) {
|
||||
if p != nil {
|
||||
p.items[v] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,13 @@ func NewTrack(codec *Codec, direction string) *Track {
|
||||
return &Track{Codec: codec, Direction: direction, sinkMu: new(sync.RWMutex)}
|
||||
}
|
||||
|
||||
func NewTrack2(media *Media, codec *Codec) *Track {
|
||||
if codec == nil {
|
||||
codec = media.Codecs[0]
|
||||
}
|
||||
return &Track{Codec: codec, Direction: media.Direction, sinkMu: new(sync.RWMutex)}
|
||||
}
|
||||
|
||||
func (t *Track) String() string {
|
||||
s := t.Codec.String()
|
||||
if t.sinkMu.TryRLock() {
|
||||
|
||||
Reference in New Issue
Block a user