www.pudn.com > HC_v4.22_scn_20070821.zip > dmserver.c
#include#include #include #include #include #include "DataType.h" #include "ds40xxsdk.h" #include "tmserverpu.h" unsigned short format1[] = {16,19,'O','f','f','i','c','e','\0'}; unsigned short format2[] = {8,3,_OSD_YEAR4,':',_OSD_MONTH2,':',_OSD_HOUR24,':',_OSD_MINUTE,':',_OSD_SECOND,'\0'}; int gcheckpass(char * usename, int namelen, char * password, int passlen); int gcheckip(int iChannel, char * sIP); void gmessage(char * buf, int iLen); void callback(int channelNum,char * buf,int frametype,int length); int audio_port = 0; static int done = 0; void poked(int sig) { done = 1; } int main() { int channelCount; int i,retVal, chan; int channelHandle[16]; SERVER_VIDEOINFO videoinfo; RECT winRect; STREAM_READ_CALLBACK pStreamRead; pStreamRead = (STREAM_READ_CALLBACK)callback; int tei=0; char data[4]; signal(SIGHUP, poked); signal(SIGINT, poked); signal(SIGTERM, poked); retVal = InitDSPs(); if(retVal == 0){//fixed at 2005.1.13 fprintf(stderr,"Do InitDSPs Error(%08x)\n",GetLastErrorNum()); return 0; } fprintf(stderr,"Success!----InitDSPs()\n"); channelCount = GetTotalChannels(); fprintf(stderr,"channelcount = %d\n",channelCount); videoinfo.m_channum = channelCount; MP4_ServerSetNetPort(5050,6050); if( MP4_ServerStart(&videoinfo) < 0) { fprintf(stderr, "Error Number is %x\n", MP4_ServerGetLastErrorNum()); goto EXIT; } MP4_ServerSetBufNum(1,60); printf("videoinfo at 0x%x, m_channum at 0x%x\n", &videoinfo, &videoinfo.m_channum); MP4_ServerCheckPassword(gcheckpass); MP4_ServerCheckIP(gcheckip); MP4_ServerSetMessage(gmessage); //open channel for(i=0;i set osd failed!\n"); return -1; } if(SetOsd(channelHandle[chan],1)<0) { fprintf(stderr," start osd failed!\n"); return -1; } }//for(chan=0;cahn set audio failed!\n"); return -1; } #endif //start capture for(i=0;i start video capture failed!error num:0x%x\n", GetLastErrorNum()); return -1; } } fprintf(stderr," Start video capture ok!\n"); while(!done){ sleep(1); } fprintf(stderr,"beging stop!\n"); MP4_ServerStop(); //stop preview fprintf(stderr,"stop video!\n"); for(i=0;i