mirror of https://bitbucket.org/ausocean/av.git
revid/senders.go: commenting of ausOceanSender
This commit is contained in:
parent
6964ac513e
commit
3aa94887eb
|
@ -105,6 +105,10 @@ func (s *fileSender) close() error {
|
||||||
return s.file.Close()
|
return s.file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ausOceanSender 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 ausOceanSender struct {
|
||||||
hs *httpSender
|
hs *httpSender
|
||||||
buf []byte
|
buf []byte
|
||||||
|
@ -113,6 +117,7 @@ type ausOceanSender struct {
|
||||||
repairer *mts.DiscontinuityRepairer
|
repairer *mts.DiscontinuityRepairer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newAusOceanSender returns a new ausOceanSender.
|
||||||
func newAusOceanSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{})) *ausOceanSender {
|
func newAusOceanSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{})) *ausOceanSender {
|
||||||
return &ausOceanSender{
|
return &ausOceanSender{
|
||||||
hs: newHttpSender(ns, log),
|
hs: newHttpSender(ns, log),
|
||||||
|
@ -120,11 +125,14 @@ func newAusOceanSender(ns *netsender.Sender, log func(lvl int8, msg string, args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 *ausOceanSender) load(c *ring.Chunk) error {
|
||||||
copy(s.pkt[:], c.Bytes())
|
copy(s.pkt[:], c.Bytes())
|
||||||
return nil
|
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 *ausOceanSender) send() error {
|
||||||
if s.sendFailed || (((*packet.Packet)(&s.pkt)).PID() == mts.PatPid && len(s.buf) != 0) {
|
if s.sendFailed || (((*packet.Packet)(&s.pkt)).PID() == mts.PatPid && len(s.buf) != 0) {
|
||||||
err := s.fixAndSend()
|
err := s.fixAndSend()
|
||||||
|
@ -139,11 +147,15 @@ func (s *ausOceanSender) send() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 *ausOceanSender) failed() {
|
||||||
s.sendFailed = true
|
s.sendFailed = true
|
||||||
s.repairer.Failed()
|
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 *ausOceanSender) fixAndSend() error {
|
||||||
err := s.repairer.Repair(s.buf)
|
err := s.repairer.Repair(s.buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -154,6 +166,8 @@ func (s *ausOceanSender) fixAndSend() error {
|
||||||
|
|
||||||
func (s *ausOceanSender) close() error { return nil }
|
func (s *ausOceanSender) 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 *ausOceanSender) release() {
|
||||||
if s.sendFailed {
|
if s.sendFailed {
|
||||||
s.sendFailed = false
|
s.sendFailed = false
|
||||||
|
|
Loading…
Reference in New Issue