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