1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "decodebufmodel.hpp"
#include <stdlib.h>
using std::deque;
/******************************************************************
* Remove entries from FIFO buffer list, if their DTS is less than
* actual SCR. These packet data have been already decoded and have
* been removed from the system target decoder's elementary stream
* buffer.
*****************************************************************/
void DecodeBufModel::Cleaned(clockticks SCR)
{
while ( bufstate.size() != 0 && bufstate.front().DTS < SCR)
{
bufstate.pop_front();
}
}
/******************************************************************
* Return the SCR when there will next be some change in the
* buffer.
* If the buffer is empty return a zero timestamp.
*****************************************************************/
clockticks DecodeBufModel::NextChange()
{
if( bufstate.size() == 0 )
return static_cast<clockticks>(0);
else
return bufstate.front().DTS;
}
/******************************************************************
*
* Remove all entries from FIFO buffer list.
*
*****************************************************************/
void DecodeBufModel::Flushed ()
{
bufstate.clear();
}
/******************************************************************
DecodeBufModel::Space
returns free space in the buffer
******************************************************************/
unsigned int DecodeBufModel::Space ()
{
unsigned int used_bytes = 0;
for( std::deque<DecodeBufEntry>::iterator i = bufstate.begin();
i < bufstate.end();
++i )
{
used_bytes += i->size;
}
return (buffer_size - used_bytes);
}
/******************************************************************
Queue_Buffer
adds entry into the buffer FIFO queue
******************************************************************/
void DecodeBufModel::Queued (unsigned int bytes, clockticks TS)
{
DecodeBufEntry entry;
entry.size = bytes;
entry.DTS = TS;
bufstate.push_back( entry );
}
|