rename bitrate to bitrate_kbits

pull/213/head
Lysander 2 years ago
parent 332afc1806
commit 7f8f4d1c62

@ -121,12 +121,12 @@ func main() {
switch pullType { switch pullType {
case PullTypeRtmp: case PullTypeRtmp:
rtmpPullSession.UpdateStat(5) rtmpPullSession.UpdateStat(5)
pullBitrate = rtmpPullSession.GetStat().Bitrate pullBitrate = rtmpPullSession.GetStat().BitrateKbits
case PullTypeHttpflv: case PullTypeHttpflv:
httpflvPullSession.UpdateStat(5) httpflvPullSession.UpdateStat(5)
pullBitrate = httpflvPullSession.GetStat().Bitrate pullBitrate = httpflvPullSession.GetStat().BitrateKbits
} }
nazalog.Debugf("stat bitrate. push=%+v, pull=%+v", pushSession.GetStat().Bitrate, pullBitrate) nazalog.Debugf("stat bitrate. push=%+v, pull=%+v", pushSession.GetStat().BitrateKbits, pullBitrate)
} }
}() }()

@ -153,15 +153,15 @@ func (s *BasicSessionStat) UniqueKey() string {
// //
func (s *BasicSessionStat) updateStat(readBytesSum, wroteBytesSum uint64, typ string, intervalSec uint32) { func (s *BasicSessionStat) updateStat(readBytesSum, wroteBytesSum uint64, typ string, intervalSec uint32) {
rDiff := readBytesSum - s.prevConnStat.ReadBytesSum rDiff := readBytesSum - s.prevConnStat.ReadBytesSum
s.stat.ReadBitrate = int(rDiff * 8 / 1024 / uint64(intervalSec)) s.stat.ReadBitrateKbits = int(rDiff * 8 / 1024 / uint64(intervalSec))
wDiff := wroteBytesSum - s.prevConnStat.WroteBytesSum wDiff := wroteBytesSum - s.prevConnStat.WroteBytesSum
s.stat.WriteBitrate = int(wDiff * 8 / 1024 / uint64(intervalSec)) s.stat.WriteBitrateKbits = int(wDiff * 8 / 1024 / uint64(intervalSec))
switch typ { switch typ {
case SessionBaseTypePubStr, SessionBaseTypePullStr: case SessionBaseTypePubStr, SessionBaseTypePullStr:
s.stat.Bitrate = s.stat.ReadBitrate s.stat.BitrateKbits = s.stat.ReadBitrateKbits
case SessionBaseTypeSubStr, SessionBaseTypePushStr: case SessionBaseTypeSubStr, SessionBaseTypePushStr:
s.stat.Bitrate = s.stat.WriteBitrate s.stat.BitrateKbits = s.stat.WriteBitrateKbits
default: default:
nazalog.Errorf("invalid session base type. type=%s", typ) nazalog.Errorf("invalid session base type. type=%s", typ)
} }

@ -51,11 +51,11 @@ type StatSession struct {
RemoteAddr string `json:"remote_addr"` RemoteAddr string `json:"remote_addr"`
ReadBytesSum uint64 `json:"read_bytes_sum"` ReadBytesSum uint64 `json:"read_bytes_sum"`
WroteBytesSum uint64 `json:"wrote_bytes_sum"` WroteBytesSum uint64 `json:"wrote_bytes_sum"`
Bitrate int `json:"bitrate"` BitrateKbits int `json:"bitrate_kbits"`
ReadBitrate int `json:"read_bitrate"` ReadBitrateKbits int `json:"read_bitrate_kbits"`
WriteBitrate int `json:"write_bitrate"` WriteBitrateKbits int `json:"write_bitrate_kbits"`
typ SessionType typ SessionType
} }

@ -154,7 +154,7 @@ type ISessionStat interface {
// //
// 获取session状态 // 获取session状态
// //
// @return 注意,结构体中的`Bitrate`的值由最近一次`func UpdateStat`调用计算决定,其他值为当前最新值 // @return 注意,结构体中的`BitrateKbits`的值由最近一次`func UpdateStat`调用计算决定,其他值为当前最新值
// //
GetStat() StatSession GetStat() StatSession

@ -118,9 +118,9 @@ func (session *ServerCommandSession) UpdateStat(intervalSec uint32) {
currStat := session.conn.GetStat() currStat := session.conn.GetStat()
rDiff := currStat.ReadBytesSum - session.prevConnStat.ReadBytesSum rDiff := currStat.ReadBytesSum - session.prevConnStat.ReadBytesSum
session.stat.Bitrate = int(rDiff * 8 / 1024 / uint64(intervalSec)) session.stat.BitrateKbits = int(rDiff * 8 / 1024 / uint64(intervalSec))
wDiff := currStat.WroteBytesSum - session.prevConnStat.WroteBytesSum wDiff := currStat.WroteBytesSum - session.prevConnStat.WroteBytesSum
session.stat.Bitrate = int(wDiff * 8 / 1024 / uint64(intervalSec)) session.stat.BitrateKbits = int(wDiff * 8 / 1024 / uint64(intervalSec))
session.prevConnStat = currStat session.prevConnStat = currStat
} }

Loading…
Cancel
Save