本文整理汇总了C++中PacketStream::getPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketStream::getPacket方法的具体用法?C++ PacketStream::getPacket怎么用?C++ PacketStream::getPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketStream
的用法示例。
在下文中一共展示了PacketStream::getPacket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packetdump
void Tool::packetdump(char **argv)
{
PacketStream packetfile;
const char *path = *argv;
Encoded buffer;
Info info;
ssize_t count;
packetfile.open(argv);
if(!packetfile.isOpen())
{
cerr << "audiotool: " << path << ": unable to access" << endl;
exit(-1);
}
if(!packetfile.isStreamable())
{
cerr << "audiotool: " << path << ": missing needed codec" << endl;
exit(-1);
}
packetfile.getInfo(&info);
buffer = new unsigned char[maxFramesize(info)];
while((count = packetfile.getPacket(buffer)) > 0)
cout << "-- " << count << endl;
delete[] buffer;
packetfile.close();
exit(0);
}
示例2: routingPacket
void* routingPacket(void* buffin)
{
PacketBufferV* buff = (PacketBufferV*) buffin;
int npix_idx = 0;
int nsamp_idx = 0;
// load packet type (once per thread)
PacketStream* ps;
pthread_mutex_lock(&lockp);
try {
ps = new PacketStream(configFileName.c_str());
} catch (PacketException* e)
{
cout << "Error during routingPacket: ";
cout << e->geterror() << endl;
}
pthread_mutex_unlock(&lockp);
ByteStreamPtr localBuffer[PACKET_NUM];
int npix[PACKET_NUM];
int nsamp[PACKET_NUM];
for(int n=0; n<NTIMES; n++)
{
// copy PACKET_NUM packets data locally
pthread_mutex_lock(&lockp);
for(int m=0; m<PACKET_NUM; m++)
{
ByteStreamPtr rawPacket = buff->getNext();
localBuffer[m] = rawPacket;
}
pthread_mutex_unlock(&lockp);
for(int m=0; m<PACKET_NUM; m++)
{
ByteStreamPtr rawPacket = localBuffer[m];
Packet *p = ps->getPacket(rawPacket);
// get npixel and nsamples
if(p->getPacketID() > 0) {
sizeMB += (p->size() / 1000000.0);
//do something with the packet
;
}
#ifdef DEBUG
else {
cout << "Warning: no packet recognized" << endl;
}
#endif
#ifdef DEBUG
std::cout << "tot size (MB) " << sizeMB << std::endl;
#endif
}
}
delete ps;
return 0;
}
示例3: decodePacket
void* decodePacket(void* buffin)
{
PacketBufferV* buff = (PacketBufferV*) buffin;
int npix_idx = 0;
int nsamp_idx = 0;
// load packet type (once per thread)
PacketStream* ps;
pthread_mutex_lock(&lockp);
try {
ps = new PacketStream(configFileName.c_str());
Packet *p = ps->getPacketType("triggered_telescope1_30GEN");
npix_idx = p->getPacketSourceDataField()->getFieldIndex("Number of pixels");
nsamp_idx = p->getPacketSourceDataField()->getFieldIndex("Number of samples");
} catch (PacketException* e)
{
cout << "Error during extractWavePacket: ";
cout << e->geterror() << endl;
}
pthread_mutex_unlock(&lockp);
ByteStreamPtr localBuffer[PACKET_NUM];
int npix[PACKET_NUM];
int nsamp[PACKET_NUM];
for(int n=0; n<NTIMES; n++)
{
// copy PACKET_NUM packets data locally
pthread_mutex_lock(&lockp);
for(int m=0; m<PACKET_NUM; m++)
{
ByteStreamPtr rawPacket = buff->getNext();
localBuffer[m] = rawPacket;
}
pthread_mutex_unlock(&lockp);
for(int m=0; m<PACKET_NUM; m++)
{
ByteStreamPtr rawPacket = localBuffer[m];
Packet *p = ps->getPacket(rawPacket);
// get npixel and nsamples
int npix = p->getPacketSourceDataField()->getFieldValue(npix_idx);
int nsamp = p->getPacketSourceDataField()->getFieldValue(nsamp_idx);
ByteStreamPtr data = p->getData();
#ifdef ARCH_BIGENDIAN
if(!data->isBigendian())
data->swapWord();
#else
if(data->isBigendian())
data->swapWord();
#endif
sizeMB += (data->size() / 1000000.0);
byte* rawdata = data->getStream();
rawdata[0] = rand() % 100 + 50;
#ifdef DEBUG
std::cout << "npixels " << npix << std::endl;
std::cout << "nsamples " << nsamp << std::endl;
std::cout << "data size " << data->size() << std::endl;
std::cout << "tot size (MB) " << sizeMB << std::endl;
#endif
}
}
delete ps;
return 0;
}