mirror of https://bitbucket.org/ausocean/av.git
revid: revid now has it's own rtpSender seperate from the loadSender slice used for multiple outputs, therefore, we can now bypass the ringbuffer in this case with a check if the rtpSender exists in the packer write method
This commit is contained in:
parent
ebccfa1a54
commit
ccd4c32ff6
|
@ -118,6 +118,9 @@ type Revid struct {
|
|||
// destination is the target endpoint.
|
||||
destination []loadSender
|
||||
|
||||
// rtpSender
|
||||
rtpSndr *rtpSender
|
||||
|
||||
// bitrate hold the last send bitrate calculation result.
|
||||
bitrate int
|
||||
|
||||
|
@ -147,6 +150,13 @@ func (p *packer) Write(frame []byte) (int, error) {
|
|||
return len(frame), nil
|
||||
}
|
||||
n, err := p.owner.buffer.Write(frame)
|
||||
// If we have an rtp sender bypass and give straight to sender
|
||||
if p.owner.rtpSndr != nil {
|
||||
err = p.owner.rtpSndr.send(frame)
|
||||
if err != nil {
|
||||
p.owner.config.Logger.Log(smartlogger.Error, pkg+"rtp send failed with error", "error", err.Error())
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err == ring.ErrDropped {
|
||||
p.owner.config.Logger.Log(smartlogger.Warning, pkg+"dropped frame", "frame size", len(frame))
|
||||
|
@ -213,7 +223,7 @@ func (r *Revid) reset(config Config) error {
|
|||
}
|
||||
|
||||
n := 1
|
||||
if r.config.Output2 != 0 {
|
||||
if r.config.Output2 != 0 && r.config.Output2 != Rtp {
|
||||
n = 2
|
||||
}
|
||||
r.destination = make([]loadSender, n)
|
||||
|
@ -247,11 +257,10 @@ func (r *Revid) reset(config Config) error {
|
|||
}
|
||||
r.destination[outNo] = s
|
||||
case Rtp:
|
||||
s, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
|
||||
r.rtpSndr, err = newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.destination[outNo] = s
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -388,9 +388,17 @@ func (s *rtpSender) load(c *ring.Chunk) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *rtpSender) send() error {
|
||||
_, err := s.chunk.WriteTo(s.encoder)
|
||||
return err
|
||||
func (s *rtpSender) send(d []byte) error {
|
||||
var err error
|
||||
if d != nil {
|
||||
_, err = s.encoder.Write(d)
|
||||
} else {
|
||||
_, err = s.chunk.WriteTo(s.encoder)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *rtpSender) release() {
|
||||
|
|
Loading…
Reference in New Issue