本文整理汇总了C++中PacketQueue::Pop方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::Pop方法的具体用法?C++ PacketQueue::Pop怎么用?C++ PacketQueue::Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::Pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mpeg_passthrough
//.........这里部分代码省略.........
if(context.audioDone && context.videoDone)
{
printf("[Copy]Both audio & video done\n");
if(context.audioDone==1 && context.videoDone==1) ret=1;
else ret=0;
accessMutex.unlock();
goto _abt;
}
// Update UI
work->setAudioSize(context.feedAudio);
context.feedVideo=0;
accessMutex.unlock();
ADM_usleep(1000*1000);
}
}
/**************************************************************************************/
/* If we get here, it means output is MPEG_TS */
/* We must use the audio packet Queue */
/**************************************************************************************/
ADM_assert(mux==MUXER_TS);
{
PacketQueue *pq;
uint32_t mx,sample;
pthread_t audioThread;
copy=new EncoderCopy(NULL);
audioQueueMT context;
uint8_t r;
copy->configure(NULL);
pq=new PacketQueue("TS audioQ",5000,2*1024*1024);
memset(&context,0,sizeof(context));
context.audioEncoder=audio;
context.audioTargetSample=target_sample;
context.packetQueue=pq;
// start audio thread
ADM_assert(!pthread_create(&audioThread,NULL,(THRINP)defaultAudioQueueSlave,&context));
// Go!
ADM_usleep(4000);
mx=copy->getNbFrame();
printf("Writing %u frames\n",mx);
for(int frame=0;frame<mx;frame++)
{
while(muxer->needAudio())
{
if(pq->Pop(audiobuffer,&audiolen,&sample))
{
if(audiolen)
{
muxer->writeAudioPacket(audiolen,audiobuffer);
//work->feedAudioFrame(audiolen);
}
}else break;
}
ADM_assert(copy);
bitstream.cleanup(frame);
r=copy->encode ( frame, &bitstream);
if(!r)
{
printf("TS:Frame %u error\n",frame);
GUI_Error_HIG (QT_TR_NOOP("Error while encoding"), NULL);
goto stopit;
}
muxer->writeVideoPacket( &bitstream);
work->setFrame(frame,bitstream.len,bitstream.out_quantizer,mx);
// work->feedFrame(bitstream.len);
if(!work->isAlive())
{
goto stopit;
}
}
ret=1;
stopit:
context.audioAbort=1;
pq->Abort();
// Wait for audio slave to be over
while(!context.audioDone)
{
printf("Waiting Audio thread\n");
ADM_usleep(500000);
}
delete pq;
} // End ts case
/************************************** TS End *********************************/
_abt:
delete work;
muxer->close();
delete muxer;
delete [] buffer;
delete [] audiobuffer;
deleteAudioFilter(audio);
if(copy) delete copy;
return ret;
}
示例2: bitstream
//.........这里部分代码省略.........
goto stopit;
//_____________ Loop _____________________
encoding_gui->setContainer(containerTitle);
if(!videoProcessMode())
encoding_gui->setCodec("Copy");
else
encoding_gui->setCodec(_encode->getDisplayName());
//
UI_purge();
if(bitstream.len)
{
muxer->writeVideoPacket( &bitstream);
frameWrite++;
}
//_____________ Start Audio thread _____________________
if(audio)
{
pq=new PacketQueue("MP4 audioQ",5000,2*1024*1024);
memset(&context,0,sizeof(context));
context.audioEncoder=audio;
context.audioTargetSample=0xFFFF0000; ; //FIXME
context.packetQueue=pq;
// start audio thread
ADM_assert(!pthread_create(&audioThread,NULL,(THRINP)defaultAudioQueueSlave,&context));
ADM_usleep(4000);
}
//_____________GO !___________________
for(int frame=1;frame<total;frame++)
{
while(muxer->needAudio())
{
if(pq->Pop(audioBuffer,&alen,&sample))
{
if(alen)
{
muxer->writeAudioPacket(alen,audioBuffer,sample_got);
totalAudioSize+=alen;
encoding_gui->setAudioSize(totalAudioSize);
sample_got+=sample;
}
}else break;
}
ADM_assert(_encode);
bitstream.cleanup(frameWrite);
if(!prefill || frame+prefill<total)
{
r=_encode->encode ( prefill+frame, &bitstream);
}
else
{
r=_encode->encode ( total-1, &bitstream);
}
if(!r && frame<total-2)
{
printf("MP4:Frame %u error\n",frame);
GUI_Error_HIG (QT_TR_NOOP("Error while encoding"), NULL);
goto stopit;
}
if(!bitstream.len && skipping)
{
printf("Frame skipped (xvid ?)\n");
continue;
}