Beispiel #1
0
//----------------------------------------------------------------------------//
void AstmField::setDate(const LocalDateTime &val, const int &index, const int &repeatedIndex)
{
    char output[18];
    
#if defined(POCO_OS_FAMILY_WINDOWS)
    _snprintf_s(output, 16, "%04d%02d%02d", val.year(), val.month(), val.day());
#else
    snprintf(output, 16, "%04d%02d%02d", val.year(), val.month(), val.day());
#endif
    
    checkIndex(index, repeatedIndex, true);
    _items[index + repeatedIndex * _componentSize] = output;
}
Beispiel #2
0
int main(int argc, char **argv)
{

	if (argc < 3)
	{
		cout << "Uage:" << argv[0] << " [ -f ] <src server > <save file >" << endl;
		exit(0);
	}

	signal(SIGHUP, sigroutine); //* 下面设置三个信号的处理方法
	signal(SIGINT, sigroutine);
	signal(SIGQUIT, sigroutine);

	bool dfps = false;
	int postion = 0;
	if (argc == 4 && (string(argv[1]) == string("-f")))
	{
		postion++;
		dfps = true;
	}

	NetH264Reader reader(argv[postion + 1]);
	FILE *out;

	cout << "connect server " << argv[postion + 1] << endl;
	if (reader.open())
	{
		cout << "connect server " << argv[postion + 1] << " sucess" << endl;
		out = fopen(argv[postion + 2], "wb");
		if (out)
		{

			H264NALU *nalu = 0;
			char naluHead[] =
			{ 0x0, 0x0, 0x0, 0x1 };
			int time = LocalDateTime().second();
			int fps = 0;
			while (run)
			{
				nalu = reader.readH264();
				if (nalu != 0)
				{
					if (dfps)
					{
						if (LocalDateTime().second() == time)
						{
							fps++;
						}
						else
						{
							LocalDateTime ld;
							cout << ld.year() << "-" << ld.month() << "-" << ld.day() << " " << ld.hour() << ":" << ld.minute() << ":" << ld.second() << " recevie fps:" << fps
									<< endl;
							fps = 1;
							time = LocalDateTime().second();
						}
					}
					fwrite(naluHead, 4, 1, out);
					fwrite(nalu->getData(), nalu->getLength(), 1, out);
				}
				else
				{
					cout << "disconnet server " << endl;
					break;
				}

			}
			
			fclose(out);
			out = NULL;
		}
		else
		{
			cout << "open file " << argv[postion + 2] << " error" << endl;
		}
	}
	else
	{
		cout << "connect server " << argv[postion + 1] << " fail" << endl;
	}

}