mirror of https://bitbucket.org/ausocean/av.git
Better field names.
This commit is contained in:
parent
c386f45bbd
commit
076a9c030a
|
@ -132,20 +132,20 @@ func readPacket(s *Session, pkt *packet) error {
|
|||
timestamp := append(s.channelTimestamp, make([]int32, 10)...)
|
||||
|
||||
var pkts []*packet
|
||||
if s.vecChannelsIn == nil {
|
||||
if s.channelsIn == nil {
|
||||
pkts = make([]*packet, n)
|
||||
} else {
|
||||
pkts = append(s.vecChannelsIn[:pkt.channel:pkt.channel], make([]*packet, 10)...)
|
||||
pkts = append(s.channelsIn[:pkt.channel:pkt.channel], make([]*packet, 10)...)
|
||||
}
|
||||
|
||||
s.channelTimestamp = timestamp
|
||||
s.vecChannelsIn = pkts
|
||||
s.channelsIn = pkts
|
||||
|
||||
for i := int(s.channelsAllocatedIn); i < len(s.channelTimestamp); i++ {
|
||||
s.channelTimestamp[i] = 0
|
||||
}
|
||||
for i := int(s.channelsAllocatedIn); i < int(n); i++ {
|
||||
s.vecChannelsIn[i] = nil
|
||||
s.channelsIn[i] = nil
|
||||
}
|
||||
s.channelsAllocatedIn = n
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ func readPacket(s *Session, pkt *packet) error {
|
|||
case size == RTMP_LARGE_HEADER_SIZE:
|
||||
pkt.hasAbsTimestamp = true
|
||||
case size < RTMP_LARGE_HEADER_SIZE:
|
||||
if s.vecChannelsIn[pkt.channel] != nil {
|
||||
*pkt = *(s.vecChannelsIn[pkt.channel])
|
||||
if s.channelsIn[pkt.channel] != nil {
|
||||
*pkt = *(s.channelsIn[pkt.channel])
|
||||
}
|
||||
}
|
||||
size--
|
||||
|
@ -224,13 +224,13 @@ func readPacket(s *Session, pkt *packet) error {
|
|||
pkt.bytesRead += uint32(chunkSize)
|
||||
|
||||
// keep the packet as ref for other packets on this channel
|
||||
if s.vecChannelsIn[pkt.channel] == nil {
|
||||
s.vecChannelsIn[pkt.channel] = &packet{}
|
||||
if s.channelsIn[pkt.channel] == nil {
|
||||
s.channelsIn[pkt.channel] = &packet{}
|
||||
}
|
||||
*(s.vecChannelsIn[pkt.channel]) = *pkt
|
||||
*(s.channelsIn[pkt.channel]) = *pkt
|
||||
|
||||
if extendedTimestamp {
|
||||
s.vecChannelsIn[pkt.channel].timestamp = 0xffffff
|
||||
s.channelsIn[pkt.channel].timestamp = 0xffffff
|
||||
}
|
||||
|
||||
if pkt.bytesRead != pkt.bodySize {
|
||||
|
@ -243,9 +243,9 @@ func readPacket(s *Session, pkt *packet) error {
|
|||
}
|
||||
s.channelTimestamp[pkt.channel] = int32(pkt.timestamp)
|
||||
|
||||
s.vecChannelsIn[pkt.channel].body = nil
|
||||
s.vecChannelsIn[pkt.channel].bytesRead = 0
|
||||
s.vecChannelsIn[pkt.channel].hasAbsTimestamp = false
|
||||
s.channelsIn[pkt.channel].body = nil
|
||||
s.channelsIn[pkt.channel].bytesRead = 0
|
||||
s.channelsIn[pkt.channel].hasAbsTimestamp = false
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -266,20 +266,20 @@ func sendPacket(s *Session, pkt *packet, queue bool) error {
|
|||
n := int(pkt.channel + 10)
|
||||
|
||||
var pkts []*packet
|
||||
if s.vecChannelsOut == nil {
|
||||
if s.channelsOut == nil {
|
||||
pkts = make([]*packet, n)
|
||||
} else {
|
||||
pkts = append(s.vecChannelsOut[:pkt.channel:pkt.channel], make([]*packet, 10)...)
|
||||
pkts = append(s.channelsOut[:pkt.channel:pkt.channel], make([]*packet, 10)...)
|
||||
}
|
||||
s.vecChannelsOut = pkts
|
||||
s.channelsOut = pkts
|
||||
|
||||
for i := int(s.channelsAllocatedOut); i < n; i++ {
|
||||
s.vecChannelsOut[i] = nil
|
||||
s.channelsOut[i] = nil
|
||||
}
|
||||
|
||||
s.channelsAllocatedOut = int32(n)
|
||||
}
|
||||
prevPkt = s.vecChannelsOut[pkt.channel]
|
||||
prevPkt = s.channelsOut[pkt.channel]
|
||||
|
||||
if prevPkt != nil && pkt.headerType != RTMP_PACKET_SIZE_LARGE {
|
||||
// compress a bit by using the prev packet's attributes
|
||||
|
@ -415,6 +415,7 @@ func sendPacket(s *Session, pkt *packet, queue bool) error {
|
|||
if s.deferred != nil {
|
||||
// Prepend the previously deferred packet and write it with the current one.
|
||||
bytes = append(s.deferred, bytes...)
|
||||
s.deferred = nil
|
||||
}
|
||||
err := writeN(s, bytes)
|
||||
if err != nil {
|
||||
|
@ -465,10 +466,10 @@ func sendPacket(s *Session, pkt *packet, queue bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
if s.vecChannelsOut[pkt.channel] == nil {
|
||||
s.vecChannelsOut[pkt.channel] = &packet{}
|
||||
if s.channelsOut[pkt.channel] == nil {
|
||||
s.channelsOut[pkt.channel] = &packet{}
|
||||
}
|
||||
*(s.vecChannelsOut[pkt.channel]) = *pkt
|
||||
*(s.channelsOut[pkt.channel]) = *pkt
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -744,7 +744,7 @@ func handleInvoke(s *Session, body []byte) error {
|
|||
}
|
||||
|
||||
case av_onBWDone:
|
||||
if s.bwCheckCounter == 0 {
|
||||
if s.checkCounter == 0 { // ToDo: why is this always zero?
|
||||
sendCheckBW(s)
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,9 @@ package rtmp
|
|||
// Session holds the state for an RTMP session.
|
||||
type Session struct {
|
||||
url string
|
||||
timeout uint
|
||||
inChunkSize int32
|
||||
outChunkSize int32
|
||||
bwCheckCounter int32
|
||||
checkCounter int32
|
||||
nBytesIn int32
|
||||
nBytesInSent int32
|
||||
streamID int32
|
||||
|
@ -52,8 +51,8 @@ type Session struct {
|
|||
methodCalls []method
|
||||
channelsAllocatedIn int32
|
||||
channelsAllocatedOut int32
|
||||
vecChannelsIn []*packet
|
||||
vecChannelsOut []*packet
|
||||
channelsIn []*packet
|
||||
channelsOut []*packet
|
||||
channelTimestamp []int32
|
||||
audioCodecs float64
|
||||
videoCodecs float64
|
||||
|
|
Loading…
Reference in New Issue