Fixed path problem when streaming.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@814 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
d4cdf761ff
commit
9fc320fbf7
|
@ -27,6 +27,7 @@
|
||||||
#define ZM_DB_PASSA "<from zmconfig>" // Privileged DB user password
|
#define ZM_DB_PASSA "<from zmconfig>" // Privileged DB user password
|
||||||
#define ZM_DB_USERB "<from zmconfig>" // Unprivileged DB user name, need just select privilege.
|
#define ZM_DB_USERB "<from zmconfig>" // Unprivileged DB user name, need just select privilege.
|
||||||
#define ZM_DB_PASSB "<from zmconfig>" // Unprivileged DB user password
|
#define ZM_DB_PASSB "<from zmconfig>" // Unprivileged DB user password
|
||||||
|
#define ZM_PATH_WEB "<from zmconfig>" // Path to web files
|
||||||
|
|
||||||
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
||||||
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
||||||
|
|
|
@ -319,11 +319,12 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, unsigned int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::StreamEvent( const char *path, int event_id, int rate, int scale, FILE *fd )
|
void Event::StreamEvent( int event_id, int rate, int scale, FILE *fd )
|
||||||
{
|
{
|
||||||
static char sql[BUFSIZ];
|
static char sql[BUFSIZ];
|
||||||
|
static char eventpath[PATH_MAX];
|
||||||
|
|
||||||
sprintf( sql, "select Id, EventId, Delta from Frames where EventId = %d order by Id", event_id );
|
sprintf( sql, "select M.Id, M.Name from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = %d", event_id );
|
||||||
if ( mysql_query( &dbconn, sql ) )
|
if ( mysql_query( &dbconn, sql ) )
|
||||||
{
|
{
|
||||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||||
|
@ -336,6 +337,31 @@ void Event::StreamEvent( const char *path, int event_id, int rate, int scale, FI
|
||||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||||
exit( mysql_errno( &dbconn ) );
|
exit( mysql_errno( &dbconn ) );
|
||||||
}
|
}
|
||||||
|
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||||
|
|
||||||
|
if ( mysql_errno( &dbconn ) )
|
||||||
|
{
|
||||||
|
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||||
|
exit( mysql_errno( &dbconn ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf( eventpath, "%s/%s/%s/%d", ZM_PATH_WEB, (const char *)config.Item( ZM_DIR_EVENTS ), dbrow[1], event_id );
|
||||||
|
|
||||||
|
mysql_free_result( result );
|
||||||
|
|
||||||
|
sprintf( sql, "select FrameId, EventId, Delta from Frames where EventId = %d order by FrameId", event_id );
|
||||||
|
if ( mysql_query( &dbconn, sql ) )
|
||||||
|
{
|
||||||
|
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||||
|
exit( mysql_errno( &dbconn ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
result = mysql_store_result( &dbconn );
|
||||||
|
if ( !result )
|
||||||
|
{
|
||||||
|
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||||
|
exit( mysql_errno( &dbconn ) );
|
||||||
|
}
|
||||||
|
|
||||||
setbuf( fd, 0 );
|
setbuf( fd, 0 );
|
||||||
|
|
||||||
|
@ -364,7 +390,7 @@ void Event::StreamEvent( const char *path, int event_id, int rate, int scale, FI
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
|
|
||||||
gettimeofday( &now, &dummy_tz );
|
gettimeofday( &now, &dummy_tz );
|
||||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
for( int i = 0; dbrow = mysql_fetch_row( result ); i++ )
|
||||||
{
|
{
|
||||||
if ( rate )
|
if ( rate )
|
||||||
{
|
{
|
||||||
|
@ -390,7 +416,7 @@ void Event::StreamEvent( const char *path, int event_id, int rate, int scale, FI
|
||||||
gettimeofday( &last_now, &dummy_tz );
|
gettimeofday( &last_now, &dummy_tz );
|
||||||
}
|
}
|
||||||
static char filepath[PATH_MAX];
|
static char filepath[PATH_MAX];
|
||||||
sprintf( filepath, "%s/%03d-capture.jpg", path, dbrow[0] );
|
sprintf( filepath, "%s/%03d-capture.jpg", eventpath, atoi(dbrow[0]) );
|
||||||
|
|
||||||
fprintf( fd, "Content-type: image/jpg\n\n" );
|
fprintf( fd, "Content-type: image/jpg\n\n" );
|
||||||
if ( scale == 1 )
|
if ( scale == 1 )
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void AddFrames( int n_frames, struct timeval **timestamps, const Image **images );
|
void AddFrames( int n_frames, struct timeval **timestamps, const Image **images );
|
||||||
void AddFrame( struct timeval timestamp, const Image *image, unsigned int score=0, const Image *alarm_frame=NULL );
|
void AddFrame( struct timeval timestamp, const Image *image, unsigned int score=0, const Image *alarm_frame=NULL );
|
||||||
|
|
||||||
static void StreamEvent( const char *path, int event_id, int rate=1, int scale=1, FILE *fd=stdout );
|
static void StreamEvent( int event_id, int rate=1, int scale=1, FILE *fd=stdout );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ZM_EVENT_H
|
#endif // ZM_EVENT_H
|
||||||
|
|
|
@ -29,7 +29,6 @@ int main(void )
|
||||||
unsigned int rate = 1;
|
unsigned int rate = 1;
|
||||||
unsigned int scale = 1;
|
unsigned int scale = 1;
|
||||||
int event = 0;
|
int event = 0;
|
||||||
const char *path = ".";
|
|
||||||
unsigned int ttl = 0;
|
unsigned int ttl = 0;
|
||||||
|
|
||||||
//setbuf( fd, 0 );
|
//setbuf( fd, 0 );
|
||||||
|
@ -66,8 +65,6 @@ int main(void )
|
||||||
id = atoi( value );
|
id = atoi( value );
|
||||||
else if ( !strcmp( name, "event" ) )
|
else if ( !strcmp( name, "event" ) )
|
||||||
event = strtoull( value, (char **)NULL, 10 );
|
event = strtoull( value, (char **)NULL, 10 );
|
||||||
else if ( !strcmp( name, "path" ) )
|
|
||||||
path = value;
|
|
||||||
else if ( !strcmp( name, "ttl" ) )
|
else if ( !strcmp( name, "ttl" ) )
|
||||||
ttl = atoi(value);
|
ttl = atoi(value);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +87,7 @@ int main(void )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Event::StreamEvent( path, event, rate, scale, stdout );
|
Event::StreamEvent( event, rate, scale, stdout );
|
||||||
}
|
}
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ if ( $mode == "still" && $paged && !empty($page) )
|
||||||
<?php
|
<?php
|
||||||
if ( $mode == "stream" )
|
if ( $mode == "stream" )
|
||||||
{
|
{
|
||||||
$stream_src = ZM_PATH_ZMS."?path=".ZM_PATH_WEB."&event=$eid&rate=$rate&scale=$scale";
|
$stream_src = ZM_PATH_ZMS."?event=$eid&rate=$rate&scale=$scale";
|
||||||
if ( canStreamNative() )
|
if ( canStreamNative() )
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue