print bitrates

pull/33/head
MPR 10 years ago
parent dc5f46a132
commit c5f7d699a2

@ -62,20 +62,22 @@ class V4L2DeviceSource: public FramedSource
// ---------------------------------
// compute FPS
// ---------------------------------
class Fps
class Stats
{
public:
Fps(const std::string & msg) : m_fps(0), m_fps_sec(0), m_msg(msg) {};
Stats(const std::string & msg) : m_fps(0), m_fps_sec(0), m_size(0), m_msg(msg) {};
public:
int notify(int tv_sec)
int notify(int tv_sec, int framesize)
{
m_fps++;
m_size+=framesize;
if (tv_sec != m_fps_sec)
{
std::cout << m_msg << "tv_sec:" << tv_sec << " fps:" << m_fps <<"\n";
std::cout << m_msg << "tv_sec:" << tv_sec << " fps:" << m_fps << " bandwidth:"<< (m_size/128) << "kbps\n";
m_fps_sec = tv_sec;
m_fps = 0;
m_size = 0;
}
return m_fps;
}
@ -83,6 +85,7 @@ class V4L2DeviceSource: public FramedSource
protected:
int m_fps;
int m_fps_sec;
int m_size;
const std::string m_msg;
};
@ -125,8 +128,8 @@ class V4L2DeviceSource: public FramedSource
int m_fd;
int m_bufferSize;
std::list<Frame*> m_captureQueue;
Fps m_in;
Fps m_out;
Stats m_in;
Stats m_out;
EventTriggerId m_eventTriggerId;
FILE* m_outfile;
std::string m_auxLine;

@ -226,11 +226,10 @@ void V4L2DeviceSource::deliverFrame()
else
{
gettimeofday(&fPresentationTime, NULL);
m_out.notify(fPresentationTime.tv_sec);
Frame * frame = m_captureQueue.front();
m_captureQueue.pop_front();
m_out.notify(fPresentationTime.tv_sec, frame->m_size);
if (frame->m_size > fMaxSize)
{
fFrameSize = fMaxSize;
@ -293,7 +292,7 @@ void V4L2DeviceSource::getNextFrame()
gettimeofday(&tv, NULL);
timeval diff;
timersub(&tv,&ref,&diff);
int fps = m_in.notify(tv.tv_sec);
m_in.notify(tv.tv_sec, frameSize);
if (m_params.m_verbose)
{
printf ("getNextFrame\ttimestamp:%d.%06d\tsize:%d diff:%d ms queue:%d\n", ref.tv_sec, ref.tv_usec, frameSize, (int)(diff.tv_sec*1000+diff.tv_usec/1000), m_captureQueue.size());

Loading…
Cancel
Save