本文整理汇总了C++中PacketQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::push方法的具体用法?C++ PacketQueue::push怎么用?C++ PacketQueue::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::push方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvbsub_ass_write
void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid)
{
if (ass_reader_running) {
ass_queue.push((uint8_t *)new ass_data(c, sub, pid));
sem_post(&ass_sem);
memset(sub, 0, sizeof(AVSubtitle));
} else
avsubtitle_free(sub);
}
示例2: dvbsub_write
void dvbsub_write(AVSubtitle *sub, int64_t pts)
{
pthread_mutex_lock(&packetMutex);
cDvbSubtitleBitmaps *Bitmaps = new cDvbSubtitleBitmaps(pts);
Bitmaps->SetSub(sub); // Note: this will copy sub, including all references. DON'T call avsubtitle_free() from the caller.
memset(sub, 0, sizeof(AVSubtitle));
bitmap_queue.push((unsigned char *) Bitmaps);
pthread_cond_broadcast(&packetCond);
pthread_mutex_unlock(&packetMutex);
}
示例3: reader_thread
//.........这里部分代码省略.........
switch (poll(pfds, 2, -1)) {
case 0:
case -1:
if (pfds[0].revents & POLLIN)
while (0 > read(pfds[0].fd, _tmp, sizeof(tmp)));
continue;
default:
if (pfds[0].revents & POLLIN)
while (0 > read(pfds[0].fd, _tmp, sizeof(tmp)));
if (!(pfds[1].revents & POLLIN))
continue;
}
len = dmx->Read(tmp, 6, 0);
if(len <= 0)
continue;
if(!memcmp(tmp, "\x00\x00\x01\xbe", 4)) { // padding stream
packlen = getbits(tmp, 4*8, 16) + 6;
count = 6;
buf = (uint8_t*) malloc(packlen);
// actually, we're doing slightly too much here ...
memmove(buf, tmp, 6);
/* read rest of the packet */
while((count < packlen) && !dvbsub_stopped) {
len = dmx->Read(buf+count, packlen-count, 1000);
if (len < 0) {
break;
} else {
count += len;
}
}
free(buf);
buf = NULL;
continue;
}
if(memcmp(tmp, "\x00\x00\x01\xbd", 4)) {
if (!bad_startcode) {
sub_debug.print(Debug::VERBOSE, "[subtitles] bad start code: %02x%02x%02x%02x\n", tmp[0], tmp[1], tmp[2], tmp[3]);
bad_startcode = true;
}
continue;
}
bad_startcode = false;
count = 6;
packlen = getbits(tmp, 4*8, 16) + 6;
buf = (uint8_t*) malloc(packlen);
memmove(buf, tmp, 6);
/* read rest of the packet */
while((count < packlen) && !dvbsub_stopped) {
len = dmx->Read(buf+count, packlen-count, 1000);
if (len < 0) {
break;
} else {
count += len;
}
}
#if 0
for(int i = 6; i < packlen - 4; i++) {
if(!memcmp(&buf[i], "\x00\x00\x01\xbd", 4)) {
int plen = getbits(&buf[i], 4*8, 16) + 6;
sub_debug.print(Debug::VERBOSE, "[subtitles] ******************* PES header at %d ?! *******************\n", i);
sub_debug.print(Debug::VERBOSE, "[subtitles] start code: %02x%02x%02x%02x len %d\n", buf[i+0], buf[i+1], buf[i+2], buf[i+3], plen);
free(buf);
continue;
}
}
#endif
if(!dvbsub_stopped /*!dvbsub_paused*/) {
sub_debug.print(Debug::VERBOSE, "[subtitles] *** new packet, len %d buf 0x%x pts-stc diff %lld ***\n", count, buf, get_pts_stc_delta(get_pts(buf)));
/* Packet now in memory */
pthread_mutex_lock(&packetMutex);
packet_queue.push(buf);
/* TODO: allocation exception */
// wake up dvb thread
pthread_cond_broadcast(&packetCond);
pthread_mutex_unlock(&packetMutex);
} else {
free(buf);
buf=NULL;
}
}
dmx->Stop();
delete dmx;
dmx = NULL;
close(fds[0]);
close(fds[1]);
flagFd = -1;
sub_debug.print(Debug::VERBOSE, "%s shutdown\n", __FUNCTION__);
pthread_exit(NULL);
}
示例4: reader_thread
//.........这里部分代码省略.........
int ret = pthread_cond_wait(&readerCond, &readerMutex);
pthread_mutex_unlock(&readerMutex);
if (ret)
{
sub_debug.print(Debug::VERBOSE, "pthread_cond_timedwait fails with %d\n", ret);
}
if(!reader_running)
break;
dvbsub_stopped = 0;
sub_debug.print(Debug::VERBOSE, "%s (re)started with pid 0x%x\n", __FUNCTION__, dvbsub_pid);
}
if(pid_change_req)
{
pid_change_req = 0;
clear_queue();
dmx->Stop();
//
#if defined (PLATFORM_COOLSTREAM)
dmx->Open(DMX_PES_CHANNEL);
#else
dmx->Open(DMX_PES_CHANNEL, 64*1024, live_fe/*?live_fe->fenumber:0*/);
#endif
//
dmx->pesFilter(dvbsub_pid);
dmx->Start();
sub_debug.print(Debug::VERBOSE, "%s changed to pid 0x%x\n", __FUNCTION__, dvbsub_pid);
}
len = 0;
count = 0;
len = dmx->Read(tmp, 6, 1000);
//printf("\n[dvbsub] len: %d\n", len);
if(len <= 0)
continue;
if(memcmp(tmp, "\x00\x00\x01\xbd", 4))
{
sub_debug.print(Debug::VERBOSE, "[subtitles] bad start code: %02x%02x%02x%02x\n", tmp[0], tmp[1], tmp[2], tmp[3]);
continue;
}
count = 6;
packlen = getbits(tmp, 4*8, 16) + 6;
buf = (uint8_t*) malloc(packlen);
memcpy(buf, tmp, 6);
/* read rest of the packet */
while((count < packlen) /* && !dvbsub_paused*/)
{
len = dmx->Read(buf+count, packlen-count, 1000);
if (len < 0) {
continue;
} else {
count += len;
}
}
#if 0
for(int i = 6; i < packlen - 4; i++) {
if(!memcmp(&buf[i], "\x00\x00\x01\xbd", 4)) {
int plen = getbits(&buf[i], 4*8, 16) + 6;
printf("[subtitles] PES header at %d ?!\n", i);
printf("[subtitles] start code: %02x%02x%02x%02x len %d\n", buf[i+0], buf[i+1], buf[i+2], buf[i+3], plen);
free(buf);
continue;
}
}
#endif
if(!dvbsub_stopped /*!dvbsub_paused*/ )
{
//sub_debug.print(Debug::VERBOSE, "[subtitles] new packet, len %d buf 0x%x pts-stc diff %lld\n", count, buf, get_pts_stc_delta(get_pts(buf)));
/* Packet now in memory */
packet_queue.push(buf);
/* TODO: allocation exception */
// wake up dvb thread
pthread_mutex_lock(&packetMutex);
pthread_cond_broadcast(&packetCond);
pthread_mutex_unlock(&packetMutex);
}
else
{
free(buf);
buf=NULL;
}
}
dmx->Stop();
delete dmx;
dmx = NULL;
sub_debug.print(Debug::VERBOSE, "%s shutdown\n", __FUNCTION__);
pthread_exit(NULL);
}