本文整理汇总了C++中PacketQueue::size方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::size方法的具体用法?C++ PacketQueue::size怎么用?C++ PacketQueue::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvbsub_ass_clear
void dvbsub_ass_clear(void)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(ass_mutex);
while(ass_queue.size()) {
ass_data *a = (ass_data *) ass_queue.pop();
if (a) {
avsubtitle_free(&a->sub);
delete a;
}
}
while(!sem_trywait(&ass_sem));
ass_track = NULL;
for(std::map<int,ASS_Track*>::iterator it = ass_map.begin(); it != ass_map.end(); ++it)
ass_free_track(it->second);
ass_map.clear();
if (ass_renderer) {
ass_renderer_done(ass_renderer);
ass_renderer = NULL;
}
if (ass_library) {
ass_library_done(ass_library);
ass_library = NULL;
}
clear_queue();
}
示例2: clear_queue
static void clear_queue()
{
uint8_t* packet;
cDvbSubtitleBitmaps *Bitmaps;
pthread_mutex_lock(&packetMutex);
while(packet_queue.size()) {
packet = packet_queue.pop();
free(packet);
}
while(bitmap_queue.size()) {
Bitmaps = (cDvbSubtitleBitmaps *) bitmap_queue.pop();
delete Bitmaps;
}
pthread_mutex_unlock(&packetMutex);
}
示例3: clear_queue
static void clear_queue()
{
uint8_t* packet;
pthread_mutex_lock(&packetMutex);
while(packet_queue.size()) {
packet = packet_queue.pop();
free(packet);
}
pthread_mutex_unlock(&packetMutex);
}
示例4: test_reliability_system
void test_reliability_system()
{
printf( "-----------------------------------------------------\n" );
printf( "test reliability system\n" );
printf( "-----------------------------------------------------\n" );
const int MaximumSequence = 255;
printf( "check bit index for sequence\n" );
check( ReliabilitySystem::bit_index_for_sequence( 99, 100, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 90, 100, MaximumSequence ) == 9 );
check( ReliabilitySystem::bit_index_for_sequence( 0, 1, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 255, 0, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 255, 1, MaximumSequence ) == 1 );
check( ReliabilitySystem::bit_index_for_sequence( 254, 1, MaximumSequence ) == 2 );
check( ReliabilitySystem::bit_index_for_sequence( 254, 2, MaximumSequence ) == 3 );
printf( "check generate ack bits\n");
PacketQueue packetQueue;
for ( int i = 0; i < 32; ++i )
{
PacketData data;
data.sequence = i;
packetQueue.insert_sorted( data, MaximumSequence );
packetQueue.verify_sorted( MaximumSequence );
}
check( ReliabilitySystem::generate_ack_bits( 32, packetQueue, MaximumSequence ) == 0xFFFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 31, packetQueue, MaximumSequence ) == 0x7FFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 33, packetQueue, MaximumSequence ) == 0xFFFFFFFE );
check( ReliabilitySystem::generate_ack_bits( 16, packetQueue, MaximumSequence ) == 0x0000FFFF );
check( ReliabilitySystem::generate_ack_bits( 48, packetQueue, MaximumSequence ) == 0xFFFF0000 );
printf( "check generate ack bits with wrap\n");
packetQueue.clear();
for ( int i = 255 - 31; i <= 255; ++i )
{
PacketData data;
data.sequence = i;
packetQueue.insert_sorted( data, MaximumSequence );
packetQueue.verify_sorted( MaximumSequence );
}
check( packetQueue.size() == 32 );
check( ReliabilitySystem::generate_ack_bits( 0, packetQueue, MaximumSequence ) == 0xFFFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 255, packetQueue, MaximumSequence ) == 0x7FFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 1, packetQueue, MaximumSequence ) == 0xFFFFFFFE );
check( ReliabilitySystem::generate_ack_bits( 240, packetQueue, MaximumSequence ) == 0x0000FFFF );
check( ReliabilitySystem::generate_ack_bits( 16, packetQueue, MaximumSequence ) == 0xFFFF0000 );
printf( "check process ack (1)\n" );
{
PacketQueue pendingAckQueue;
for ( int i = 0; i < 33; ++i )
{
PacketData data;
data.sequence = i;
data.time = 0.0f;
pendingAckQueue.insert_sorted( data, MaximumSequence );
pendingAckQueue.verify_sorted( MaximumSequence );
}
PacketQueue ackedQueue;
std::vector<unsigned int> acks;
float rtt = 0.0f;
unsigned int acked_packets = 0;
ReliabilitySystem::process_ack( 32, 0xFFFFFFFF, pendingAckQueue, ackedQueue, acks, acked_packets, rtt, MaximumSequence );
check( acks.size() == 33 );
check( acked_packets == 33 );
check( ackedQueue.size() == 33 );
check( pendingAckQueue.size() == 0 );
ackedQueue.verify_sorted( MaximumSequence );
for ( unsigned int i = 0; i < acks.size(); ++i )
check( acks[i] == i );
unsigned int i = 0;
for ( PacketQueue::iterator itor = ackedQueue.begin(); itor != ackedQueue.end(); ++itor, ++i )
check( itor->sequence == i );
}
printf( "check process ack (2)\n" );
{
PacketQueue pendingAckQueue;
for ( int i = 0; i < 33; ++i )
{
PacketData data;
data.sequence = i;
data.time = 0.0f;
pendingAckQueue.insert_sorted( data, MaximumSequence );
pendingAckQueue.verify_sorted( MaximumSequence );
}
PacketQueue ackedQueue;
std::vector<unsigned int> acks;
float rtt = 0.0f;
unsigned int acked_packets = 0;
ReliabilitySystem::process_ack( 32, 0x0000FFFF, pendingAckQueue, ackedQueue, acks, acked_packets, rtt, MaximumSequence );
check( acks.size() == 17 );
check( acked_packets == 17 );
check( ackedQueue.size() == 17 );
check( pendingAckQueue.size() == 33 - 17 );
ackedQueue.verify_sorted( MaximumSequence );
unsigned int i = 0;
for ( PacketQueue::iterator itor = pendingAckQueue.begin(); itor != pendingAckQueue.end(); ++itor, ++i )
check( itor->sequence == i );
//.........这里部分代码省略.........
示例5: dvbsub_thread
static void* dvbsub_thread(void* /*arg*/)
{
struct timespec restartWait;
struct timeval now;
sub_debug.print(Debug::VERBOSE, "%s started\n", __FUNCTION__);
if (!dvbSubtitleConverter)
dvbSubtitleConverter = new cDvbSubtitleConverter;
int timeout = 1000000;
while(dvbsub_running)
{
uint8_t* packet;
int64_t pts;
int dataoffset;
int packlen;
gettimeofday(&now, NULL);
int ret = 0;
now.tv_usec += (timeout == 0) ? 1000000 : timeout; // add the timeout
while (now.tv_usec >= 1000000)
{
// take care of an overflow
now.tv_sec++;
now.tv_usec -= 1000000;
}
restartWait.tv_sec = now.tv_sec; // seconds
restartWait.tv_nsec = now.tv_usec * 1000; // nano seconds
pthread_mutex_lock( &packetMutex );
ret = pthread_cond_timedwait( &packetCond, &packetMutex, &restartWait );
pthread_mutex_unlock( &packetMutex );
timeout = dvbSubtitleConverter->Action();
if(packet_queue.size() == 0) {
continue;
}
#if 1
sub_debug.print(Debug::VERBOSE, "PES: Wakeup, queue size %d\n\n", packet_queue.size());
#endif
if(dvbsub_stopped /*dvbsub_paused*/)
{
clear_queue();
continue;
}
pthread_mutex_lock(&packetMutex);
packet = packet_queue.pop();
pthread_mutex_unlock(&packetMutex);
if (!packet) {
sub_debug.print(Debug::VERBOSE, "Error no packet found\n");
continue;
}
packlen = (packet[4] << 8 | packet[5]) + 6;
pts = get_pts(packet);
dataoffset = packet[8] + 8 + 1;
if (packet[dataoffset] != 0x20)
{
#if 1
sub_debug.print(Debug::VERBOSE, "Not a dvb subtitle packet, discard it (len %d)\n", packlen);
for(int i = 0; i < packlen; i++)
printf("%02X ", packet[i]);
printf("\n");
#endif
goto next_round;
}
#if 1
sub_debug.print(Debug::VERBOSE, "PES packet: len %d data len %d PTS=%Ld (%02d:%02d:%02d.%d) diff %lld\n", packlen, packlen - (dataoffset + 2), pts, (int)(pts/324000000), (int)((pts/5400000)%60), (int)((pts/90000)%60), (int)(pts%90000), get_pts_stc_delta(pts));
#endif
if (packlen <= dataoffset + 3)
{
sub_debug.print(Debug::INFO, "Packet too short, discard\n");
goto next_round;
}
if (packet[dataoffset + 2] == 0x0f)
{
dvbSubtitleConverter->Convert(&packet[dataoffset + 2], packlen - (dataoffset + 2), pts);
}
else
{
sub_debug.print(Debug::INFO, "End_of_PES is missing\n");
}
timeout = dvbSubtitleConverter->Action();
next_round:
free(packet);
}
delete dvbSubtitleConverter;
//.........这里部分代码省略.........