2002-09-24 06:08:50 +08:00
|
|
|
//
|
2002-12-10 21:21:41 +08:00
|
|
|
// ZoneMinder Streaming Server, $Date$, $Revision$
|
2003-01-12 02:22:27 +08:00
|
|
|
// Copyright (C) 2003 Philip Coombes
|
2002-09-24 06:08:50 +08:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
//
|
|
|
|
|
2002-09-16 17:19:24 +08:00
|
|
|
#include "zm.h"
|
2003-03-26 20:00:16 +08:00
|
|
|
#include "zm_db.h"
|
|
|
|
#include "zm_monitor.h"
|
2002-09-16 17:19:24 +08:00
|
|
|
|
2004-01-15 05:26:47 +08:00
|
|
|
int main(void )
|
2002-09-16 17:19:24 +08:00
|
|
|
{
|
|
|
|
int id = 1;
|
|
|
|
unsigned long idle = 5000;
|
|
|
|
unsigned long refresh = 50;
|
2004-02-16 03:47:23 +08:00
|
|
|
unsigned int rate = 100;
|
|
|
|
unsigned int scale = 100;
|
2002-09-16 17:19:24 +08:00
|
|
|
int event = 0;
|
2003-03-21 18:53:55 +08:00
|
|
|
unsigned int ttl = 0;
|
2002-09-16 17:19:24 +08:00
|
|
|
|
2003-06-09 04:24:52 +08:00
|
|
|
//setbuf( fd, 0 );
|
|
|
|
//char streambuf[0x40000];
|
|
|
|
//setbuffer( stdout, streambuf, sizeof(streambuf) );
|
|
|
|
|
2002-09-16 17:19:24 +08:00
|
|
|
const char *query = getenv( "QUERY_STRING" );
|
|
|
|
if ( query )
|
|
|
|
{
|
|
|
|
char temp_query[256];
|
|
|
|
strcpy( temp_query, query );
|
|
|
|
char *q_ptr = temp_query;
|
|
|
|
char *parms[8]; // Shouldn't be more than this
|
|
|
|
int parm_no = 0;
|
2003-04-07 19:16:34 +08:00
|
|
|
while( (parms[parm_no] = strtok( q_ptr, "&" )) )
|
2002-09-16 17:19:24 +08:00
|
|
|
{
|
|
|
|
parm_no++;
|
|
|
|
q_ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( int p = 0; p < parm_no; p++ )
|
|
|
|
{
|
|
|
|
char *name = strtok( parms[p], "=" );
|
|
|
|
char *value = strtok( NULL, "=" );
|
2003-10-10 18:38:30 +08:00
|
|
|
if ( !strcmp( name, "rate" ) )
|
|
|
|
rate = atoi( value );
|
2003-10-16 17:00:53 +08:00
|
|
|
else if ( !strcmp( name, "scale" ) )
|
|
|
|
scale = atoi( value );
|
2003-10-10 18:38:30 +08:00
|
|
|
else if ( !strcmp( name, "refresh" ) )
|
2002-09-16 17:19:24 +08:00
|
|
|
refresh = atol( value );
|
|
|
|
else if ( !strcmp( name, "idle" ) )
|
|
|
|
idle = atol( value );
|
|
|
|
else if ( !strcmp( name, "monitor" ) )
|
|
|
|
id = atoi( value );
|
|
|
|
else if ( !strcmp( name, "event" ) )
|
2004-01-15 05:26:47 +08:00
|
|
|
event = strtoull( value, (char **)NULL, 10 );
|
2003-11-21 18:36:54 +08:00
|
|
|
else if ( !strcmp( name, "ttl" ) )
|
2003-03-21 18:53:55 +08:00
|
|
|
ttl = atoi(value);
|
2002-09-16 17:19:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-26 20:00:16 +08:00
|
|
|
zm_dbg_name = "zms";
|
2002-09-16 17:19:24 +08:00
|
|
|
|
2003-03-26 20:00:16 +08:00
|
|
|
zmDbgInit();
|
2002-09-16 17:19:24 +08:00
|
|
|
|
2003-03-26 20:00:16 +08:00
|
|
|
zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA );
|
2002-09-16 17:19:24 +08:00
|
|
|
|
|
|
|
if ( !event )
|
|
|
|
{
|
|
|
|
Monitor *monitor = Monitor::Load( id );
|
|
|
|
|
|
|
|
if ( monitor )
|
2003-03-21 18:53:55 +08:00
|
|
|
{
|
2003-10-19 18:11:07 +08:00
|
|
|
monitor->StreamImages( idle, refresh, ttl, scale, stdout );
|
2003-03-21 18:53:55 +08:00
|
|
|
}
|
2002-09-16 17:19:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-06 05:58:44 +08:00
|
|
|
Event::StreamEvent( event, rate, scale, stdout );
|
2002-09-16 17:19:24 +08:00
|
|
|
}
|
2002-10-28 22:33:57 +08:00
|
|
|
return( 0 );
|
2002-09-16 17:19:24 +08:00
|
|
|
}
|