Added ability to control camera settings.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@576 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-06-25 09:47:09 +00:00
parent f20eeaa339
commit d543323c9a
10 changed files with 508 additions and 37 deletions

View File

@ -201,13 +201,13 @@ sleep( START_DELAY );
my $filters = GetFilters( $monitor );
my $last_action = 0;
my $size = 16; # We only need the first 16 bytes really for the last event count
my $size = 24; # We only need the first 16 bytes really for the last event count
my $key = ZM_SHM_KEY|$monitor;
my $shmid = shmget( $key, $size, 0 ) || die( "Can't get shared memory id: $!" );
while( 1 )
{
shmread( $shmid, $last_event_id, 12, 4 ) || die( "Can't read from shared memory: $!" );
shmread( $shmid, $last_event_id, 20, 4 ) || die( "Can't read from shared memory: $!" );
$last_event_id = unpack( "l", $last_event_id );
print( "Last event generated is $last_event_id\n" ) if ( VERBOSE );

View File

@ -55,6 +55,13 @@ public:
unsigned int Colours() const { return( colours ); }
unsigned int ImageSize() const { return( colours*width*height ); }
virtual int Brightness( int p_brightness=-1 ) { return( -1 ); }
virtual int Hue( int p_hue=-1 ) { return( -1 ); }
virtual int Colour( int p_colour=-1 ) { return( -1 ); }
virtual int Contrast( int p_contrast=-1 ) { return( -1 ); }
bool CanCapture() const { return( capture ); }
virtual int PreCapture()=0;
virtual int PostCapture( Image &image )=0;
};

View File

