nginx-mod-rtmp/ngx_rtmp_bandwidth.c

27 lines
589 B
C
Raw Normal View History

2013-11-03 20:11:37 +01:00
2012-05-07 13:41:03 +02:00
/*
2013-11-03 20:11:37 +01:00
* Copyright (C) Roman Arutyunyan
2012-05-07 13:41:03 +02:00
*/
#include <ngx_config.h>
#include <ngx_core.h>
2012-05-07 13:41:03 +02:00
#include "ngx_rtmp_bandwidth.h"
2013-11-30 08:21:53 +01:00
void
2012-05-07 13:41:03 +02:00
ngx_rtmp_update_bandwidth(ngx_rtmp_bandwidth_t *bw, uint32_t bytes)
{
if (ngx_cached_time->sec > bw->intl_end) {
2013-11-30 08:21:53 +01:00
bw->bandwidth = ngx_cached_time->sec >
2012-05-07 13:41:03 +02:00
bw->intl_end + NGX_RTMP_BANDWIDTH_INTERVAL
? 0
: bw->intl_bytes / NGX_RTMP_BANDWIDTH_INTERVAL;
bw->intl_bytes = 0;
bw->intl_end = ngx_cached_time->sec + NGX_RTMP_BANDWIDTH_INTERVAL;
}
bw->bytes += bytes;
bw->intl_bytes += bytes;
}