mirror of https://bitbucket.org/ausocean/av.git
revid: improved some naming
This commit is contained in:
parent
7c724c9fc3
commit
8cc7f6e500
|
@ -189,30 +189,30 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer, flvEnc func
|
||||||
// We will go through our outputs and create the corresponding senders to add
|
// We will go through our outputs and create the corresponding senders to add
|
||||||
// to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
|
// to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
|
||||||
// output requires FLV encoding.
|
// output requires FLV encoding.
|
||||||
var sender io.Writer
|
var w io.Writer
|
||||||
for _, out := range r.config.Outputs {
|
for _, out := range r.config.Outputs {
|
||||||
switch out {
|
switch out {
|
||||||
case Http:
|
case Http:
|
||||||
sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil)
|
w = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil)
|
||||||
mtsSenders = append(mtsSenders, sender)
|
mtsSenders = append(mtsSenders, w)
|
||||||
case Rtp:
|
case Rtp:
|
||||||
sender, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
|
w, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
|
r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
|
||||||
}
|
}
|
||||||
mtsSenders = append(mtsSenders, sender)
|
mtsSenders = append(mtsSenders, w)
|
||||||
case File:
|
case File:
|
||||||
sender, err := newFileSender(r.config.OutputPath)
|
w, err := newFileSender(r.config.OutputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
mtsSenders = append(mtsSenders, sender)
|
mtsSenders = append(mtsSenders, w)
|
||||||
case Rtmp:
|
case Rtmp:
|
||||||
sender, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
|
w, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
|
r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
|
||||||
}
|
}
|
||||||
flvSenders = append(flvSenders, sender)
|
flvSenders = append(flvSenders, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
|
||||||
ms = e.(*tstFlvEncoder).dst
|
ms = e.(*tstFlvEncoder).dst
|
||||||
}
|
}
|
||||||
|
|
||||||
senders := ms.(*multiSender).senders
|
senders := ms.(*multiSender).dst
|
||||||
got = len(senders)
|
got = len(senders)
|
||||||
want = len(test.encoders[idx].destinations)
|
want = len(test.encoders[idx].destinations)
|
||||||
if got != want {
|
if got != want {
|
||||||
|
|
|
@ -59,14 +59,14 @@ type Log func(level int8, message string, params ...interface{})
|
||||||
// multiSender implements io.Writer. It provides the capacity to send to multiple
|
// multiSender implements io.Writer. It provides the capacity to send to multiple
|
||||||
// senders from a single Write call.
|
// senders from a single Write call.
|
||||||
type multiSender struct {
|
type multiSender struct {
|
||||||
senders []io.Writer
|
dst []io.Writer
|
||||||
log Log
|
log Log
|
||||||
}
|
}
|
||||||
|
|
||||||
// newMultiSender returns a pointer to a new multiSender.
|
// newMultiSender returns a pointer to a new multiSender.
|
||||||
func newMultiSender(senders []io.Writer, log Log) *multiSender {
|
func newMultiSender(senders []io.Writer, log Log) *multiSender {
|
||||||
return &multiSender{
|
return &multiSender{
|
||||||
senders: senders,
|
dst: senders,
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,13 +74,13 @@ func newMultiSender(senders []io.Writer, log Log) *multiSender {
|
||||||
// Write implements io.Writer. This will call load (with the passed slice), send
|
// Write implements io.Writer. This will call load (with the passed slice), send
|
||||||
// and release on all senders of multiSender.
|
// and release on all senders of multiSender.
|
||||||
func (s *multiSender) Write(d []byte) (int, error) {
|
func (s *multiSender) Write(d []byte) (int, error) {
|
||||||
for i, sender := range s.senders {
|
for i, sender := range s.dst {
|
||||||
_, err := sender.Write(d)
|
_, err := sender.Write(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(logger.Warning, pkg+"send failed", "sender", i, "error", err)
|
s.log(logger.Warning, pkg+"send failed", "sender", i, "error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, sender := range s.senders {
|
for _, sender := range s.dst {
|
||||||
s, ok := sender.(loadSender)
|
s, ok := sender.(loadSender)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("sender is not a loadSender")
|
panic("sender is not a loadSender")
|
||||||
|
|
|
@ -335,7 +335,7 @@ func TestMultiSenderWrite(t *testing.T) {
|
||||||
|
|
||||||
// Check that the senders got the data correctly from the writes.
|
// Check that the senders got the data correctly from the writes.
|
||||||
for i := byte(0); i < noOfWrites; i++ {
|
for i := byte(0); i < noOfWrites; i++ {
|
||||||
for j, dest := range ms.senders {
|
for j, dest := range ms.dst {
|
||||||
got := dest.(*dummyLoadSender).buf[i][0]
|
got := dest.(*dummyLoadSender).buf[i][0]
|
||||||
if got != i {
|
if got != i {
|
||||||
t.Errorf("Did not get expected result for sender: %v. \nGot: %v\nWant: %v\n", j, got, i)
|
t.Errorf("Did not get expected result for sender: %v. \nGot: %v\nWant: %v\n", j, got, i)
|
||||||
|
|
Loading…
Reference in New Issue