Пример #1
0
void VideoBuffer::pushNewVideoFrame(VideoFrame & frame){
    
    int64_t time = frame.getTimestamp().epochMicroseconds();
    if(microsOneSec==-1) microsOneSec=time;
    framesOneSec++;
    int64_t diff = time-microsOneSec;
    if(diff>=1000000){
        realFps = double(framesOneSec*1000000.)/double(diff);
        framesOneSec = 0;
        microsOneSec = time-(diff-1000000);
    }
    totalFrames++;
    if(size()==0)initTime=frame.getTimestamp();
    //timeMutex.lock();

    
    if (size() >= maxSize) {
        // THIS LINE IS GIVING ME CRASHES SOMETIMES ..... SERIOUS WTF : if i dont see this happen again its fixed
        frames[ofClamp(framePos, 0, size()-1)] = frame; // Here we use the framePos variable to specify where new frames
                                  // should be stored in the video buffer instead of using the vector push_back call.
    }
    else if (size() < maxSize) {
        frames.push_back(frame);
    }
    
    while(size() > maxSize){
        frames.erase(frames.begin()+framePos);
    }
}
Пример #2
0
void VideoBuffer::newVideoFrame(VideoFrame & frame){
	int64_t time = frame.getTimestamp().epochMicroseconds();
	if(microsOneSec==-1) microsOneSec=time;
	framesOneSec++;
	int64_t diff = time-microsOneSec;
	if(diff>=1000000){
		realFps = double(framesOneSec*1000000.)/double(diff);
		framesOneSec = 0;
		microsOneSec = time-(diff-1000000);
	}
    totalFrames++;
    if(size()==0)initTime=frame.getTimestamp();
    //timeMutex.lock();
    frames.push_back(frame);
    while(size()>maxSize){
        frames.erase(frames.begin());
    }
    //timeMutex.unlock();
    newFrameEvent.notify(this,frame);

}
Пример #3
0
void VideoBuffer::pushNewVideoFrameTracer(VideoFrame & frame){
    if(isStopped()){
        return;
    }
    int64_t time = frame.getTimestamp().epochMicroseconds();
    if(microsOneSec==-1) microsOneSec=time;
    framesOneSec++;
    int64_t diff = time-microsOneSec;
    if(diff>=1000000){
        realFps = double(framesOneSec*1000000.)/double(diff);
        framesOneSec = 0;
        microsOneSec = time-(diff-1000000);
    }
    totalFrames++;
    if(size()==0)initTime=frame.getTimestamp();
    //timeMutex.lock();
    
    frames.push_back(frame);
    
    while(size()>maxSize){
        frames.erase(frames.begin());
    }
}