@ -417,6 +417,90 @@ bool LocalCamera::GetCurrentSettings( int device, char *output, bool verbose )
return( true );
}
int LocalCamera::Brightness( int p_brightness )
{
struct video_picture vid_pic;
if( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) )
{
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
return( -1 );
}
if ( p_brightness >= 0 )
{
vid_pic.brightness = p_brightness;
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
{
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
return( -1 );
}
}
return( vid_pic.brightness );
}
int LocalCamera::Hue( int p_hue )
{
struct video_picture vid_pic;
if( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) )
{
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
return( -1 );
}
if ( p_hue >= 0 )
{
vid_pic.hue = p_hue;
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
{
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
return( -1 );
}
}
return( vid_pic.hue );
}
int LocalCamera::Colour( int p_colour )
{
struct video_picture vid_pic;
if( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) )
{
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
return( -1 );
}
if ( p_colour >= 0 )
{
vid_pic.colour = p_colour;
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
{
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
return( -1 );
}
}
return( vid_pic.colour );
}
int LocalCamera::Contrast( int p_contrast )
{
struct video_picture vid_pic;
if( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) )
{
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
return( -1 );
}
if ( p_contrast >= 0 )
{
vid_pic.contrast = p_contrast;
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
{
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
return( -1 );
}
}
return( vid_pic.contrast );
}
int LocalCamera::PreCapture()
{
//Info(( "%s: Capturing image", id ));

View File

@ -57,6 +57,11 @@ public:
unsigned int Channel() const { return( channel ); }
unsigned int Format() const { return( format ); }
int Brightness( int p_brightness=-1 );
int Hue( int p_hue=-1 );
int Colour( int p_colour=-1 );
int Contrast( int p_contrast=-1 );
int PreCapture();
int PostCapture( Image &image );

View File

@ -26,28 +26,28 @@
#include "zm_local_camera.h"
#include "zm_remote_camera.h"
Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), n_zones( p_n_zones ), zones( p_zones )
Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), mode( p_mode ), n_zones( p_n_zones ), zones( p_zones )
{
name = new char[strlen(p_name)+1];
strcpy( name, p_name );
strcpy( label_format, p_label_format );
camera = new LocalCamera( p_device, p_channel, p_format, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, p_mode==CAPTURE );
camera = new LocalCamera( p_device, p_channel, p_format, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, mode==CAPTURE );
Initialise( p_mode );
Initialise();
}
Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), n_zones( p_n_zones ), zones( p_zones )
Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), mode( p_mode ), n_zones( p_n_zones ), zones( p_zones )
{
name = new char[strlen(p_name)+1];
strcpy( name, p_name );
strcpy( label_format, p_label_format );
camera = new RemoteCamera( p_host, p_port, p_path, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, p_mode==CAPTURE );
camera = new RemoteCamera( p_host, p_port, p_path, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, mode==CAPTURE );
Initialise( p_mode);
Initialise();
}
Monitor::~Monitor()
@ -71,7 +71,7 @@ Monitor::~Monitor()
}
}
void Monitor::Initialise( Mode mode )
void Monitor::Initialise()
{
fps = 0.0;
event_count = 0;
@ -103,10 +103,15 @@ void Monitor::Initialise( Mode mode )
memset( shared_data, 0, shared_data_size );
shared_data->valid = true;
shared_data->state = IDLE;
shared_data->force_state = FORCE_NEUTRAL;
shared_data->last_write_index = image_buffer_count;
shared_data->last_read_index = image_buffer_count;
shared_data->last_event = 0;
shared_data->force_state = FORCE_NEUTRAL;
shared_data->action = (Action)0;
shared_data->brightness = -1;
shared_data->hue = -1;
shared_data->colour = -1;
shared_data->contrast = -1;
}
if ( !shared_data->valid )
{
@ -263,6 +268,142 @@ void Monitor::CancelForced()
shared_data->force_state = FORCE_NEUTRAL;
}
int Monitor::Brightness( int p_brightness )
{
if ( mode != CAPTURE )
{
if ( p_brightness >= 0 )
{
shared_data->brightness = p_brightness;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & SET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
else
{
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & GET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
return( shared_data->brightness );
}
return( camera->Brightness( p_brightness ) );
}
int Monitor::Contrast( int p_contrast )
{
if ( mode != CAPTURE )
{
if ( p_contrast >= 0 )
{
shared_data->contrast = p_contrast;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & SET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
else
{
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & GET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
return( shared_data->contrast );
}
return( camera->Contrast( p_contrast ) );
}
int Monitor::Hue( int p_hue )
{
if ( mode != CAPTURE )
{
if ( p_hue >= 0 )
{
shared_data->hue = p_hue;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & SET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
else
{
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & GET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
return( shared_data->hue );
}
return( camera->Hue( p_hue ) );
}
int Monitor::Colour( int p_colour )
{
if ( mode != CAPTURE )
{
if ( p_colour >= 0 )
{
shared_data->colour = p_colour;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & SET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
else
{
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while ( shared_data->action & GET_SETTINGS )
{
if ( wait_loops-- )
usleep( 100000 );
else
return( -1 );
}
}
return( shared_data->colour );
}
return( camera->Colour( p_colour ) );
}
void Monitor::DumpZoneImage()
{
int index = shared_data->last_write_index;

View File

@ -73,6 +73,8 @@ protected:
int fps_report_interval;// How many images should be captured/processed between reporting the current FPS
int ref_blend_perc; // Percentage of new image going into reference image.
Mode mode; // What this monitor has been created to do
double fps;
Image image;
Image ref_image;
@ -98,15 +100,21 @@ protected:
Snapshot *image_buffer;
typedef enum { FORCE_NEUTRAL, FORCE_ON, FORCE_OFF } ForceState;
typedef enum { GET_SETTINGS=0x0001, SET_SETTINGS=0x0002 } Action;
typedef struct
{
bool valid;
State state;
ForceState force_state;
int last_write_index;
int last_read_index;
int last_event;
ForceState force_state;
int action;
int brightness;
int hue;
int colour;
int contrast;
struct timeval *timestamps;
unsigned char *images;
} SharedData;
@ -122,7 +130,7 @@ public:
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
~Monitor();
void Initialise( Mode mode );
void Initialise();
void AddZones( int p_n_zones, Zone *p_zones[] );
@ -151,6 +159,11 @@ public:
void ForceAlarmOff();
void CancelForced();
int Brightness( int p_brightness=-1 );
int Hue( int p_hue=-1 );
int Colour( int p_colour=-1 );
int Contrast( int p_contrast=-1 );
bool DumpSettings( char *output, bool verbose );
void DumpZoneImage();
@ -200,6 +213,23 @@ public:
Info(( "%s: %d - Capturing at %.2f fps", name, image_count, fps ));
last_fps_time = now;
}
if ( shared_data->action & GET_SETTINGS )
{
shared_data->brightness = camera->Brightness();
shared_data->hue = camera->Hue();
shared_data->colour = camera->Colour();
shared_data->contrast = camera->Contrast();
shared_data->action &= ~GET_SETTINGS;
}
if ( shared_data->action & SET_SETTINGS )
{
camera->Brightness( shared_data->brightness );
camera->Hue( shared_data->hue );
camera->Colour( shared_data->colour );
camera->Contrast( shared_data->contrast );
shared_data->action &= ~SET_SETTINGS;
}
return( 0 );
}
return( -1 );

View File

@ -27,13 +27,22 @@
void Usage( int status=-1 )
{
fprintf( stderr, "zmu <-d device_no> [-v] [function]\n" );
fprintf( stderr, "zmu [-m monitor_id] [-v] [function]\n" );
fprintf( stderr, "Options:\n" );
fprintf( stderr, " -d, --device <device_no> : Get the current video device settings for /dev/video<device_no>\n" );
fprintf( stderr, " -m, --monitor <monitor_id> : Specify which monitor to address, default 1 if absent\n" );
fprintf( stderr, "zmu <-m monitor_id> [-v] [function]\n" );
fprintf( stderr, "General options:\n" );
fprintf( stderr, " -h, --help : This screen\n" );
fprintf( stderr, " -v, --verbose : Produce more verbose output\n" );
fprintf( stderr, " -q, --query : Query the current settings for the device or monitor\n" );
fprintf( stderr, "Options for use with devices:\n" );
fprintf( stderr, " -d, --device <device_no> : Get the current video device settings for /dev/video<device_no>\n" );
fprintf( stderr, " -q, --query : Query the current settings for the device\n" );
fprintf( stderr, " -p, --probe : Query possible settings for the device\n" );
fprintf( stderr, "Options for use with monitors:\n" );
fprintf( stderr, " -m, --monitor <monitor_id> : Specify which monitor to address, default 1 if absent\n" );
fprintf( stderr, " -q, --query : Query the current settings for the monitor\n" );
fprintf( stderr, " -s, --state : Output the current monitor state, 0 = idle, 1 = alarm, 2 = alert\n" );
fprintf( stderr, " -B, --brightness [value] : Output the current brightness, set to value if given \n" );
fprintf( stderr, " -C, --contrast [value] : Output the current contrast, set to value if given \n" );
fprintf( stderr, " -H, --hue [value] : Output the current hue, set to value if given \n" );
fprintf( stderr, " -O, --colour [value] : Output the current colour, set to value if given \n" );
fprintf( stderr, " -i, --image [image_index] : Write captured image to disk as <monitor_name>.jpg, last image captured\n" );
fprintf( stderr, " or specified ring buffer index if given.\n" );
fprintf( stderr, " -t, --timestamp [image_index] : Output captured image timestamp, last image captured or specified\n" );
@ -46,8 +55,6 @@ void Usage( int status=-1 )
fprintf( stderr, " -a, --alarm : Force alarm in monitor, this will trigger recording until cancelled with -c\n" );
fprintf( stderr, " -n, --noalarm : Force no alarms in monitor, this will prevent alarms until cancelled with -c\n" );
fprintf( stderr, " -c, --cancel : Cancel a forced alarm/noalarm in monitor, required after being enabled with -a or -n\n" );
fprintf( stderr, " -h, --help - This screen\n" );
fprintf( stderr, "Note, only the -q/--query option is valid with -d/--device\n" );
exit( status );
}
@ -61,6 +68,10 @@ int main( int argc, char *argv[] )
{"image", 2, 0, 'i'},
{"timestamp", 2, 0, 't'},
{"state", 0, 0, 's'},
{"brightness", 2, 0, 'B'},
{"contrast", 2, 0, 'C'},
{"hue", 2, 0, 'H'},
{"contrast", 2, 0, 'O'},
{"read_index", 0, 0, 'r'},
{"write_index", 0, 0, 'w'},
{"event", 0, 0, 'e'},
@ -70,6 +81,7 @@ int main( int argc, char *argv[] )
{"noalarm", 0, 0, 'n'},
{"cancel", 0, 0, 'c'},
{"query", 0, 0, 'q'},
{"brightness", 0, 0, 'b'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
@ -90,16 +102,24 @@ int main( int argc, char *argv[] )
ALARM=0x0100,
NOALARM=0x0200,
CANCEL=0x0400,
QUERY=0x0800
QUERY=0x0800,
BRIGHTNESS=0x1000,
CONTRAST=0x2000,
HUE=0x4000,
COLOUR=0x8000
} Function;
Function function = BOGUS;
int image_idx = -1;
int brightness = -1;
int contrast = -1;
int hue = -1;
int colour = -1;
while (1)
{
int option_index = 0;
int c = getopt_long (argc, argv, "d:m:vsrwie::t::fzancqh", long_options, &option_index);
int c = getopt_long (argc, argv, "d:m:vsrwie::t::fzancqphB::C::H::O::", long_options, &option_index);
if (c == -1)
{
break;
@ -160,6 +180,34 @@ int main( int argc, char *argv[] )
case 'q':
function = Function(function | QUERY);
break;
case 'B':
function = Function(function | BRIGHTNESS);
if ( optarg )
{
brightness = atoi( optarg );
}
break;
case 'C':
function = Function(function | CONTRAST);
if ( optarg )
{
contrast = atoi( optarg );
}
break;
case 'H':
function = Function(function | HUE);
if ( optarg )
{
hue = atoi( optarg );
}
break;
case 'O':
function = Function(function | COLOUR);
if ( optarg )
{
colour = atoi( optarg );
}
break;
case 'h':
Usage( 0 );
break;
@ -181,9 +229,9 @@ int main( int argc, char *argv[] )
Usage();
}
if ( dev_id >= 0 && function != QUERY )
if ( dev_id >= 0 && !(function&(QUERY|QUERY)) )
{
fprintf( stderr, "Error, -d option cannot be used with this options\n" );
fprintf( stderr, "Error, -d option cannot be used with this option\n" );
Usage();
}
//printf( "Monitor %d, Function %d\n", mon_id, function );
@ -197,10 +245,13 @@ int main( int argc, char *argv[] )
if ( dev_id >= 0 )
{
char vid_string[1024] = "";
bool ok = LocalCamera::GetCurrentSettings( dev_id, vid_string, verbose );
printf( "%s", vid_string );
exit( ok?0:-1 );
if ( function & QUERY )
{
char vid_string[4096] = "";
bool ok = LocalCamera::GetCurrentSettings( dev_id, vid_string, verbose );
printf( "%s", vid_string );
exit( ok?0:-1 );
}
}
else
{
@ -331,6 +382,82 @@ int main( int argc, char *argv[] )
monitor->DumpSettings( mon_string, verbose );
printf( "%s\n", mon_string );
}
if ( function & BRIGHTNESS )
{
if ( verbose )
{
if ( brightness >= 0 )
printf( "New brightness: %d\n", monitor->Brightness( brightness ) );
else
printf( "Current brightness: %d\n", monitor->Brightness() );
}
else
{
if ( have_output ) printf( "%c", separator );
if ( brightness >= 0 )
printf( "%d", monitor->Brightness( brightness ) );
else
printf( "%d", monitor->Brightness() );
have_output = true;
}
}
if ( function & CONTRAST )
{
if ( verbose )
{
if ( contrast >= 0 )
printf( "New brightness: %d\n", monitor->Contrast( contrast ) );
else
printf( "Current contrast: %d\n", monitor->Contrast() );
}
else
{
if ( have_output ) printf( "%c", separator );
if ( contrast >= 0 )
printf( "%d", monitor->Contrast( contrast ) );
else
printf( "%d", monitor->Contrast() );
have_output = true;
}
}
if ( function & HUE )
{
if ( verbose )
{
if ( hue >= 0 )
printf( "New hue: %d\n", monitor->Hue( hue ) );
else
printf( "Current hue: %d\n", monitor->Hue() );
}
else
{
if ( have_output ) printf( "%c", separator );
if ( hue >= 0 )
printf( "%d", monitor->Hue( hue ) );
else
printf( "%d", monitor->Hue() );
have_output = true;
}
}
if ( function & COLOUR )
{
if ( verbose )
{
if ( colour >= 0 )
printf( "New colour: %d\n", monitor->Colour( colour ) );
else
printf( "Current colour: %d\n", monitor->Colour() );
}
else
{
if ( have_output ) printf( "%c", separator );
if ( colour >= 0 )
printf( "%d", monitor->Colour( colour ) );
else
printf( "%d", monitor->Colour() );
have_output = true;
}
}
if ( have_output )
{
printf( "\n" );

View File

@ -340,6 +340,12 @@ if ( $action )
$refresh_parent = true;
}
}
elseif ( $action == "settings" )
{
$zmu_command = ZMU_PATH." -m $mid -B$new_brightness -C$new_contrast -H$new_hue -O$new_colour";
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
list( $brightness, $contrast, $hue, $colour ) = split( ' ', $zmu_output );
}
elseif ( $action == "reset" )
{
$HTTP_SESSION_VARS[event_reset_time] = strftime( "%Y-%m-%d %H:%M:%S" );

View File

@ -158,5 +158,6 @@ $jws = array(
'video' => array( 'w'=>100, 'h'=>80 ),
'image' => array( 'w'=>48, 'h'=>80 ),
'stats' => array( 'w'=>600, 'h'=>150 ),
'settings' => array( 'w'=>200, 'h'=>225 ),
);
?>

View File

@ -660,6 +660,10 @@ window.focus();
<title>ZM - <?= $monitor[Name] ?> - WatchFeed</title>
<link rel="stylesheet" href="zm_styles.css" type="text/css">
<script language="JavaScript">
function newWindow(Url,Name,Width,Height)
{
var Name = window.open(Url,Name,"resizable,width="+Width+",height="+Height);
}
function closeWindow()
{
top.window.close();
@ -669,15 +673,20 @@ function closeWindow()
<body>
<table width="96%" align="center" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="33%" align="left" class="text"><b><?= $monitor[Name] ?></b></td>
<?php if ( $mode == "stream" ) { ?>
<td width="34%" align="center" class="text"><a href="<?= $PHP_SELF ?>?view=watchfeed&mode=still&mid=<?= $mid ?>">Stills</a></td>
<?php } elseif ( canStream() ) { ?>
<td width="34%" align="center" class="text"><a href="<?= $PHP_SELF ?>?view=watchfeed&mode=stream&mid=<?= $mid ?>">Stream</a></td>
<td width="25%" align="left" class="text"><b><?= $monitor[Name] ?></b></td>
<?php if ( $monitor[Type] == "Local" ) { ?>
<td width="25%" align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=settings&mid=<?= $monitor[Id] ?>', 'zmSettings<?= $monitor[Name] ?>', <?= $jws['settings']['w'] ?>, <?= $jws['settings']['h'] ?> );">Settings</a></td>
<?php } else { ?>
<td width="34%" align="center" class="text">&nbsp;</td>
<td width="25%" align="center" class="text">&nbsp;</td>
<?php } ?>
<td width="33%" align="right" class="text"><a href="javascript: closeWindow();">Close</a></td>
<?php if ( $mode == "stream" ) { ?>
<td width="25%" align="center" class="text"><a href="<?= $PHP_SELF ?>?view=watchfeed&mode=still&mid=<?= $mid ?>">Stills</a></td>
<?php } elseif ( canStream() ) { ?>
<td width="25%" align="center" class="text"><a href="<?= $PHP_SELF ?>?view=watchfeed&mode=stream&mid=<?= $mid ?>">Stream</a></td>
<?php } else { ?>
<td width="25%" align="center" class="text">&nbsp;</td>
<?php } ?>
<td width="25%" align="right" class="text"><a href="javascript: closeWindow();">Close</a></td>
</tr>
<?php
if ( $mode == "stream" )
@ -686,26 +695,87 @@ function closeWindow()
if ( isNetscape() )
{
?>
<tr><td colspan="3" align="center"><img src="<?= $stream_src ?>" border="0" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"></td></tr>
<tr><td colspan="4" align="center"><img src="<?= $stream_src ?>" border="0" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"></td></tr>
<?php
}
else
{
?>
<tr><td colspan="3" align="center"><applet code="com.charliemouse.cambozola.Viewer" archive="<?= ZM_PATH_CAMBOZOLA ?>" align="middle" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"><param name="url" value="<?= $stream_src ?>"></applet></td></tr>
<tr><td colspan="4" align="center"><applet code="com.charliemouse.cambozola.Viewer" archive="<?= ZM_PATH_CAMBOZOLA ?>" align="middle" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"><param name="url" value="<?= $stream_src ?>"></applet></td></tr>
<?php
}
}
else
{
?>
<tr><td colspan="3" align="center"><img src="<?= ZM_DIR_IMAGES.'/'.$monitor[Name] ?>.jpg" border="0" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"></td></tr>
<tr><td colspan="4" align="center"><img src="<?= ZM_DIR_IMAGES.'/'.$monitor[Name] ?>.jpg" border="0" width="<?= $monitor[Width] ?>" height="<?= $monitor[Height] ?>"></td></tr>
<?php
}
?>
</table>
</body>
</html>
<?php
break;
}
case "settings" :
{
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );
$zmu_command = ZMU_PATH." -m $mid -B -C -H -O";
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
list( $brightness, $contrast, $hue, $colour ) = split( ' ', $zmu_output );
?>
<html>
<head>
<title>ZM - <?= $monitor[Name] ?> - Settings</title>
<link rel="stylesheet" href="zm_styles.css" type="text/css">
<script language="JavaScript">
<?php
if ( $refresh_parent )
{
?>
opener.location.reload();
<?php
}
?>
window.focus();
function validateForm(theForm)
{
return( true );
}
function closeWindow()
{
window.close();
}
</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="4" width="100%">
<tr>
<td colspan="2" align="left" class="head">Monitor <?= $monitor[Name] ?> - Settings</td>
</tr>
<form name="settings_form" method="get" action="<?= $PHP_SELF ?>" onsubmit="return validateForm( document.settings_form )">
<input type="hidden" name="view" value="<?= $view ?>">
<input type="hidden" name="action" value="settings">
<input type="hidden" name="mid" value="<?= $mid ?>">
<tr>
<td align="right" class="smallhead">Parameter</td><td align="left" class="smallhead">Value</td>
</tr>
<tr><td align="right" class="text">Brightness</td><td align="left" class="text"><input type="text" name="new_brightness" value="<?= $brightness ?>" size="8" class="form"></td></tr>
<tr><td align="right" class="text">Contrast</td><td align="left" class="text"><input type="text" name="new_contrast" value="<?= $contrast ?>" size="8" class="form"></td></tr>
<tr><td align="right" class="text">Hue</td><td align="left" class="text"><input type="text" name="new_hue" value="<?= $hue ?>" size="8" class="form"></td></tr>
<tr><td align="right" class="text">Colour</td><td align="left" class="text"><input type="text" name="new_colour" value="<?= $colour ?>" size="8" class="form"></td></tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Save" class="form">&nbsp;&nbsp;<input type="button" value="Cancel" class="form" onClick="closeWindow()"></td>
</tr>
</table>
</body>
</html>
<?php
break;
}