mirror of https://bitbucket.org/ausocean/av.git
stream/mts: ausOceanSender => mtsSender
This commit is contained in:
parent
4044368837
commit
31d36577b1
|
@ -211,7 +211,7 @@ func (r *Revid) reset(config Config) error {
|
|||
case Http:
|
||||
switch r.Config().Packetization {
|
||||
case Mpegts:
|
||||
r.destination = append(r.destination, newAusOceanSender(r.ns, r.config.Logger.Log))
|
||||
r.destination = append(r.destination, newMtsSender(r.ns, r.config.Logger.Log))
|
||||
default:
|
||||
r.destination = append(r.destination, newHttpSender(r.ns, r.config.Logger.Log))
|
||||
}
|
||||
|
|
|
@ -105,11 +105,11 @@ func (s *fileSender) close() error {
|
|||
return s.file.Close()
|
||||
}
|
||||
|
||||
// ausOceanSender provides http sending capability specifically for use with
|
||||
// mtsSender provides http sending capability specifically for use with
|
||||
// mpegts packetization. It handles the construction of appropriately lengthed
|
||||
// clips based on PSI. It also fixes accounts for discontinuities by setting
|
||||
// the discontinuity indicator for the first packet of a clip.
|
||||
type ausOceanSender struct {
|
||||
type mtsSender struct {
|
||||
hs *httpSender
|
||||
buf []byte
|
||||
pkt [mts.PacketSize]byte
|
||||
|
@ -117,23 +117,23 @@ type ausOceanSender struct {
|
|||
repairer *mts.DiscontinuityRepairer
|
||||
}
|
||||
|
||||
// newAusOceanSender returns a new ausOceanSender.
|
||||
func newAusOceanSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{})) *ausOceanSender {
|
||||
return &ausOceanSender{
|
||||
// newmtsSender returns a new mtsSender.
|
||||
func newMtsSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{})) *mtsSender {
|
||||
return &mtsSender{
|
||||
hs: newHttpSender(ns, log),
|
||||
repairer: mts.NewDiscontinuityRepairer(),
|
||||
}
|
||||
}
|
||||
|
||||
// load takes a *ring.Chunk and extracts bytes copying into s.pkt for use by the sender.
|
||||
func (s *ausOceanSender) load(c *ring.Chunk) error {
|
||||
func (s *mtsSender) load(c *ring.Chunk) error {
|
||||
copy(s.pkt[:], c.Bytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
// send checks the most recently loaded packet and if it is a PAT then the clip
|
||||
// in s.buf is sent, otherwise the packet is added to s.buf.
|
||||
func (s *ausOceanSender) send() error {
|
||||
func (s *mtsSender) send() error {
|
||||
if s.sendFailed || (((*packet.Packet)(&s.pkt)).PID() == mts.PatPid && len(s.buf) != 0) {
|
||||
err := s.fixAndSend()
|
||||
if err != nil {
|
||||
|
@ -149,14 +149,14 @@ func (s *ausOceanSender) send() error {
|
|||
|
||||
// failed sets the s.sendFailed flag to true, and let's the discontinuity
|
||||
// repairer know that there has been a failed send.
|
||||
func (s *ausOceanSender) failed() {
|
||||
func (s *mtsSender) failed() {
|
||||
s.sendFailed = true
|
||||
s.repairer.Failed()
|
||||
}
|
||||
|
||||
// fixAndSend uses the discontinuity repairer to ensure there is not a
|
||||
// discontinuity, and if so sets the discontinuity indicator of the PAT packet.
|
||||
func (s *ausOceanSender) fixAndSend() error {
|
||||
func (s *mtsSender) fixAndSend() error {
|
||||
err := s.repairer.Repair(s.buf)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -164,11 +164,11 @@ func (s *ausOceanSender) fixAndSend() error {
|
|||
return s.hs.httpSend(s.buf)
|
||||
}
|
||||
|
||||
func (s *ausOceanSender) close() error { return nil }
|
||||
func (s *mtsSender) close() error { return nil }
|
||||
|
||||
// release will set the s.sendFailed flag to fals and clear the buffer if
|
||||
// the previous send was a fail.
|
||||
func (s *ausOceanSender) release() {
|
||||
func (s *mtsSender) release() {
|
||||
if s.sendFailed {
|
||||
s.sendFailed = false
|
||||
s.buf = s.buf[:0]
|
||||
|
|
Loading…
Reference in New Issue