当前位置: 首页>>代码示例>>C++>>正文


C++ PacketStream::getPacket方法代码示例

本文整理汇总了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);
}
开发者ID:tws67,项目名称:bayonne-base-windows,代码行数:33,代码来源:packetdump.cpp

示例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;
}
开发者ID:ASTRO-BO,项目名称:RTAtest,代码行数:56,代码来源:mt.cpp

示例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;
}
开发者ID:ASTRO-BO,项目名称:RTAtest,代码行数:65,代码来源:mt.cpp


注:本文中的PacketStream::getPacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。