1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| DLL_EXPORT int System_Init(TCoreEventCallback Callback)
{
TConfiguration *Cfg;
double MotionSigmoideLambda;
char *Value, Buffer[512];
srand(GetTickCount());
System_SetConfigPath(NULL);
CoreEventCallback = Callback;
/*
{
HANDLE Handle;
int Width = 150;
int Height = 40;
AllocConsole();
Handle = GetStdHandle(STD_OUTPUT_HANDLE);
if(Width * Height>0)
{
SMALL_RECT Rect = {0, 0, Width, Height};
SetConsoleWindowInfo(Handle, 1, &Rect);
COORD Coord = {Width, 10*Height};
SetConsoleScreenBufferSize(Handle, Coord);
}
freopen("CONOUT$", "w", stdout);
}
*/
{
TLog Log;
snprintf(Buffer, sizeof(Buffer) - 1, "%sdebug.log", ConfigPath);
// BEGIN - Dialonics (02/07/2009)
FILE* file = fopen(Buffer, "a");
// BEFORE :
// freopen(Buffer, "w", stdout);
// END
Log.Mode = 0;
Log.Mode |= LOG_AUTO_FLUSH;
Log.Mode |= LOG_SHOW_FILE;
Log.Mode |= LOG_SHOW_LINE;
Log.Mode |= LOG_SHOW_FUNCTION;
Log.Mode |= LOG_SHOW_DATE;
Log.Mode |= LOG_SERIALIZE;
Log.Filename = strdup(Buffer);
Log.FD = -1;
// BEGIN - Dialonics (02/07/2009)
Log.File = file;
// BEFORE :
// Log.File = stdout;
// END
Log.Padding = 70;
Log.MaxLines = 200*1000;
Log_SetDefault(&Log);
}
#ifndef REVISION
#define REVISION "<unk>"
#endif
LOG_DEBUG("core.dll: revision %s, build on %s at %s\n", REVISION, __DATE__, __TIME__);
TRACE();
ConnectionRobot.Socket = -1;
ConnectionRobot.SSL_Session = NULL;
InitializeCriticalSection(&ConnectionCS);
InitializeCriticalSection(&SystemCS);
SSL_Init();
Video_Init();
Discover_Init();
VoIP_Init();
Record_Init();
Net_Init();
snprintf(Buffer, sizeof(Buffer) - 1, "%sdebug.nattrav.log", ConfigPath);
RemoteConnection_Init(Buffer);
snprintf(Buffer, sizeof(Buffer) - 1, "%s%s", ConfigPath, CORE_CONFIG_FILE);
Cfg = Config_Read(Buffer);
if(!Cfg)
{
LOG_DEBUG("error: Config_Read() on file '%s'\n", Buffer);
return 0;
}
Value = Config_Search(Cfg, "", "video-record-quality");
if(Value)
Record_SetParameter("video-quality", Value);
Value = Config_Search(Cfg, "", "audio-record-quality");
if(Value)
Record_SetParameter("audio-quality", Value);
Value = Config_Search(Cfg, "", "connection-brokers");
if(Value)
String_SafeRelplace(ConnectionBrokers, Value);
Value = Config_Search(Cfg, "", "connection-brokers-tcp-ports");
if(Value)
String_SafeRelplace(ConnectionBrokersTCPPorts, Value);
Value = Config_Search(Cfg, "", "connection-brokers-udp-ports");
if(Value)
String_SafeRelplace(ConnectionBrokersUDPPorts, Value);
Value = Config_Search(Cfg, "", "connect-timeout");
if(Value)
{
ConnectTimeout = atoi(Value);
if(ConnectTimeout < 5)
ConnectTimeout = 5;
}
MotionSigmoideLambda = 0.0;
Value = Config_Search(Cfg, "", "motion-sigmoide-lambda");
if(Value)
{
MotionSigmoideLambda = atof(Value);
if(MotionSigmoideLambda <= 0.0 || MotionSigmoideLambda >= 1.0)
{
LOG_DEBUG("warning: invalid sigma for motion detector (%lf)\n", MotionSigmoideLambda);
}
else
{
MotionDetector_SetSigmoideLambda(MotionSigmoideLambda);
}
}
Video_Configure(Cfg);
Config_Free(Cfg);
return 1;
} |
Partager