From 354262c557a9ee3717adabd959f307478b35d355 Mon Sep 17 00:00:00 2001 From: APHW2 MFGENG Date: Tue, 3 Oct 2017 13:28:56 -0700 Subject: [PATCH] wip nvsocket --- db/zm_create.sql.in | 2 +- db/zm_update-1.31.6.sql | 1 + distros/ubuntu1604/changelog | 7 ++++ src/CMakeLists.txt | 2 +- src/zm_monitor.cpp | 17 +++++++++ src/zm_remote_camera_nvsocket.cpp | 54 ++++------------------------- src/zm_remote_camera_nvsocket.h | 15 +++++++- version | 2 +- web/api/.gitattributes | 33 ------------------ web/api/.gitignore | 21 ----------- web/lang/en_gb.php | 14 ++++---- web/skins/classic/views/monitor.php | 38 ++++++++++++-------- 12 files changed, 79 insertions(+), 127 deletions(-) create mode 100644 db/zm_update-1.31.6.sql delete mode 100644 web/api/.gitattributes delete mode 100644 web/api/.gitignore diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 7a67c7e59..daa164d63 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -320,7 +320,7 @@ DROP TABLE IF EXISTS `MonitorPresets`; CREATE TABLE `MonitorPresets` ( `Id` int(10) unsigned NOT NULL auto_increment, `Name` varchar(64) NOT NULL default '', - `Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL') NOT NULL default 'Local', + `Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL','NVSocket') NOT NULL default 'Local', `Device` tinytext, `Channel` tinytext, `Format` int(10) unsigned default NULL, diff --git a/db/zm_update-1.31.6.sql b/db/zm_update-1.31.6.sql new file mode 100644 index 000000000..ea1bb2a58 --- /dev/null +++ b/db/zm_update-1.31.6.sql @@ -0,0 +1 @@ +ALTER TABLE Monitors MODIFY `Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL','NVSocket') NOT NULL default 'Local'; diff --git a/distros/ubuntu1604/changelog b/distros/ubuntu1604/changelog index e69de29bb..3ea02e3ea 100644 --- a/distros/ubuntu1604/changelog +++ b/distros/ubuntu1604/changelog @@ -0,0 +1,7 @@ +zoneminder (1.31.4-vivid1) vivid; urgency=medium + + * Release 1.31.4 + + -- Isaac Connor Thu, 21 Sep 2017 09:55:31 -0700 + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 539dfea36..84962f572 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY) # Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc) -set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_eventstream.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_input.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_monitorstream.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_packet.cpp zm_packetqueue.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_remote_camera_nvsocket.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_swscale.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp zm_storage.cpp) +set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_eventstream.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_input.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_monitorstream.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_packet.cpp zm_packetqueue.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_nvsocket.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_swscale.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp zm_storage.cpp) # A fix for cmake recompiling the source files for every target. add_library(zm STATIC ${ZM_BIN_SRC_FILES}) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index aa948a184..7df356ce9 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -35,6 +35,7 @@ #endif // ZM_HAS_V4L #include "zm_remote_camera.h" #include "zm_remote_camera_http.h" +#include "zm_remote_camera_nvsocket.h" #if HAVE_LIBAVFORMAT #include "zm_remote_camera_rtsp.h" #endif // HAVE_LIBAVFORMAT @@ -2653,6 +2654,22 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) { #else // ZM_HAS_V4L Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); #endif // ZM_HAS_V4L + } else if ( type == "NVSocket" ) { + camera = new RemoteCameraNVSocket( + id, + host.c_str(), + port.c_str(), + path.c_str(), + width, + height, + colours, + brightness, + contrast, + hue, + colour, + purpose==CAPTURE, + record_audio + ); } else if ( type == "Remote" ) { if ( protocol == "http" ) { camera = new RemoteCameraHttp( diff --git a/src/zm_remote_camera_nvsocket.cpp b/src/zm_remote_camera_nvsocket.cpp index abf61540c..933e5d343 100644 --- a/src/zm_remote_camera_nvsocket.cpp +++ b/src/zm_remote_camera_nvsocket.cpp @@ -117,7 +117,7 @@ int RemoteCameraNVSocket::Connect() { Warning("Can't connect to remote camera mid: %d at %s: %s", monitor_id, buf, strerror(errno) ); continue; } - + Debug(1,"Connected to nvsocket mid: %d at %s: %s", monitor_id, buf, strerror(errno) ); /* If we got here, we must have connected successfully */ break; } @@ -284,56 +284,16 @@ struct image_def image_def; } int RemoteCameraNVSocket::Capture( Image &image ) { - int content_length = GetResponse(); - if ( content_length == 0 ) { + if ( SendRequest("GetNextImage") < 0 ) { Warning( "Unable to capture image, retrying" ); return( 1 ); } - if ( content_length < 0 ) { - Error( "Unable to get response, disconnecting" ); - Disconnect(); - return( -1 ); - } - switch( format ) { - case JPEG : - { - if ( !image.DecodeJpeg( buffer.extract( content_length ), content_length, colours, subpixelorder ) ) - { - Error( "Unable to decode jpeg" ); - Disconnect(); - return( -1 ); - } - break; - } - case X_RGB : - { - if ( content_length != (long)image.Size() ) - { - Error( "Image length mismatch, expected %d bytes, content length was %d", image.Size(), content_length ); - Disconnect(); - return( -1 ); - } - image.Assign( width, height, colours, subpixelorder, buffer, imagesize ); - break; - } - case X_RGBZ : - { - if ( !image.Unzip( buffer.extract( content_length ), content_length ) ) - { - Error( "Unable to unzip RGB image" ); - Disconnect(); - return( -1 ); - } - image.Assign( width, height, colours, subpixelorder, buffer, imagesize ); - break; - } - default : - { - Error( "Unexpected image format encountered" ); - Disconnect(); - return( -1 ); - } + if ( Read( sd, buffer, imagesize ) < imagesize ) { + Warning( "Unable to capture image, retrying" ); + return( 1 ); } + + image.Assign( width, height, colours, subpixelorder, buffer, imagesize ); return( 0 ); } diff --git a/src/zm_remote_camera_nvsocket.h b/src/zm_remote_camera_nvsocket.h index 8c7f66db5..4f62bafe3 100644 --- a/src/zm_remote_camera_nvsocket.h +++ b/src/zm_remote_camera_nvsocket.h @@ -44,7 +44,20 @@ protected: enum { SIMPLE, REGEXP } method; public: - RemoteCameraNVSocket( unsigned int p_monitor_id, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ); + RemoteCameraNVSocket( +unsigned int p_monitor_id, +const std::string &host, +const std::string &port, +const std::string &path, +int p_width, +int p_height, +int p_colours, +int p_brightness, +int p_contrast, +int p_hue, +int p_colour, +bool p_capture, +bool p_record_audio ); ~RemoteCameraNVSocket(); void Initialise(); diff --git a/version b/version index 490b76e45..deade24a7 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.5 +1.31.6 diff --git a/web/api/.gitattributes b/web/api/.gitattributes deleted file mode 100644 index fc3f49166..000000000 --- a/web/api/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -# Define the line ending behavior of the different file extensions -# Set default behaviour, in case users don't have core.autocrlf set. -* text=auto - -# Explicitly declare text files we want to always be normalized and converted -# to native line endings on checkout. -*.php text -*.default text -*.ctp text -*.sql text -*.md text -*.po text -*.js text -*.css text -*.ini text -*.properties text -*.txt text -*.xml text -*.yml text -.htaccess text - -# Declare files that will always have CRLF line endings on checkout. -*.bat eol=crlf - -# Declare files that will always have LF line endings on checkout. -*.pem eol=lf - -# Denote all files that are truly binary and should not be modified. -*.png binary -*.jpg binary -*.gif binary -*.ico binary -*.mo binary \ No newline at end of file diff --git a/web/api/.gitignore b/web/api/.gitignore deleted file mode 100644 index 4a1adb886..000000000 --- a/web/api/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# User specific & automatically generated files # -################################################# -/app/Config/database.php -/app/tmp -/lib/Cake/Console/Templates/skel/tmp/ -/plugins -/vendors -/build -/dist -/tags - -# OS generated files # -###################### -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -.Trashes -Icon? -ehthumbs.db -Thumbs.db \ No newline at end of file diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index ece6eccb8..8783f1ed8 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -595,13 +595,13 @@ $SLANG = array( 'Record' => 'Record', 'RefImageBlendPct' => 'Reference Image Blend %ge', 'Refresh' => 'Refresh', - 'RemoteHostName' => 'Remote Host Name', - 'RemoteHostPath' => 'Remote Host Path', - 'RemoteHostSubPath' => 'Remote Host SubPath', - 'RemoteHostPort' => 'Remote Host Port', - 'RemoteImageColours' => 'Remote Image Colours', - 'RemoteMethod' => 'Remote Method', - 'RemoteProtocol' => 'Remote Protocol', + 'RemoteHostName' => 'Host Name', + 'RemoteHostPath' => 'Path', + 'RemoteHostSubPath' => 'SubPath', + 'RemoteHostPort' => 'Port', + 'RemoteImageColours' => 'Image Colours', + 'RemoteMethod' => 'Method', + 'RemoteProtocol' => 'Protocol', 'Remote' => 'Remote', 'Rename' => 'Rename', 'ReplayAll' => 'All Events', diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index d54a1b028..0e92476e6 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -51,11 +51,13 @@ if ( ! $Server ) { $Server = array( 'Id' => '' ); } +$monitor = null; if ( ! empty($_REQUEST['mid']) ) { $monitor = new Monitor( $_REQUEST['mid'] ); - if ( ZM_OPT_X10 ) + if ( $monitor and ZM_OPT_X10 ) $x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['mid']) ); -} else { +} +if ( ! $monitor ) { $nextId = getTableAutoInc( 'Monitors' ); if ( isset( $_REQUEST['dupId'] ) ) { @@ -207,7 +209,8 @@ $sourceTypes = array( 'File' => translate('File'), 'Ffmpeg' => translate('Ffmpeg'), 'Libvlc' => translate('Libvlc'), - 'cURL' => 'cURL (HTTP(S) only)' + 'cURL' => 'cURL (HTTP(S) only)', + 'NVSocket' => translate('NVSocket') ); if ( !ZM_HAS_V4L ) unset($sourceTypes['Local']); @@ -395,12 +398,12 @@ $Colours = array( ); $orientations = array( - translate('Normal') => '0', - translate('RotateRight') => '90', - translate('Inverted') => '180', - translate('RotateLeft') => '270', - translate('FlippedHori') => 'hori', - translate('FlippedVert') => 'vert' + '0' => translate('Normal'), + '90' => translate('RotateRight'), + '180' => translate('Inverted'), + '270' => translate('RotateLeft'), + 'horz' => translate('FlippedHori'), + 'vert' => translate('FlippedVert') ); $deinterlaceopts = array( @@ -598,7 +601,7 @@ if ( $tab != 'storage' ) { Type()!= 'Remote' && $monitor->Protocol()!= 'rtsp') ) { +if ( $tab != 'source' || ($monitor->Type() != 'Remote' && $monitor->Protocol()!= 'rtsp') ) { ?> Type() != 'Local' && $monitor->Type() != 'File' ) { + if ( $monitor->Type() != 'Local' && $monitor->Type() != 'File' && $monitor->Type() != 'NVSocket' ) { ?>  () @@ -822,7 +825,10 @@ switch ( $tab ) { Type() == 'Remote' ) { + + } else if ( $monitor->Type() == 'NVSocket' ) { +include('monitor_source_nvsocket.php'); + } else if ( $monitor->Type() == 'Remote' ) { ?> Protocol(), "updateMethods( this );if(this.value=='rtsp'){\$('RTSPDescribe').setStyle('display','table-row');}else{\$('RTSPDescribe').hide();}" ); ?> - + Type() == 'File' ) { @@ -857,14 +863,16 @@ switch ( $tab ) {  (Type()), 'zmOptionHelp', 'optionhelp', '?' ) ?>) Type() != 'NVSocket' ) { ?> () () - + Orientation() );?> Type() == 'Local' ) { + } +if ( $monitor->Type() == 'Local' ) { ?>