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()
|
||||
}
|
||||
|
||||
// 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 {
|
||||
hs *httpSender
|
||||
buf []byte
|
||||
|
@ -113,6 +117,7 @@ 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{
|
||||
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 {
|
||||
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 {
|
||||
if s.sendFailed || (((*packet.Packet)(&s.pkt)).PID() == mts.PatPid && len(s.buf) != 0) {
|
||||
err := s.fixAndSend()
|
||||
|
@ -139,11 +147,15 @@ func (s *ausOceanSender) send() error {
|
|||
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() {
|
||||
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 {
|
||||
err := s.repairer.Repair(s.buf)
|
||||
if err != nil {
|
||||
|
@ -154,6 +166,8 @@ func (s *ausOceanSender) fixAndSend() error {
|
|||
|
||||
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() {
|
||||
if s.sendFailed {
|
||||
s.sendFailed = false
|
||||
|
|
Loading…
Reference in New Issue