src/app/dvb/streamer/plugin/stream.cpp
const int Stream::getRate(struct klkstat_s& stat) const
{
    struct timeval current;
    if (gettimeofday(&current, NULL) < 0)
    {
        throw Exception(__FILE__, __LINE__,
                        "Error %d in gettimeofday(): %s",
                        errno, strerror(errno));
    }

    // calculate rate
    struct timeval diff;
    timersub(&current, &stat.lastupdate, &diff);

    int rate = 0;
    if (stat.count != 0)
    {
        if (diff.tv_sec <= 0 && diff.tv_usec <= 0)
        {
            // cannot calculate rate
            throw Exception(__FILE__, __LINE__, "Incorrect time diff");
        }

        double time = diff.tv_sec + diff.tv_usec * 1.0e-6;
        BOOST_ASSERT(time > 0);
        rate = static_cast<int>(stat.count/time);
    }
    // clear rate info
    stat.count = 0;
    stat.lastupdate = current;

    return rate;
}
// Retrives rate in bytes per second from stat info and
// prepare (clear) the stat info for next collection
Retrives rate in bytes per second from stat info and
prepare (clear) the stat info for next collection
Retrives rate in bytes per second from stat info and prepare ( clear ) the stat info for next collection
const int Stream::getRate(struct klkstat_s& stat) const
{
    struct timeval current;
    if (gettimeofday(&current, NULL) < 0)
    {
        throw Exception(__FILE__, __LINE__,
                        "Error %d in gettimeofday(): %s",
                        errno, strerror(errno));
    }
    struct timeval diff;
    timersub(&current, &stat.lastupdate, &diff);
    int rate = 0;
    if (stat.count != 0)
    {
        if (diff.tv_sec <= 0 && diff.tv_usec <= 0)
        {
            throw Exception(__FILE__, __LINE__, "Incorrect time diff");
        }
        double time = diff.tv_sec + diff.tv_usec * 1.0e-6;
        BOOST_ASSERT(time > 0);
        rate = static_cast<int>(stat.count/time);
    }
    stat.count = 0;
    stat.lastupdate = current;
    return rate;
}
const int Stream :: getRate ( struct klkstat_s & stat ) const { struct timeval current ; if ( gettimeofday ( & current , NULL ) < 0 ) { throw Exception ( __FILE__ , __LINE__ , " " , errno , strerror ( errno ) ) ; } struct timeval diff ; timersub ( & current , & stat . lastupdate , & diff ) ; int rate = 0 ; if ( stat . count != 0 ) { if ( diff . tv_sec <= 0 && diff . tv_usec <= 0 ) { throw Exception ( __FILE__ , __LINE__ , " " ) ; } double time = diff . tv_sec + diff . tv_usec * 1.0e-6 ; BOOST_ASSERT ( time > 0 ) ; rate = static_cast < int > ( stat . count / time ) ; } stat . count = 0 ; stat . lastupdate = current ; return rate ; }
Retrives rate in bytes per second from stat info and
prepare (clear) the stat info for next collection
Retrives rate in bytes per second from stat info and prepare ( clear ) the stat info for next collection
// calculate rate // cannot calculate rate // clear rate info