From ebf466c2dfe69b801b0546a9eeff01938c2adc8a Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Fri, 21 Mar 2014 17:50:49 +0100 Subject: [PATCH 01/18] - Timeout when opening stream after 10 seconds Sometimes when restarting the camera ffmpeg hung itself in some state, when calling avformat_open_input, which seemed to last forever. - Reopen stream if av_read_frame returns EOF Sometimes ffmpeg starts returning an EOF error when calling av_read_frame. Once this happens it seems no more images will ever be captured. - Reopen stream if av_read_frame returns -110 Means something like Connection failed; cant remember. Anyway. Once this happens it seems no more images will ever be captured. --- src/zm_ffmpeg_camera.cpp | 388 +++++++++++++++++++++++++-------------- src/zm_ffmpeg_camera.h | 10 + 2 files changed, 264 insertions(+), 134 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index b827c0036..ea93918ed 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -41,6 +41,10 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri mRawFrame = NULL; mFrame = NULL; frameCount = 0; + mIsOpening = false; + mCanCapture = false; + mOpenStart = 0; + mOpenTimeout = 10; #if HAVE_LIBSWSCALE mConvertContext = NULL; @@ -63,31 +67,7 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri FfmpegCamera::~FfmpegCamera() { - av_freep( &mFrame ); - av_freep( &mRawFrame ); - -#if HAVE_LIBSWSCALE - if ( mConvertContext ) - { - sws_freeContext( mConvertContext ); - mConvertContext = NULL; - } -#endif - - if ( mCodecContext ) - { - avcodec_close( mCodecContext ); - mCodecContext = NULL; // Freed by av_close_input_file - } - if ( mFormatContext ) - { -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0) - avformat_close_input( &mFormatContext ); -#else - av_close_input_file( mFormatContext ); -#endif - mFormatContext = NULL; - } + CloseFfmpeg(); if ( capture ) { @@ -112,116 +92,11 @@ void FfmpegCamera::Terminate() int FfmpegCamera::PrimeCapture() { Info( "Priming capture from %s", mPath.c_str() ); - - - // Open the input, not necessarily a file -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) - if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 ) -#else - // Handle options - AVDictionary *opts = 0; - StringVector opVect = split(Options(), ","); - - // Set transport method as specified by method field, rtpUni is default - if ( Method() == "rtpMulti" ) - opVect.push_back("rtsp_transport=udp_multicast"); - else if ( Method() == "rtpRtsp" ) - opVect.push_back("rtsp_transport=tcp"); - else if ( Method() == "rtpRtspHttp" ) - opVect.push_back("rtsp_transport=http"); - - Debug(2, "Number of Options: %d",opVect.size()); - for (size_t i=0; i 1) { - parts[0] = trimSpaces(parts[0]); - parts[1] = trimSpaces(parts[1]); - if ( av_dict_set(&opts, parts[0].c_str(), parts[1].c_str(), 0) == 0 ) { - Debug(2, "set option %d '%s' to '%s'", i, parts[0].c_str(), parts[1].c_str()); - } - else - { - Warning( "Error trying to set option %d '%s' to '%s'", i, parts[0].c_str(), parts[1].c_str() ); - } - - } + if (OpenFfmpeg() != 0){ + ReopenFfmpeg(); } - - if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) !=0 ) -#endif - Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) ); - - // Locate stream info from input -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) - if ( av_find_stream_info( mFormatContext ) < 0 ) -#else - if ( avformat_find_stream_info( mFormatContext, 0 ) < 0 ) -#endif - Fatal( "Unable to find stream info from %s due to: %s", mPath.c_str(), strerror(errno) ); - - // Find first video stream present - mVideoStreamId = -1; - for (unsigned int i=0; i < mFormatContext->nb_streams; i++ ) - { -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1) - if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) -#else - if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO ) -#endif - { - mVideoStreamId = i; - break; - } - } - if ( mVideoStreamId == -1 ) - Fatal( "Unable to locate video stream in %s", mPath.c_str() ); - - mCodecContext = mFormatContext->streams[mVideoStreamId]->codec; - - // Try and get the codec from the codec context - if ( (mCodec = avcodec_find_decoder( mCodecContext->codec_id )) == NULL ) - Fatal( "Can't find codec for video stream from %s", mPath.c_str() ); - - // Open the codec -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 7, 0) - if ( avcodec_open( mCodecContext, mCodec ) < 0 ) -#else - if ( avcodec_open2( mCodecContext, mCodec, 0 ) < 0 ) -#endif - Fatal( "Unable to open codec for video stream from %s", mPath.c_str() ); - - // Allocate space for the native video frame - mRawFrame = avcodec_alloc_frame(); - - // Allocate space for the converted video frame - mFrame = avcodec_alloc_frame(); - - if(mRawFrame == NULL || mFrame == NULL) - Fatal( "Unable to allocate frame for %s", mPath.c_str() ); - - int pSize = avpicture_get_size( imagePixFormat, width, height ); - if( (unsigned int)pSize != imagesize) { - Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); - } - -#if HAVE_LIBSWSCALE -#if LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0, 8, 0) - if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { - Fatal("swscale does not support the codec format: %c%c%c%c",(mCodecContext->pix_fmt)&0xff,((mCodecContext->pix_fmt>>8)&0xff),((mCodecContext->pix_fmt>>16)&0xff),((mCodecContext->pix_fmt>>24)&0xff)); - } - - if(!sws_isSupportedOutput(imagePixFormat)) { - Fatal("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff)); - } -#endif - -#else // HAVE_LIBSWSCALE - Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); -#endif // HAVE_LIBSWSCALE - - return( 0 ); + return 0; } int FfmpegCamera::PreCapture() @@ -232,6 +107,10 @@ int FfmpegCamera::PreCapture() int FfmpegCamera::Capture( Image &image ) { + if (!mCanCapture){ + return -1; + } + AVPacket packet; uint8_t* directbuffer; @@ -248,7 +127,16 @@ int FfmpegCamera::Capture( Image &image ) int avResult = av_read_frame( mFormatContext, &packet ); if ( avResult < 0 ) { - Error( "Unable to read packet from stream %d: error %d", packet.stream_index, avResult ); + if (avResult == AVERROR_EOF || (mFormatContext->pb && mFormatContext->pb->eof_reached)) + { + Info( "av_read_frame returned EOF. Reopening stream." ); + ReopenFfmpeg(); + } else if (avResult == -110) { + Info( "av_read_frame returned \"%s\". Reopening stream.", av_err2str(avResult)) ; + ReopenFfmpeg(); + } else { + Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, avResult, av_err2str(avResult) ); + } return( -1 ); } Debug( 5, "Got packet from stream %d", packet.stream_index ); @@ -300,4 +188,236 @@ int FfmpegCamera::PostCapture() return( 0 ); } +int FfmpegCamera::OpenFfmpeg() { + + Debug ( 2, "OpenFfmpeg called." ); + + mOpenStart = time(NULL); + mIsOpening = true; + + // Open the input, not necessarily a file +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) + Debug ( 1, "Calling av_open_input_file" ); + if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 ) +#else + // Handle options + AVDictionary *opts = 0; + StringVector opVect = split(Options(), ","); + + // Set transport method as specified by method field, rtpUni is default + if ( Method() == "rtpMulti" ) + opVect.push_back("rtsp_transport=udp_multicast"); + else if ( Method() == "rtpRtsp" ) + opVect.push_back("rtsp_transport=tcp"); + else if ( Method() == "rtpRtspHttp" ) + opVect.push_back("rtsp_transport=http"); + + Debug(2, "Number of Options: %d",opVect.size()); + for (size_t i=0; i 1) { + parts[0] = trimSpaces(parts[0]); + parts[1] = trimSpaces(parts[1]); + if ( av_dict_set(&opts, parts[0].c_str(), parts[1].c_str(), 0) == 0 ) { + Debug(2, "set option %d '%s' to '%s'", i, parts[0].c_str(), parts[1].c_str()); + } + else + { + Warning( "Error trying to set option %d '%s' to '%s'", i, parts[0].c_str(), parts[1].c_str() ); + } + + } + } + Debug ( 1, "Calling avformat_open_input" ); + + mFormatContext = avformat_alloc_context( ); + mFormatContext->interrupt_callback.callback = FfmpegInterruptCallback; + mFormatContext->interrupt_callback.opaque = this; + + if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 ) +#endif + { + mIsOpening = false; + Error( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) ); + return -1; + } + + mIsOpening = false; + Debug ( 1, "Opened input" ); + + // Locate stream info from avformat_open_input +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) + Debug ( 1, "Calling av_find_stream_info" ); + if ( av_find_stream_info( mFormatContext ) < 0 ) +#else + Debug ( 1, "Calling avformat_find_stream_info" ); + if ( avformat_find_stream_info( mFormatContext, 0 ) < 0 ) +#endif + Fatal( "Unable to find stream info from %s due to: %s", mPath.c_str(), strerror(errno) ); + + Debug ( 1, "Got stream info" ); + + // Find first video stream present + mVideoStreamId = -1; + for (unsigned int i=0; i < mFormatContext->nb_streams; i++ ) + { +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1) + if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) +#else + if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO ) +#endif + { + mVideoStreamId = i; + break; + } + } + if ( mVideoStreamId == -1 ) + Fatal( "Unable to locate video stream in %s", mPath.c_str() ); + + Debug ( 1, "Found video stream" ); + + mCodecContext = mFormatContext->streams[mVideoStreamId]->codec; + + // Try and get the codec from the codec context + if ( (mCodec = avcodec_find_decoder( mCodecContext->codec_id )) == NULL ) + Fatal( "Can't find codec for video stream from %s", mPath.c_str() ); + + Debug ( 1, "Found decoder" ); + + // Open the codec +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 7, 0) + Debug ( 1, "Calling avcodec_open" ); + if ( avcodec_open( mCodecContext, mCodec ) < 0 ) +#else + Debug ( 1, "Calling avcodec_open2" ); + if ( avcodec_open2( mCodecContext, mCodec, 0 ) < 0 ) +#endif + Fatal( "Unable to open codec for video stream from %s", mPath.c_str() ); + + Debug ( 1, "Opened codec" ); + + // Allocate space for the native video frame + mRawFrame = avcodec_alloc_frame(); + + // Allocate space for the converted video frame + mFrame = avcodec_alloc_frame(); + + if(mRawFrame == NULL || mFrame == NULL) + Fatal( "Unable to allocate frame for %s", mPath.c_str() ); + + Debug ( 1, "Allocated frames" ); + + int pSize = avpicture_get_size( imagePixFormat, width, height ); + if( (unsigned int)pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + + Debug ( 1, "Validated imagesize" ); + +#if HAVE_LIBSWSCALE + Debug ( 1, "Calling sws_isSupportedInput" ); + if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { + Fatal("swscale does not support the codec format: %c%c%c%c",(mCodecContext->pix_fmt)&0xff,((mCodecContext->pix_fmt>>8)&0xff),((mCodecContext->pix_fmt>>16)&0xff),((mCodecContext->pix_fmt>>24)&0xff)); + } + + if(!sws_isSupportedOutput(imagePixFormat)) { + Fatal("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff)); + } + +#else // HAVE_LIBSWSCALE + Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); +#endif // HAVE_LIBSWSCALE + + mCanCapture = true; + + return 0; +} + +int FfmpegCamera::ReopenFfmpeg() { + + Debug(2, "ReopenFfmpeg called."); + + mCanCapture = false; + pthread_t thread1; + if (pthread_create( &thread1, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0){ + Error( "ReopenFfmpeg failed to create worker thread." ); + return -1; + } + + return 0; +} + +int FfmpegCamera::CloseFfmpeg(){ + + Debug(2, "CloseFfmpeg called."); + + mCanCapture = false; + + av_freep( &mFrame ); + av_freep( &mRawFrame ); + +#if HAVE_LIBSWSCALE + if ( mConvertContext ) + { + sws_freeContext( mConvertContext ); + mConvertContext = NULL; + } +#endif + + if ( mCodecContext ) + { + avcodec_close( mCodecContext ); + mCodecContext = NULL; // Freed by av_close_input_file + } + if ( mFormatContext ) + { +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) + av_close_input_file( mFormatContext ); +#else + avformat_close_input( &mFormatContext ); +#endif + mFormatContext = NULL; + } + + return 0; +} + +int FfmpegCamera::FfmpegInterruptCallback(void *ctx) +{ + FfmpegCamera* camera = reinterpret_cast(ctx); + if (camera->mIsOpening){ + int now = time(NULL); + if ((now - camera->mOpenStart) > camera->mOpenTimeout) { + Error ( "Open video took more than %d seconds.", camera->mOpenTimeout ); + return 1; + } + } + + return 0; +} + +void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){ + if (ctx == NULL) return NULL; + + FfmpegCamera* camera = reinterpret_cast(ctx); + + // Close current stream. + camera->CloseFfmpeg(); + + // Sleep if neccessary to not reconnect too fast. + int wait = camera->mOpenTimeout - (time(NULL) - camera->mOpenStart); + wait = wait < 0 ? 0 : wait; + if (wait > 0){ + Debug( 1, "Sleeping %d seconds before reopening stream.", wait ); + sleep(wait); + } + + if (camera->OpenFfmpeg() != 0){ + camera->ReopenFfmpeg(); + } + + return NULL; +} + #endif // HAVE_LIBAVFORMAT diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index aadb1d5a8..bfee1bb6d 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -47,6 +47,16 @@ protected: AVFrame *mRawFrame; AVFrame *mFrame; PixelFormat imagePixFormat; + + int OpenFfmpeg(); + int ReopenFfmpeg(); + int CloseFfmpeg(); + static int FfmpegInterruptCallback(void *ctx); + static void* ReopenFfmpegThreadCallback(void *ctx); + bool mIsOpening; + bool mCanCapture; + int mOpenStart; + int mOpenTimeout; #endif // HAVE_LIBAVFORMAT #if HAVE_LIBSWSCALE From a307b8a1e3621ab636583f061ab8dc88a91a9b44 Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Fri, 21 Mar 2014 19:15:36 +0100 Subject: [PATCH 02/18] Use value from options (FFMPEG_OPEN_TIMEOUT) as timeout when calling av_open_input_file. --- scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in | 9 +++++++++ src/zm_ffmpeg_camera.cpp | 7 +++---- src/zm_ffmpeg_camera.h | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 87752ce23..54bd14e26 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -442,6 +442,15 @@ our @options = type => $types{string}, category => "images", }, + { + name => "ZM_FFMPEG_OPEN_TIMEOUT", + default => "10", + description => "Timeout in seconds when opening a stream.", + help => "When Ffmpeg is opening a stream, it can take a long time before failing; certain circumstances even seem to be able to lock indefinitely. This option allows you to set a maximum time in seconds to pass before closing the stream and trying to reopen it again.", + requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + type => $types{integer}, + category => "images", + }, { name => "ZM_LOG_LEVEL_SYSLOG", default => "0", diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index ea93918ed..d9174e6bb 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -44,7 +44,6 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri mIsOpening = false; mCanCapture = false; mOpenStart = 0; - mOpenTimeout = 10; #if HAVE_LIBSWSCALE mConvertContext = NULL; @@ -388,8 +387,8 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) FfmpegCamera* camera = reinterpret_cast(ctx); if (camera->mIsOpening){ int now = time(NULL); - if ((now - camera->mOpenStart) > camera->mOpenTimeout) { - Error ( "Open video took more than %d seconds.", camera->mOpenTimeout ); + if ((now - camera->mOpenStart) > config.ffmpeg_open_timeout) { + Error ( "Open video took more than %d seconds.", config.ffmpeg_open_timeout ); return 1; } } @@ -406,7 +405,7 @@ void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){ camera->CloseFfmpeg(); // Sleep if neccessary to not reconnect too fast. - int wait = camera->mOpenTimeout - (time(NULL) - camera->mOpenStart); + int wait = config.ffmpeg_open_timeout - (time(NULL) - camera->mOpenStart); wait = wait < 0 ? 0 : wait; if (wait > 0){ Debug( 1, "Sleeping %d seconds before reopening stream.", wait ); diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index bfee1bb6d..cef5c2e24 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -56,7 +56,6 @@ protected: bool mIsOpening; bool mCanCapture; int mOpenStart; - int mOpenTimeout; #endif // HAVE_LIBAVFORMAT #if HAVE_LIBSWSCALE From 7de59df080375ee41e8e706e82c0e6e77bfb935a Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Fri, 21 Mar 2014 19:42:03 +0100 Subject: [PATCH 03/18] removed use of av_err2str. someone could not compile when using that macro. --- src/zm_ffmpeg_camera.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index d9174e6bb..50b9b677a 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -126,16 +126,20 @@ int FfmpegCamera::Capture( Image &image ) int avResult = av_read_frame( mFormatContext, &packet ); if ( avResult < 0 ) { - if (avResult == AVERROR_EOF || (mFormatContext->pb && mFormatContext->pb->eof_reached)) + char errbuf[AV_ERROR_MAX_STRING_SIZE]; + av_strerror(avResult, errbuf, AV_ERROR_MAX_STRING_SIZE); + if ( + // Check if EOF. + (avResult == AVERROR_EOF || (mFormatContext->pb && mFormatContext->pb->eof_reached)) || + // Check for Connection failure. + (avResult == -110) + ) { - Info( "av_read_frame returned EOF. Reopening stream." ); + Info( "av_read_frame returned \"%s\". Reopening stream.", errbuf); ReopenFfmpeg(); - } else if (avResult == -110) { - Info( "av_read_frame returned \"%s\". Reopening stream.", av_err2str(avResult)) ; - ReopenFfmpeg(); - } else { - Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, avResult, av_err2str(avResult) ); } + + Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, avResult, errbuf ); return( -1 ); } Debug( 5, "Got packet from stream %d", packet.stream_index ); From 83d2a494c3c79a84c671b33ef11573b6f1f7a939 Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Fri, 21 Mar 2014 22:53:19 +0100 Subject: [PATCH 04/18] Process should exit if ReopenFfmpeg function fails to create a worker thread. --- src/zm_ffmpeg_camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 50b9b677a..78937cb57 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -344,8 +344,8 @@ int FfmpegCamera::ReopenFfmpeg() { mCanCapture = false; pthread_t thread1; if (pthread_create( &thread1, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0){ - Error( "ReopenFfmpeg failed to create worker thread." ); - return -1; + // Log a fatal error and exit the process. + Fatal( "ReopenFfmpeg failed to create worker thread." ); } return 0; From f32b1276dfa3b8a171f2d133219107dcf1150b22 Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Sun, 23 Mar 2014 00:39:36 +0100 Subject: [PATCH 05/18] Define AV_ERROR_MAX_STRING_SIZE to 64 if it is not already defined. --- src/zm_ffmpeg_camera.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 78937cb57..55e8b546c 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -19,6 +19,10 @@ #include "zm.h" +#ifndef AV_ERROR_MAX_STRING_SIZE +#define AV_ERROR_MAX_STRING_SIZE 64 +#endif + #if HAVE_LIBAVFORMAT #include "zm_ffmpeg_camera.h" From a865a555f294bebd7779b5877795519eb5e308b0 Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Sun, 23 Mar 2014 01:08:39 +0100 Subject: [PATCH 06/18] Define AV_ERROR_MAX_STRING_SIZE after all include files to use ffmpeg define if it exists. --- src/zm_ffmpeg_camera.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 55e8b546c..a32039e02 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -19,14 +19,14 @@ #include "zm.h" -#ifndef AV_ERROR_MAX_STRING_SIZE -#define AV_ERROR_MAX_STRING_SIZE 64 -#endif - #if HAVE_LIBAVFORMAT #include "zm_ffmpeg_camera.h" +#ifndef AV_ERROR_MAX_STRING_SIZE +#define AV_ERROR_MAX_STRING_SIZE 64 +#endif + FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), mPath( p_path ), From 7534557533a7347f4901a139c2b698e76aaf164d Mon Sep 17 00:00:00 2001 From: Sune1337 Date: Sat, 11 Oct 2014 16:58:47 +0200 Subject: [PATCH 07/18] - join reconnect thread when finished to clean up thread resources. - don't spawn a new thread for every attempt to open a stream while reconnecting. --- src/zm_ffmpeg_camera.cpp | 46 ++++++++++++++++++++++++++-------------- src/zm_ffmpeg_camera.h | 1 + 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index a32039e02..a0492a1d4 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -48,6 +48,7 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri mIsOpening = false; mCanCapture = false; mOpenStart = 0; + mReopenThread = 0; #if HAVE_LIBSWSCALE mConvertContext = NULL; @@ -113,6 +114,20 @@ int FfmpegCamera::Capture( Image &image ) if (!mCanCapture){ return -1; } + + // If the reopen thread has a value, but mCanCapture != 0, then we have just reopened the connection to the ffmpeg device, and we can clean up the thread. + if (mReopenThread != 0) { + void *retval = 0; + int ret; + + ret = pthread_tryjoin_np(mReopenThread, &retval); + if (ret != 0){ + Error("Could not join reopen thread."); + } + + Info( "Successfully reopened stream." ); + mReopenThread = 0; + } AVPacket packet; uint8_t* directbuffer; @@ -346,8 +361,7 @@ int FfmpegCamera::ReopenFfmpeg() { Debug(2, "ReopenFfmpeg called."); mCanCapture = false; - pthread_t thread1; - if (pthread_create( &thread1, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0){ + if (pthread_create( &mReopenThread, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0){ // Log a fatal error and exit the process. Fatal( "ReopenFfmpeg failed to create worker thread." ); } @@ -409,22 +423,22 @@ void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){ FfmpegCamera* camera = reinterpret_cast(ctx); - // Close current stream. - camera->CloseFfmpeg(); + while (1){ + // Close current stream. + camera->CloseFfmpeg(); - // Sleep if neccessary to not reconnect too fast. - int wait = config.ffmpeg_open_timeout - (time(NULL) - camera->mOpenStart); - wait = wait < 0 ? 0 : wait; - if (wait > 0){ - Debug( 1, "Sleeping %d seconds before reopening stream.", wait ); - sleep(wait); - } - - if (camera->OpenFfmpeg() != 0){ - camera->ReopenFfmpeg(); - } + // Sleep if neccessary to not reconnect too fast. + int wait = config.ffmpeg_open_timeout - (time(NULL) - camera->mOpenStart); + wait = wait < 0 ? 0 : wait; + if (wait > 0){ + Debug( 1, "Sleeping %d seconds before reopening stream.", wait ); + sleep(wait); + } - return NULL; + if (camera->OpenFfmpeg() == 0){ + return NULL; + } + } } #endif // HAVE_LIBAVFORMAT diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index cef5c2e24..11b39d3e1 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -56,6 +56,7 @@ protected: bool mIsOpening; bool mCanCapture; int mOpenStart; + pthread_t mReopenThread; #endif // HAVE_LIBAVFORMAT #if HAVE_LIBSWSCALE From 6cb96f1316a39051360cdc3689a341ea971867a9 Mon Sep 17 00:00:00 2001 From: SteveGilvarry Date: Sun, 12 Oct 2014 16:47:27 +1100 Subject: [PATCH 08/18] Put opts back in --- src/zm_ffmpeg_camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index a0492a1d4..9a4ea5fcb 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -222,7 +222,7 @@ int FfmpegCamera::OpenFfmpeg() { Debug ( 1, "Calling av_open_input_file" ); if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 ) #else - // Handle options + // Handle options AVDictionary *opts = 0; StringVector opVect = split(Options(), ","); @@ -257,7 +257,7 @@ int FfmpegCamera::OpenFfmpeg() { mFormatContext->interrupt_callback.callback = FfmpegInterruptCallback; mFormatContext->interrupt_callback.opaque = this; - if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 ) + if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) !=0 ) #endif { mIsOpening = false; From 96859e3b11c9c55277a86a3440510900f28fea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Sun, 9 Nov 2014 14:18:14 +0100 Subject: [PATCH 09/18] * Use CMake instead of Autotools. * Some lintian love (minor fixes and cosmetic changes...) * Don't remove database data if we are using a remote MySQL server. --- README.md | 2 +- distros/debian/changelog | 11 +++++ distros/debian/control | 16 ++++---- distros/debian/copyright | 35 ++++++++++++++++ distros/debian/dirs | 1 - distros/debian/init.d | 9 ++--- distros/debian/install | 7 ++++ distros/debian/links | 4 ++ distros/debian/postrm | 10 +++-- distros/debian/preinst | 0 distros/debian/rules | 87 ++++++++++++++-------------------------- 11 files changed, 104 insertions(+), 78 deletions(-) create mode 100644 distros/debian/install create mode 100644 distros/debian/links mode change 100755 => 100644 distros/debian/preinst diff --git a/README.md b/README.md index da5517f27..83db14646 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ apache2-mpm-prefork libapache2-mod-php5 php5-cli A fresh build based on master branch running Debian 7 (wheezy): ```bash -root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; +root@host:~# aptitude install -y libapache2-mod-php5 mysql-server php5-mysqlnd build-essential cmake debhelper libphp-serialization-perl libgnutls-dev libmysqlclient-dev libdbd-mysql-perl libdate-manip-perl libwww-perl libjpeg8-dev libpcre3-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libbz2-dev libsys-mmap-perl libav-tools libnetpbm10-dev libavdevice-dev libdevice-serialport-perl libarchive-zip-perl libmime-lite-perl libvlccore-dev libvlc-dev libcurl4-gnutls-dev libgcrypt11-dev libpolkit-gobject-1-dev; root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; root@host:~# cd zoneminder; diff --git a/distros/debian/changelog b/distros/debian/changelog index ceebf9367..0edaefce7 100644 --- a/distros/debian/changelog +++ b/distros/debian/changelog @@ -1,3 +1,14 @@ +zoneminder (1.28.0-0.1) wheezy; urgency=low + + * Use CMake instead of Autotools to simplify + debian/rules and have less build-depends. + * Some lintian love in debian/{control,copyright} + and perl ZoneMinder modules. + * Don't purge database if we use a remote + MySQL server. + + -- Cosme Domínguez Díaz Sun, 09 Nov 2014 02:20:20 +0100 + zoneminder (1.28.0-wheezy) wheezy; urgency=medium * Release diff --git a/distros/debian/control b/distros/debian/control index 1949ef0b9..01adf14df 100644 --- a/distros/debian/control +++ b/distros/debian/control @@ -2,14 +2,14 @@ Source: zoneminder Section: net Priority: optional Maintainer: Isaac Connor -Build-Depends: debhelper (>= 7.0.50), autoconf, automake, dpatch, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libtool, libsys-mmap-perl, ffmpeg | libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libpcre3, libarchive-zip-perl, libmime-lite-perl, libjpeg8, dh-autoreconf, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev, libpolkit-gobject-1-dev -Standards-Version: 3.9.2 +Build-Depends: debhelper (>= 9), cmake, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libsys-mmap-perl, libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev, libpolkit-gobject-1-dev +Standards-Version: 3.9.4 Package: zoneminder Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, apache2 | httpd, libapache2-mod-php5 | libapache2-mod-fcgid | php5-fpm, php5, php5-mysql|php5-mysqlnd, libphp-serialization-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, mariadb-client|mysql-client, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl, libpcre3, ffmpeg | libav-tools, rsyslog | system-log-daemon, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl, netpbm, libavdevice53, libjpeg8, zip, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl, libvlccore5 | libvlccore7, libvlc5, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libpolkit-gobject-1-0 -Recommends: mysql-server|mariadb-server -Description: A video camera security and surveillance solution +Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, apache2 | httpd, libapache2-mod-php5 | libapache2-mod-fcgid | php5-fpm, php5-mysqlnd | php5-mysql, libphp-serialization-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, mariadb-client | mysql-client, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl, libpcre3, libav-tools, rsyslog | system-log-daemon, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl, netpbm, libavdevice53, libjpeg8, zip, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl, libvlccore5 | libvlccore7, libvlc5, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libpolkit-gobject-1-0 +Recommends: mysql-server | mariadb-server +Description: Video camera security and surveillance solution ZoneMinder is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child or family member or home monitoring and other care scenarios. It @@ -23,9 +23,9 @@ Description: A video camera security and surveillance solution Package: zoneminder-dbg Architecture: any -Depends: - zoneminder (= ${binary:Version}), - ${misc:Depends} +Priority: extra +Section: debug +Depends: zoneminder (= ${binary:Version}), ${misc:Depends} Description: debugging syumbols for zoneminder. ZoneMinder is a video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security diff --git a/distros/debian/copyright b/distros/debian/copyright index a177502a0..1c10c59db 100644 --- a/distros/debian/copyright +++ b/distros/debian/copyright @@ -20,3 +20,38 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian GNU/Linux systems, the text of the GPL can be found in /usr/share/common-licenses/GPL. + +/usr/share/zoneminder/api/lib/Cake/*: +Copyright: + +Copyright (c) 2005-2013, Cake Software Foundation, Inc. + +License: + +CakePHP(tm) : The Rapid Development PHP Framework (http://cakephp.org) + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +Cake Software Foundation, Inc. +1785 E. Sahara Avenue, +Suite 490-204 +Las Vegas, Nevada 89104, +United States of America. diff --git a/distros/debian/dirs b/distros/debian/dirs index 4178482c1..9e29e6113 100644 --- a/distros/debian/dirs +++ b/distros/debian/dirs @@ -3,4 +3,3 @@ var/lib/zm var/cache/zoneminder/events var/cache/zoneminder/images var/cache/zoneminder/temp -usr/share/zoneminder/db diff --git a/distros/debian/init.d b/distros/debian/init.d index d3354c1d8..cbc8fb10e 100644 --- a/distros/debian/init.d +++ b/distros/debian/init.d @@ -23,12 +23,10 @@ command="$ZM_PATH_BIN/zmpkg.pl" start() { echo -n "Starting $prog: " - mkdir -p $RUNDIR && chown www-data:www-data $RUNDIR - mkdir -p $TMPDIR && chown www-data:www-data $TMPDIR + mkdir -p $RUNDIR $TMPDIR && chown www-data:www-data $RUNDIR $TMPDIR $command start RETVAL=$? - [ $RETVAL = 0 ] && echo success - [ $RETVAL != 0 ] && echo failure + [ $RETVAL = 0 ] && echo success || echo failure echo [ $RETVAL = 0 ] && touch /var/lock/zm return $RETVAL @@ -51,8 +49,7 @@ stop() { else $command stop RETVAL=$? - [ $RETVAL = 0 ] && echo success - [ $RETVAL != 0 ] && echo failure + [ $RETVAL = 0 ] && echo success || echo failure echo [ $RETVAL = 0 ] && rm -f /var/lock/zm fi diff --git a/distros/debian/install b/distros/debian/install new file mode 100644 index 000000000..9e8953409 --- /dev/null +++ b/distros/debian/install @@ -0,0 +1,7 @@ +usr/bin +usr/lib/cgi-bin +usr/share/man +usr/share/perl5/ZoneMinder +usr/share/perl5/ZoneMinder.pm +usr/share/zoneminder +etc/zm diff --git a/distros/debian/links b/distros/debian/links new file mode 100644 index 000000000..9715ee428 --- /dev/null +++ b/distros/debian/links @@ -0,0 +1,4 @@ +var/cache/zoneminder/events usr/share/zoneminder/events +var/cache/zoneminder/images usr/share/zoneminder/images +var/cache/zoneminder/temp usr/share/zoneminder/temp +usr/lib/cgi-bin usr/share/zoneminder/cgi-bin diff --git a/distros/debian/postrm b/distros/debian/postrm index 28a00a7a0..fde590981 100644 --- a/distros/debian/postrm +++ b/distros/debian/postrm @@ -1,9 +1,11 @@ #! /bin/sh -# set -e # to be reinstated later +set -e if [ "$1" = "purge" ]; then - echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm + if [ -e "/etc/init.d/mysql" ]; then + echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm + fi fi #DEBHELPER# diff --git a/distros/debian/preinst b/distros/debian/preinst old mode 100755 new mode 100644 diff --git a/distros/debian/rules b/distros/debian/rules index df11f4988..0bf0f3362 100755 --- a/distros/debian/rules +++ b/distros/debian/rules @@ -1,71 +1,42 @@ #!/usr/bin/make -f # -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -CFLAGS = -Wall -g -CPPFLAGS = -D__STDC_CONSTANT_MACROS -CXXFLAGS = -DHAVE_LIBCRYPTO - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -%: - dh $@ --with autoreconf +export CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe +export CXXFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe +INSTDIR = debian/tmp override_dh_auto_configure: - CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --sysconfdir=/etc/zm --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --with-mysql=/usr --with-mariadb=/usr --with-webdir=/usr/share/zoneminder --with-ffmpeg=/usr --with-cgidir=/usr/lib/cgi-bin --with-webuser=www-data --with-webgroup=www-data --enable-crashtrace=no --enable-mmap=yes + dh_auto_configure -- \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_SKIP_RPATH=ON \ + -DCMAKE_VERBOSE_MAKEFILE=OFF \ + -DCMAKE_COLOR_MAKEFILE=ON \ + -DZM_RUNDIR=/var/run/zm \ + -DZM_SOCKDIR=/var/run/zm \ + -DZM_TMPDIR=/var/tmp/zm \ + -DZM_LOGDIR=/var/log/zm \ + -DZM_WEBDIR=/usr/share/zoneminder \ + -DZM_CONTENTDIR=/var/cache/zoneminder \ + -DZM_CGIDIR=/usr/lib/cgi-bin \ + -DZM_WEB_USER=www-data \ + -DZM_WEB_GROUP=www-data \ + -DZM_PERL_SUBPREFIX=/share/perl5 \ + -DCMAKE_INSTALL_SYSCONFDIR=etc/zm -override_dh_clean: - # Add here commands to clean up after the build process. - [ ! -f Makefile ] || $(MAKE) distclean - dh_clean - -override_dh_install: - # Add here commands to install the package into debian/zm. - $(MAKE) install DESTDIR=$(CURDIR)/debian/zoneminder RUNDIR=$(CURDIR)/debian/zoneminder/var/run ZM_RUNDIR=$(CURDIR)/debian/zoneminder/var/run - install -D -m 0644 db/zm_create.sql $(CURDIR)/debian/zoneminder/usr/share/zoneminder/db - install -D -m 0644 db/zm_update-*.sql $(CURDIR)/debian/zoneminder/usr/share/zoneminder/db - install -D -m 0644 debian/apache.conf $(CURDIR)/debian/zoneminder/etc/zm - # - # NOTE: This is a short-term kludge; hopefully changes in the next - # upstream version will render this unnecessary. - rm -rf debian/zoneminder/usr/share/zoneminder/events - rm -rf debian/zoneminder/usr/share/zoneminder/images - rm -rf debian/zoneminder/usr/share/zoneminder/temp - ln -s /var/cache/zoneminder/events debian/zoneminder/usr/share/zoneminder/ - ln -s /var/cache/zoneminder/images debian/zoneminder/usr/share/zoneminder/ - ln -s /var/cache/zoneminder/temp debian/zoneminder/usr/share/zoneminder/ - - # - # This is a slightly lesser kludge; moving the cgi stuff to - # /usr/share/zoneminder/cgi-bin breaks one set of behavior, - # having it just in /usr/lib/cgi-bin breaks another bit of - # behavior. - # - ln -s /usr/lib/cgi-bin debian/zoneminder/usr/share/zoneminder/ - -override_dh_fixperms: - dh_fixperms - chown root:root debian/zoneminder/etc/zm/zm.conf +override_dh_auto_install: + dh_auto_install --buildsystem=cmake + install -D -m 0644 debian/apache.conf $(INSTDIR)/etc/zm/apache.conf + rm $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/LICENSE.txt + rm $(INSTDIR)/usr/share/zoneminder/api/.gitignore + rm -r $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/Test override_dh_auto_test: # do not run tests... -.PHONY: override_dh_strip override_dh_strip: - dh_strip --dbg-package=zoneminder-dbg + dh_strip --dbg-package=zoneminder-dbg + +%: + dh $@ --buildsystem=cmake --parallel From 964cdde2b3460692ea2abcc597004c3a264c13ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Tue, 11 Nov 2014 00:34:23 +0100 Subject: [PATCH 10/18] Use gnutls-openssl instead of gnutls to fix build with CMake. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5608469f..ec4befb07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,7 @@ else(GCRYPT_LIBRARIES) endif(GCRYPT_LIBRARIES) # gnutls (using find_library and find_path) -find_library(GNUTLS_LIBRARIES gnutls) +find_library(GNUTLS_LIBRARIES gnutls-openssl) if(GNUTLS_LIBRARIES) set(HAVE_LIBGNUTLS 1) list(APPEND ZM_BIN_LIBS "${GNUTLS_LIBRARIES}") From 972dedd15a4fca89dde2d6a42e4e5e31325651e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Tue, 11 Nov 2014 22:47:28 +0100 Subject: [PATCH 11/18] * distros/debian -> Autotools * distros/debian_cmake -> CMake --- distros/debian/changelog | 11 ---- distros/debian/control | 16 +++--- distros/debian/copyright | 35 ------------ distros/debian/dirs | 1 + distros/debian/init.d | 9 ++-- distros/debian/postrm | 10 ++-- distros/debian/preinst | 0 distros/debian/rules | 87 ++++++++++++++++++++---------- distros/debian_cmake/README.Debian | 51 ++++++++++++++++++ distros/debian_cmake/apache.conf | 9 ++++ distros/debian_cmake/changelog | 29 ++++++++++ distros/debian_cmake/compat | 1 + distros/debian_cmake/control | 40 ++++++++++++++ distros/debian_cmake/copyright | 57 ++++++++++++++++++++ distros/debian_cmake/dirs | 5 ++ distros/debian_cmake/docs | 1 + distros/debian_cmake/init.d | 87 ++++++++++++++++++++++++++++++ distros/debian_cmake/install | 7 +++ distros/debian_cmake/links | 4 ++ distros/debian_cmake/postinst | 53 ++++++++++++++++++ distros/debian_cmake/postrm | 11 ++++ distros/debian_cmake/preinst | 32 +++++++++++ distros/debian_cmake/rules | 42 +++++++++++++++ distros/debian_cmake/watch | 3 ++ 24 files changed, 509 insertions(+), 92 deletions(-) mode change 100644 => 100755 distros/debian/preinst create mode 100644 distros/debian_cmake/README.Debian create mode 100644 distros/debian_cmake/apache.conf create mode 100644 distros/debian_cmake/changelog create mode 100644 distros/debian_cmake/compat create mode 100644 distros/debian_cmake/control create mode 100644 distros/debian_cmake/copyright create mode 100644 distros/debian_cmake/dirs create mode 100644 distros/debian_cmake/docs create mode 100644 distros/debian_cmake/init.d create mode 100644 distros/debian_cmake/install create mode 100644 distros/debian_cmake/links create mode 100644 distros/debian_cmake/postinst create mode 100644 distros/debian_cmake/postrm create mode 100644 distros/debian_cmake/preinst create mode 100755 distros/debian_cmake/rules create mode 100644 distros/debian_cmake/watch diff --git a/distros/debian/changelog b/distros/debian/changelog index 0edaefce7..ceebf9367 100644 --- a/distros/debian/changelog +++ b/distros/debian/changelog @@ -1,14 +1,3 @@ -zoneminder (1.28.0-0.1) wheezy; urgency=low - - * Use CMake instead of Autotools to simplify - debian/rules and have less build-depends. - * Some lintian love in debian/{control,copyright} - and perl ZoneMinder modules. - * Don't purge database if we use a remote - MySQL server. - - -- Cosme Domínguez Díaz Sun, 09 Nov 2014 02:20:20 +0100 - zoneminder (1.28.0-wheezy) wheezy; urgency=medium * Release diff --git a/distros/debian/control b/distros/debian/control index 01adf14df..1949ef0b9 100644 --- a/distros/debian/control +++ b/distros/debian/control @@ -2,14 +2,14 @@ Source: zoneminder Section: net Priority: optional Maintainer: Isaac Connor -Build-Depends: debhelper (>= 9), cmake, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libsys-mmap-perl, libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev, libpolkit-gobject-1-dev -Standards-Version: 3.9.4 +Build-Depends: debhelper (>= 7.0.50), autoconf, automake, dpatch, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libtool, libsys-mmap-perl, ffmpeg | libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libpcre3, libarchive-zip-perl, libmime-lite-perl, libjpeg8, dh-autoreconf, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev, libpolkit-gobject-1-dev +Standards-Version: 3.9.2 Package: zoneminder Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, apache2 | httpd, libapache2-mod-php5 | libapache2-mod-fcgid | php5-fpm, php5-mysqlnd | php5-mysql, libphp-serialization-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, mariadb-client | mysql-client, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl, libpcre3, libav-tools, rsyslog | system-log-daemon, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl, netpbm, libavdevice53, libjpeg8, zip, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl, libvlccore5 | libvlccore7, libvlc5, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libpolkit-gobject-1-0 -Recommends: mysql-server | mariadb-server -Description: Video camera security and surveillance solution +Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, apache2 | httpd, libapache2-mod-php5 | libapache2-mod-fcgid | php5-fpm, php5, php5-mysql|php5-mysqlnd, libphp-serialization-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, mariadb-client|mysql-client, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl, libpcre3, ffmpeg | libav-tools, rsyslog | system-log-daemon, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl, netpbm, libavdevice53, libjpeg8, zip, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl, libvlccore5 | libvlccore7, libvlc5, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libpolkit-gobject-1-0 +Recommends: mysql-server|mariadb-server +Description: A video camera security and surveillance solution ZoneMinder is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child or family member or home monitoring and other care scenarios. It @@ -23,9 +23,9 @@ Description: Video camera security and surveillance solution Package: zoneminder-dbg Architecture: any -Priority: extra -Section: debug -Depends: zoneminder (= ${binary:Version}), ${misc:Depends} +Depends: + zoneminder (= ${binary:Version}), + ${misc:Depends} Description: debugging syumbols for zoneminder. ZoneMinder is a video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security diff --git a/distros/debian/copyright b/distros/debian/copyright index 1c10c59db..a177502a0 100644 --- a/distros/debian/copyright +++ b/distros/debian/copyright @@ -20,38 +20,3 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian GNU/Linux systems, the text of the GPL can be found in /usr/share/common-licenses/GPL. - -/usr/share/zoneminder/api/lib/Cake/*: -Copyright: - -Copyright (c) 2005-2013, Cake Software Foundation, Inc. - -License: - -CakePHP(tm) : The Rapid Development PHP Framework (http://cakephp.org) - -The MIT License - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -Cake Software Foundation, Inc. -1785 E. Sahara Avenue, -Suite 490-204 -Las Vegas, Nevada 89104, -United States of America. diff --git a/distros/debian/dirs b/distros/debian/dirs index 9e29e6113..4178482c1 100644 --- a/distros/debian/dirs +++ b/distros/debian/dirs @@ -3,3 +3,4 @@ var/lib/zm var/cache/zoneminder/events var/cache/zoneminder/images var/cache/zoneminder/temp +usr/share/zoneminder/db diff --git a/distros/debian/init.d b/distros/debian/init.d index cbc8fb10e..d3354c1d8 100644 --- a/distros/debian/init.d +++ b/distros/debian/init.d @@ -23,10 +23,12 @@ command="$ZM_PATH_BIN/zmpkg.pl" start() { echo -n "Starting $prog: " - mkdir -p $RUNDIR $TMPDIR && chown www-data:www-data $RUNDIR $TMPDIR + mkdir -p $RUNDIR && chown www-data:www-data $RUNDIR + mkdir -p $TMPDIR && chown www-data:www-data $TMPDIR $command start RETVAL=$? - [ $RETVAL = 0 ] && echo success || echo failure + [ $RETVAL = 0 ] && echo success + [ $RETVAL != 0 ] && echo failure echo [ $RETVAL = 0 ] && touch /var/lock/zm return $RETVAL @@ -49,7 +51,8 @@ stop() { else $command stop RETVAL=$? - [ $RETVAL = 0 ] && echo success || echo failure + [ $RETVAL = 0 ] && echo success + [ $RETVAL != 0 ] && echo failure echo [ $RETVAL = 0 ] && rm -f /var/lock/zm fi diff --git a/distros/debian/postrm b/distros/debian/postrm index fde590981..28a00a7a0 100644 --- a/distros/debian/postrm +++ b/distros/debian/postrm @@ -1,11 +1,9 @@ #! /bin/sh -set -e +# set -e # to be reinstated later if [ "$1" = "purge" ]; then - if [ -e "/etc/init.d/mysql" ]; then - echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm - fi + echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm fi #DEBHELPER# diff --git a/distros/debian/preinst b/distros/debian/preinst old mode 100644 new mode 100755 diff --git a/distros/debian/rules b/distros/debian/rules index 0bf0f3362..df11f4988 100755 --- a/distros/debian/rules +++ b/distros/debian/rules @@ -1,42 +1,71 @@ #!/usr/bin/make -f # -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -export CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe -export CXXFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe -INSTDIR = debian/tmp +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +CFLAGS = -Wall -g +CPPFLAGS = -D__STDC_CONSTANT_MACROS +CXXFLAGS = -DHAVE_LIBCRYPTO + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +%: + dh $@ --with autoreconf override_dh_auto_configure: - dh_auto_configure -- \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_SKIP_RPATH=ON \ - -DCMAKE_VERBOSE_MAKEFILE=OFF \ - -DCMAKE_COLOR_MAKEFILE=ON \ - -DZM_RUNDIR=/var/run/zm \ - -DZM_SOCKDIR=/var/run/zm \ - -DZM_TMPDIR=/var/tmp/zm \ - -DZM_LOGDIR=/var/log/zm \ - -DZM_WEBDIR=/usr/share/zoneminder \ - -DZM_CONTENTDIR=/var/cache/zoneminder \ - -DZM_CGIDIR=/usr/lib/cgi-bin \ - -DZM_WEB_USER=www-data \ - -DZM_WEB_GROUP=www-data \ - -DZM_PERL_SUBPREFIX=/share/perl5 \ - -DCMAKE_INSTALL_SYSCONFDIR=etc/zm + CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --sysconfdir=/etc/zm --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --with-mysql=/usr --with-mariadb=/usr --with-webdir=/usr/share/zoneminder --with-ffmpeg=/usr --with-cgidir=/usr/lib/cgi-bin --with-webuser=www-data --with-webgroup=www-data --enable-crashtrace=no --enable-mmap=yes -override_dh_auto_install: - dh_auto_install --buildsystem=cmake - install -D -m 0644 debian/apache.conf $(INSTDIR)/etc/zm/apache.conf - rm $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/LICENSE.txt - rm $(INSTDIR)/usr/share/zoneminder/api/.gitignore - rm -r $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/Test +override_dh_clean: + # Add here commands to clean up after the build process. + [ ! -f Makefile ] || $(MAKE) distclean + dh_clean + +override_dh_install: + # Add here commands to install the package into debian/zm. + $(MAKE) install DESTDIR=$(CURDIR)/debian/zoneminder RUNDIR=$(CURDIR)/debian/zoneminder/var/run ZM_RUNDIR=$(CURDIR)/debian/zoneminder/var/run + install -D -m 0644 db/zm_create.sql $(CURDIR)/debian/zoneminder/usr/share/zoneminder/db + install -D -m 0644 db/zm_update-*.sql $(CURDIR)/debian/zoneminder/usr/share/zoneminder/db + install -D -m 0644 debian/apache.conf $(CURDIR)/debian/zoneminder/etc/zm + # + # NOTE: This is a short-term kludge; hopefully changes in the next + # upstream version will render this unnecessary. + rm -rf debian/zoneminder/usr/share/zoneminder/events + rm -rf debian/zoneminder/usr/share/zoneminder/images + rm -rf debian/zoneminder/usr/share/zoneminder/temp + ln -s /var/cache/zoneminder/events debian/zoneminder/usr/share/zoneminder/ + ln -s /var/cache/zoneminder/images debian/zoneminder/usr/share/zoneminder/ + ln -s /var/cache/zoneminder/temp debian/zoneminder/usr/share/zoneminder/ + + # + # This is a slightly lesser kludge; moving the cgi stuff to + # /usr/share/zoneminder/cgi-bin breaks one set of behavior, + # having it just in /usr/lib/cgi-bin breaks another bit of + # behavior. + # + ln -s /usr/lib/cgi-bin debian/zoneminder/usr/share/zoneminder/ + +override_dh_fixperms: + dh_fixperms + chown root:root debian/zoneminder/etc/zm/zm.conf override_dh_auto_test: # do not run tests... +.PHONY: override_dh_strip override_dh_strip: - dh_strip --dbg-package=zoneminder-dbg - -%: - dh $@ --buildsystem=cmake --parallel + dh_strip --dbg-package=zoneminder-dbg diff --git a/distros/debian_cmake/README.Debian b/distros/debian_cmake/README.Debian new file mode 100644 index 000000000..a49b6be72 --- /dev/null +++ b/distros/debian_cmake/README.Debian @@ -0,0 +1,51 @@ +zoneminder for Debian +--------------------- + +There is one manual step to get the web interface working. +You need to link /etc/zm/apache.conf to /etc/apache2/conf.d/zoneminder.conf, +then reload the apache config (i.e. /etc/init.d/apache2 reload) + +Changing the location for images and events +------------------------------------------- + +Zoneminder, in its upstream form, stores data in /usr/share/zoneminder/. This +package modifies that by changing /usr/share/zoneminder/images and +/usr/share/zoneminder/events to symlinks to directories under +/var/cache/zoneminder. + +There are numerous places these could be put and ways to do it. But, at the +moment, if you change this, an upgrade will fail with a warning about these +locations having changed (the reason for this was that previously, an upgrade +would silently revert the changes and cause event loss - refer +bug #608793). + +If you do want to change the location, here are a couple of suggestions. + +These lines would mount /dev/sdX1 to /video_storage, and then 'link' /video_storage +to the locations that ZoneMinder expects them to be at. + + /dev/sdX1 /video_storage ext4 defaults 0 2 + /video_storage/zoneminder/images /var/cache/zoneminder/images none bind 0 2 + /video_storage/zoneminder/events /var/cache/zoneminder/events none bind 0 2 + + or if you have a separate partition for each: + + /dev/sdX1 /var/cache/zoneminder/images ext4 defaults 0 2 + /dev/sdX2 /var/cache/zoneminder/events ext4 defaults 0 2 + + + + -- Peter Howard , Sun, 16 Jan 2010 01:35:51 +1100 + +Access to /dev/video* +--------------------- + +For cameras which require access to /dev/video*, zoneminder may need the +www-data user added to the video group in order to see those cameras: + + adduser www-data video + +Note that all web applications running on the zoneminder server will then have +access to all video devices on the system. + + -- Vagrant Cascadian Sun, 27 Mar 2011 13:06:56 -0700 diff --git a/distros/debian_cmake/apache.conf b/distros/debian_cmake/apache.conf new file mode 100644 index 000000000..92a2b6414 --- /dev/null +++ b/distros/debian_cmake/apache.conf @@ -0,0 +1,9 @@ +Alias /zm /usr/share/zoneminder + + + php_flag register_globals off + Options Indexes FollowSymLinks + + DirectoryIndex index.php + + diff --git a/distros/debian_cmake/changelog b/distros/debian_cmake/changelog new file mode 100644 index 000000000..0edaefce7 --- /dev/null +++ b/distros/debian_cmake/changelog @@ -0,0 +1,29 @@ +zoneminder (1.28.0-0.1) wheezy; urgency=low + + * Use CMake instead of Autotools to simplify + debian/rules and have less build-depends. + * Some lintian love in debian/{control,copyright} + and perl ZoneMinder modules. + * Don't purge database if we use a remote + MySQL server. + + -- Cosme Domínguez Díaz Sun, 09 Nov 2014 02:20:20 +0100 + +zoneminder (1.28.0-wheezy) wheezy; urgency=medium + + * Release + + -- Isaac Connor Fri, 17 Oct 2014 09:27:22 -0400 + +zoneminder (1.27.99+1-testing-SNAPSHOT2014072901) testing; urgency=medium + + * improve error messages + * Make zmupdate re-run the most recent patch so that people running the daily builds get their db updates + + -- Isaac Connor Tue, 29 Jul 2014 14:50:20 -0400 + +zoneminder (1.27.0+1-testing-v4ltomonitor-1) testing; urgency=high + + * Snapshot release - + + -- Isaac Connor Wed, 09 Jul 2014 21:35:29 -0400 diff --git a/distros/debian_cmake/compat b/distros/debian_cmake/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/distros/debian_cmake/compat @@ -0,0 +1 @@ +9 diff --git a/distros/debian_cmake/control b/distros/debian_cmake/control new file mode 100644 index 000000000..01adf14df --- /dev/null +++ b/distros/debian_cmake/control @@ -0,0 +1,40 @@ +Source: zoneminder +Section: net +Priority: optional +Maintainer: Isaac Connor +Build-Depends: debhelper (>= 9), cmake, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libsys-mmap-perl, libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev, libpolkit-gobject-1-dev +Standards-Version: 3.9.4 + +Package: zoneminder +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, apache2 | httpd, libapache2-mod-php5 | libapache2-mod-fcgid | php5-fpm, php5-mysqlnd | php5-mysql, libphp-serialization-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl, mariadb-client | mysql-client, libwww-perl, libarchive-tar-perl, libarchive-zip-perl, libdevice-serialport-perl, libpcre3, libav-tools, rsyslog | system-log-daemon, libmodule-load-perl, libsys-mmap-perl, libjson-any-perl, netpbm, libavdevice53, libjpeg8, zip, libnet-sftp-foreign-perl, libio-pty-perl, libexpect-perl, libvlccore5 | libvlccore7, libvlc5, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libpolkit-gobject-1-0 +Recommends: mysql-server | mariadb-server +Description: Video camera security and surveillance solution + ZoneMinder is intended for use in single or multi-camera video security + applications, including commercial or home CCTV, theft prevention and child + or family member or home monitoring and other care scenarios. It + supports capture, analysis, recording, and monitoring of video data coming + from one or more video or network cameras attached to a Linux system. + ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom + cameras using a variety of protocols. It is suitable for use as a home + video security system and for commercial or professional video security + and surveillance. It can also be integrated into a home automation system + via X.10 or other protocols. + +Package: zoneminder-dbg +Architecture: any +Priority: extra +Section: debug +Depends: zoneminder (= ${binary:Version}), ${misc:Depends} +Description: debugging syumbols for zoneminder. + ZoneMinder is a video camera security and surveillance solution. + ZoneMinder is intended for use in single or multi-camera video security + applications, including commercial or home CCTV, theft prevention and child + or family member or home monitoring and other care scenarios. It + supports capture, analysis, recording, and monitoring of video data coming + from one or more video or network cameras attached to a Linux system. + ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom + cameras using a variety of protocols. It is suitable for use as a home + video security system and for commercial or professional video security + and surveillance. It can also be integrated into a home automation system + via X.10 or other protocols. diff --git a/distros/debian_cmake/copyright b/distros/debian_cmake/copyright new file mode 100644 index 000000000..1c10c59db --- /dev/null +++ b/distros/debian_cmake/copyright @@ -0,0 +1,57 @@ +Copyright: + +Copyright 2002 Philip Coombes + +License: + +This package 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 package 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 package; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian GNU/Linux systems, the text of the GPL can be found in +/usr/share/common-licenses/GPL. + +/usr/share/zoneminder/api/lib/Cake/*: +Copyright: + +Copyright (c) 2005-2013, Cake Software Foundation, Inc. + +License: + +CakePHP(tm) : The Rapid Development PHP Framework (http://cakephp.org) + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +Cake Software Foundation, Inc. +1785 E. Sahara Avenue, +Suite 490-204 +Las Vegas, Nevada 89104, +United States of America. diff --git a/distros/debian_cmake/dirs b/distros/debian_cmake/dirs new file mode 100644 index 000000000..9e29e6113 --- /dev/null +++ b/distros/debian_cmake/dirs @@ -0,0 +1,5 @@ +var/log/zm +var/lib/zm +var/cache/zoneminder/events +var/cache/zoneminder/images +var/cache/zoneminder/temp diff --git a/distros/debian_cmake/docs b/distros/debian_cmake/docs new file mode 100644 index 000000000..b43bf86b5 --- /dev/null +++ b/distros/debian_cmake/docs @@ -0,0 +1 @@ +README.md diff --git a/distros/debian_cmake/init.d b/distros/debian_cmake/init.d new file mode 100644 index 000000000..cbc8fb10e --- /dev/null +++ b/distros/debian_cmake/init.d @@ -0,0 +1,87 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: zoneminder +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $network $remote_fs $syslog +# Should-Start: mysql +# Should-Stop: mysql +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Control ZoneMinder as a Service +### END INIT INFO +# description: Control ZoneMinder as a Service +# chkconfig: 2345 20 20 + +# Source function library. +#. /etc/rc.d/init.d/functions + +prog=ZoneMinder +ZM_PATH_BIN="/usr/bin" +RUNDIR=/var/run/zm +TMPDIR=/tmp/zm +command="$ZM_PATH_BIN/zmpkg.pl" + +start() { + echo -n "Starting $prog: " + mkdir -p $RUNDIR $TMPDIR && chown www-data:www-data $RUNDIR $TMPDIR + $command start + RETVAL=$? + [ $RETVAL = 0 ] && echo success || echo failure + echo + [ $RETVAL = 0 ] && touch /var/lock/zm + return $RETVAL +} +stop() { + echo -n "Stopping $prog: " + # + # Why is this status check being done? + # as $command stop returns 1 if zoneminder + # is stopped, which will result in + # this returning 1, which will stuff + # dpkg when it tries to stop zoneminder before + # uninstalling . . . + # + result=`$command status` + if [ ! "$result" = "running" ]; then + echo "Zoneminder already stopped" + echo + RETVAL=0 + else + $command stop + RETVAL=$? + [ $RETVAL = 0 ] && echo success || echo failure + echo + [ $RETVAL = 0 ] && rm -f /var/lock/zm + fi +} +status() { + result=`$command status` + if [ "$result" = "running" ]; then + echo "ZoneMinder is running" + RETVAL=0 + else + echo "ZoneMinder is stopped" + RETVAL=1 + fi +} + +case "$1" in +'start') + start + ;; +'stop') + stop + ;; +'restart' | 'force-reload') + stop + start + ;; +'status') + status + ;; +*) + echo "Usage: $0 { start | stop | restart | status }" + RETVAL=1 + ;; +esac +exit $RETVAL diff --git a/distros/debian_cmake/install b/distros/debian_cmake/install new file mode 100644 index 000000000..9e8953409 --- /dev/null +++ b/distros/debian_cmake/install @@ -0,0 +1,7 @@ +usr/bin +usr/lib/cgi-bin +usr/share/man +usr/share/perl5/ZoneMinder +usr/share/perl5/ZoneMinder.pm +usr/share/zoneminder +etc/zm diff --git a/distros/debian_cmake/links b/distros/debian_cmake/links new file mode 100644 index 000000000..9715ee428 --- /dev/null +++ b/distros/debian_cmake/links @@ -0,0 +1,4 @@ +var/cache/zoneminder/events usr/share/zoneminder/events +var/cache/zoneminder/images usr/share/zoneminder/images +var/cache/zoneminder/temp usr/share/zoneminder/temp +usr/lib/cgi-bin usr/share/zoneminder/cgi-bin diff --git a/distros/debian_cmake/postinst b/distros/debian_cmake/postinst new file mode 100644 index 000000000..d06f9c641 --- /dev/null +++ b/distros/debian_cmake/postinst @@ -0,0 +1,53 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + if [ -e "/etc/init.d/mysql" ]; then + # + # Get mysql started if it isn't + # + if ! $(/etc/init.d/mysql status >/dev/null 2>&1); then + invoke-rc.d mysql start + fi + if $(/etc/init.d/mysql status >/dev/null 2>&1); then + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload + # test if database if already present... + if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then + cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf + echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + fi + + invoke-rc.d zoneminder stop || true + zmupdate.pl --nointeractive + + else + echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' + fi + else + echo 'mysql not found, assuming remote server.' + fi + chown www-data:www-data /var/log/zm + chown www-data:www-data /var/lib/zm/ + if [ -z "$2" ]; then + chown www-data:www-data -R /var/cache/zoneminder + fi +fi +# Ensure zoneminder is stopped... +if [ -x "/etc/init.d/zoneminder" ]; then + if invoke-rc.d zoneminder status ; then + invoke-rc.d zoneminder stop || exit $? + fi +fi + +if [ "$1" = "configure" ]; then + if [ -z "$2" ]; then + chown www-data:www-data /var/log/zm + chown www-data:www-data /var/lib/zm/ + chown www-data:www-data -R /var/cache/zoneminder + else + chown www-data:www-data /var/log/zm + zmupdate.pl + fi +fi +#DEBHELPER# diff --git a/distros/debian_cmake/postrm b/distros/debian_cmake/postrm new file mode 100644 index 000000000..fde590981 --- /dev/null +++ b/distros/debian_cmake/postrm @@ -0,0 +1,11 @@ +#! /bin/sh +set -e + +if [ "$1" = "purge" ]; then + if [ -e "/etc/init.d/mysql" ]; then + echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm + fi +fi +#DEBHELPER# diff --git a/distros/debian_cmake/preinst b/distros/debian_cmake/preinst new file mode 100644 index 000000000..6cd01ba55 --- /dev/null +++ b/distros/debian_cmake/preinst @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +abort=false +if [ -L /usr/share/zoneminder/events ]; then + l=$(readlink /usr/share/zoneminder/events) + if [ "$l" != "/var/cache/zoneminder/events" ]; then + abort=true + fi +fi +if [ -L /usr/share/zoneminder/images ]; then + l=$(readlink /usr/share/zoneminder/images ) + if [ "$l" != "/var/cache/zoneminder/images" ]; then + abort=true + fi +fi + +if [ "$abort" = "true" ]; then + cat >&2 << EOF +Aborting installation of zoneminder due to non-default symlinks in +/usr/share/zoneminder for the images and/or events directory, which could +result in loss of data. Please move your data in each of these directories to +/var/cache/zoneminder before installing zoneminder from the package. +EOF + exit 1 + +fi + +#DEBHELPER# + +exit 0 diff --git a/distros/debian_cmake/rules b/distros/debian_cmake/rules new file mode 100755 index 000000000..0bf0f3362 --- /dev/null +++ b/distros/debian_cmake/rules @@ -0,0 +1,42 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +export CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe +export CXXFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -pipe +INSTDIR = debian/tmp + +override_dh_auto_configure: + dh_auto_configure -- \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_SKIP_RPATH=ON \ + -DCMAKE_VERBOSE_MAKEFILE=OFF \ + -DCMAKE_COLOR_MAKEFILE=ON \ + -DZM_RUNDIR=/var/run/zm \ + -DZM_SOCKDIR=/var/run/zm \ + -DZM_TMPDIR=/var/tmp/zm \ + -DZM_LOGDIR=/var/log/zm \ + -DZM_WEBDIR=/usr/share/zoneminder \ + -DZM_CONTENTDIR=/var/cache/zoneminder \ + -DZM_CGIDIR=/usr/lib/cgi-bin \ + -DZM_WEB_USER=www-data \ + -DZM_WEB_GROUP=www-data \ + -DZM_PERL_SUBPREFIX=/share/perl5 \ + -DCMAKE_INSTALL_SYSCONFDIR=etc/zm + +override_dh_auto_install: + dh_auto_install --buildsystem=cmake + install -D -m 0644 debian/apache.conf $(INSTDIR)/etc/zm/apache.conf + rm $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/LICENSE.txt + rm $(INSTDIR)/usr/share/zoneminder/api/.gitignore + rm -r $(INSTDIR)/usr/share/zoneminder/api/lib/Cake/Test + +override_dh_auto_test: + # do not run tests... + +override_dh_strip: + dh_strip --dbg-package=zoneminder-dbg + +%: + dh $@ --buildsystem=cmake --parallel diff --git a/distros/debian_cmake/watch b/distros/debian_cmake/watch new file mode 100644 index 000000000..5a8a9c4d7 --- /dev/null +++ b/distros/debian_cmake/watch @@ -0,0 +1,3 @@ +version=3 +http://www.zoneminder.com/downloads.html \ + .*/ZoneMinder-(.*).tar.gz From 7c8030fccf5c67195243062d77939ff541b7671a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Tue, 11 Nov 2014 23:06:34 +0100 Subject: [PATCH 12/18] Restore README.md to 3fe5724ca009c82b6c1e02c273a3b5948d363af4. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83db14646..da5517f27 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ apache2-mpm-prefork libapache2-mod-php5 php5-cli A fresh build based on master branch running Debian 7 (wheezy): ```bash -root@host:~# aptitude install -y libapache2-mod-php5 mysql-server php5-mysqlnd build-essential cmake debhelper libphp-serialization-perl libgnutls-dev libmysqlclient-dev libdbd-mysql-perl libdate-manip-perl libwww-perl libjpeg8-dev libpcre3-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libbz2-dev libsys-mmap-perl libav-tools libnetpbm10-dev libavdevice-dev libdevice-serialport-perl libarchive-zip-perl libmime-lite-perl libvlccore-dev libvlc-dev libcurl4-gnutls-dev libgcrypt11-dev libpolkit-gobject-1-dev; +root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; root@host:~# cd zoneminder; From 5fe0b84b3caf56508a7366f21b46301ec8b863a9 Mon Sep 17 00:00:00 2001 From: jmcastro2014 Date: Wed, 12 Nov 2014 08:40:35 -0300 Subject: [PATCH 13/18] Create 3S.pm 3S API Control Protocol Module --- .../ZoneMinder/lib/ZoneMinder/Control/3S.pm | 606 ++++++++++++++++++ 1 file changed, 606 insertions(+) create mode 100644 scripts/ZoneMinder/lib/ZoneMinder/Control/3S.pm diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/3S.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/3S.pm new file mode 100644 index 000000000..f825af109 --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/3S.pm @@ -0,0 +1,606 @@ +# ========================================================================== +# +# ZoneMinder 3S API Control Protocol Module, $Date: 2014-11-12 08:00:00 +0300 (Tue, 21 Jun 2011) $, $Revision: 1 $ +# Copyright (C) 2014 Juan Manuel Castro +# +# 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. +# +# ========================================================================== +# +# This module contains the implementation of the 3S camera control +# protocol +#Model: N5071 +#Hardware Version: 00 +#Firmware Version: V1.03_STD-1 +#Firmware Build Time: Jun 19 2012 15:28:17 + +package ZoneMinder::Control::3S; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; +require ZoneMinder::Control; + +our @ISA = qw(ZoneMinder::Control); + +our $VERSION = $ZoneMinder::Base::VERSION; + +# ========================================================================== +# +# 3S Control Protocol +# +# ========================================================================== + +use ZoneMinder::Logger qw(:all); +use ZoneMinder::Config qw(:all); + +use Time::HiRes qw( usleep ); + +sub new +{ + my $class = shift; + my $id = shift; + my $self = ZoneMinder::Control->new( $id ); + bless( $self, $class ); + srand( time() ); + return $self; +} + +our $AUTOLOAD; + +sub AUTOLOAD +{ + my $self = shift; + my $class = ref($self) || croak( "$self not object" ); + my $name = $AUTOLOAD; + $name =~ s/.*://; + if ( exists($self->{$name}) ) + { + return( $self->{$name} ); + } + Fatal( "Can't access $name member of object of class $class" ); +} + +sub open +{ + my $self = shift; + + $self->loadMonitor(); + + use LWP::UserAgent; + $self->{ua} = LWP::UserAgent->new; + #$self->{ua}->agent( "ZoneMinder Control Agent/".ZM_VERSION ); + $self->{ua}->agent( "ZoneMinder Control Agent/" . ZoneMinder::Base::ZM_VERSION ); + $self->{state} = 'open'; +} + +sub close +{ + my $self = shift; + $self->{state} = 'closed'; +} + +sub printMsg +{ + my $self = shift; + my $msg = shift; + my $msg_len = length($msg); + + Debug( $msg."[".$msg_len."]" ); +} + +sub sendCmd +{ + my $self = shift; + my $cmd = shift; + + my $result = undef; + + printMsg( $cmd, "Tx" ); + + #print("http://".$self->{Monitor}->{ControlAddress}."/$cmd"); + my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" ); + my $res = $self->{ua}->request($req); + + if ( $res->is_success ) + { + $result = !undef; + } + else + { + Error( "Error check failed: '".$res->status_line()."'" ); + } + + return( $result ); +} + +sub cameraReset +{ + my $self = shift; + Debug( "Camera Reset" ); + my $cmd = "/restart.cgi"; + $self->sendCmd( $cmd ); +} + +#Custom# +#Move X or Y Axis +sub Up +{ + my $self = shift; + Debug( "Move Up" ); + my $cmd = "/ptz.cgi?move=up"; + $self->sendCmd( $cmd ); +} + +sub Down +{ + my $self = shift; + Debug( "Move Down" ); + my $cmd = "/ptz.cgi?move=down"; + $self->sendCmd( $cmd ); +} + +sub Left +{ + my $self = shift; + Debug( "Move Left" ); + my $cmd = "/ptz.cgi?move=left"; + $self->sendCmd( $cmd ); +} + +sub Right +{ + my $self = shift; + Debug( "Move Right" ); + my $cmd = "/ptz.cgi?move=right"; + $self->sendCmd( $cmd ); +} + +##Zoom +sub Tele +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Zoom Tele" ); + my $cmd = "/ptz.cgi?rzoom=$step"; + $self->sendCmd( $cmd ); +} + +sub Wide +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Zoom Wide" ); + my $cmd = "/ptz.cgi?rzoom=-$step"; + $self->sendCmd( $cmd ); +} + +#Move X and Y Axis +sub UpRight +{ + my $self = shift; + Debug( "Move Up/Right" ); + my $cmd = "/ptz.cgi?move=upright"; + $self->sendCmd( $cmd ); +} + +sub UpLeft +{ + my $self = shift; + Debug( "Move Up/Left" ); + my $cmd = "/ptz.cgi?move=upleft"; + $self->sendCmd( $cmd ); +} + +sub DownRight +{ + my $self = shift; + Debug( "Move Down/Right" ); + my $cmd = "/ptz.cgi?move=downright"; + $self->sendCmd( $cmd ); +} + +sub DownLeft +{ + my $self = shift; + Debug( "Move Down/Left" ); + my $cmd = "/ptz.cgi?move=downleft"; + $self->sendCmd( $cmd ); +} + +#Foco +sub focusAuto +{ + my $self = shift; + Debug( "Focus Auto" ); + my $cmd = "/ptz.cgi?Autofocus=on"; + $self->sendCmd( $cmd ); +} + +sub focusMan +{ + my $self = shift; + Debug( "Focus Manual" ); + my $cmd = "/ptz.cgi?Autofocus=off"; + $self->sendCmd( $cmd ); +} + +sub Near +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Focus Near" ); + my $cmd = "/ptz.cgi?rfocus=-$step"; + $self->sendCmd( $cmd ); +} + +sub Far +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Focus Far" ); + my $cmd = "/ptz.cgi?rfocus=$step"; + $self->sendCmd( $cmd ); +} + +#Iris +sub Open +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Iris Open" ); + my $cmd = "/ptz.cgi?riris=$step"; + $self->sendCmd( $cmd ); +} + +sub Close +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Iris Close" ); + my $cmd = "/ptz.cgi?riris=-$step"; + $self->sendCmd( $cmd ); +} + +#Custom# + +sub moveConUp +{ + my $self = shift; + Debug( "Move Up" ); + my $cmd = "/ptz.cgi?move=up"; + $self->sendCmd( $cmd ); +} + +sub moveConDown +{ + my $self = shift; + Debug( "Move Down" ); + my $cmd = "/ptz.cgi?move=down"; + $self->sendCmd( $cmd ); +} + +sub moveConLeft +{ + my $self = shift; + Debug( "Move Left" ); + my $cmd = "/ptz.cgi?move=left"; + $self->sendCmd( $cmd ); +} + +sub moveConRight +{ + my $self = shift; + Debug( "Move Right" ); + my $cmd = "/ptz.cgi?move=right"; + $self->sendCmd( $cmd ); +} + +sub moveConUpRight +{ + my $self = shift; + Debug( "Move Up/Right" ); + my $cmd = "/ptz.cgi?move=upright"; + $self->sendCmd( $cmd ); +} + +sub moveConUpLeft +{ + my $self = shift; + Debug( "Move Up/Left" ); + my $cmd = "/ptz.cgi?move=upleft"; + $self->sendCmd( $cmd ); +} + +sub moveConDownRight +{ + my $self = shift; + Debug( "Move Down/Right" ); + my $cmd = "/ptz.cgi?move=downright"; + $self->sendCmd( $cmd ); +} + +sub moveConDownLeft +{ + my $self = shift; + Debug( "Move Down/Left" ); + my $cmd = "/ptz.cgi?move=downleft"; + $self->sendCmd( $cmd ); +} + +sub moveRelUp +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Up $step" ); + my $cmd = "/ptz.cgi?tilt=$step"; + $self->sendCmd( $cmd ); +} + +sub moveRelDown +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Down $step" ); + my $cmd = "/ptz.cgi?tilt=-$step"; + $self->sendCmd( $cmd ); +} + +sub moveRelLeft +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'panstep' ); + Debug( "Step Left $step" ); + my $cmd = "/ptz.cgi?pan=-$step"; + $self->sendCmd( $cmd ); +} + +sub moveRelRight +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'panstep' ); + Debug( "Step Right $step" ); + my $cmd = "/ptz.cgi?pan=$step"; + $self->sendCmd( $cmd ); +} + +sub moveRelUpRight +{ + my $self = shift; + my $params = shift; + my $panstep = $self->getParam( $params, 'panstep' ); + my $tiltstep = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Up/Right $tiltstep/$panstep" ); + my $cmd = "/ptz.cgi?pan=$panstep&tilt=$tiltstep"; + $self->sendCmd( $cmd ); +} + +sub moveRelUpLeft +{ + my $self = shift; + my $params = shift; + my $panstep = $self->getParam( $params, 'panstep' ); + my $tiltstep = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Up/Left $tiltstep/$panstep" ); + my $cmd = "/ptz.cgi?pan=-$panstep&tilt=$tiltstep"; + $self->sendCmd( $cmd ); +} + +sub moveRelDownRight +{ + my $self = shift; + my $params = shift; + my $panstep = $self->getParam( $params, 'panstep' ); + my $tiltstep = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Down/Right $tiltstep/$panstep" ); + my $cmd = "/ptz.cgi?pan=$panstep&tilt=-$tiltstep"; + $self->sendCmd( $cmd ); +} + +sub moveRelDownLeft +{ + my $self = shift; + my $params = shift; + my $panstep = $self->getParam( $params, 'panstep' ); + my $tiltstep = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Down/Left $tiltstep/$panstep" ); + my $cmd = "/ptz.cgi?pan=-$panstep&tilt=-$tiltstep"; + $self->sendCmd( $cmd ); +} + +sub zoomRelTele +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Zoom Tele" ); + my $cmd = "/ptz.cgi?rzoom=$step"; + $self->sendCmd( $cmd ); +} + +sub zoomRelWide +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Zoom Wide" ); + my $cmd = "/ptz.cgi?rzoom=-$step"; + $self->sendCmd( $cmd ); +} + +sub focusRelNear +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Focus Near" ); + my $cmd = "/ptz.cgi?rfocus=-$step"; + $self->sendCmd( $cmd ); +} + +sub focusRelFar +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Focus Far" ); + my $cmd = "/ptz.cgi?rfocus=$step"; + $self->sendCmd( $cmd ); +} + +sub focusAuto +{ + my $self = shift; + Debug( "Focus Auto" ); + my $cmd = "/ptz.cgi?Autofocus=on"; + $self->sendCmd( $cmd ); +} + +sub focusMan +{ + my $self = shift; + Debug( "Focus Manual" ); + my $cmd = "/ptz.cgi?Autofocus=off"; + $self->sendCmd( $cmd ); +} + +sub irisRelOpen +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Iris Open" ); + my $cmd = "/ptz.cgi?riris=$step"; + $self->sendCmd( $cmd ); +} + +sub irisRelClose +{ + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'step' ); + Debug( "Iris Close" ); + my $cmd = "/ptz.cgi?riris=-$step"; + $self->sendCmd( $cmd ); +} + +sub irisAuto +{ + my $self = shift; + Debug( "Iris Auto" ); + my $cmd = "/ptz.cgi?autoiris=on"; + $self->sendCmd( $cmd ); +} + +sub irisMan +{ + my $self = shift; + Debug( "Iris Manual" ); + my $cmd = "/ptz.cgi?autoiris=off"; + $self->sendCmd( $cmd ); +} + +sub presetClear +{ + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Debug( "Clear Preset $preset" ); + my $cmd = "/ptz.cgi?removeserverpresetno=$preset"; + $self->sendCmd( $cmd ); +} + +sub presetGoto +{ + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Debug( "Goto Preset $preset" ); + my $cmd = "/ptz.cgi?gotoserverpresetno=$preset"; + $self->sendCmd( $cmd ); +} + +sub presetHome +{ + my $self = shift; + Debug( "Home Preset" ); + my $cmd = "/ptz.cgi?move=home"; + $self->sendCmd( $cmd ); +} + +1; +__END__ +# Below is stub documentation for your module. You'd better edit it! + +=head1 NAME + +ZoneMinder::Database - Perl extension for blah blah blah + +=head1 SYNOPSIS + + use ZoneMinder::Database; + blah blah blah + +=head1 DESCRIPTION + +Stub documentation for ZoneMinder, created by h2xs. It looks like the +author of the extension was negligent enough to leave the stub +unedited. + +Blah blah blah. + +=head2 EXPORT + +None by default. + + + +=head1 SEE ALSO + +Mention other useful documentation such as the documentation of +related modules or operating system documentation (such as man pages +in UNIX), or any relevant external documentation such as RFCs or +standards. + +If you have a mailing list set up for your module, mention it here. + +If you have a web site set up for your module, mention it here. + +=head1 AUTHOR + +Juan Manuel Castro, Ejuanmanuel.castro@gmail.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 Juan Manuel Castro + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.8.3 or, +at your option, any later version of Perl 5 you may have available. + + +=cut From af57c177d7b8757dac87a3317d02b0463f80b516 Mon Sep 17 00:00:00 2001 From: jmcastro2014 Date: Wed, 12 Nov 2014 08:47:35 -0300 Subject: [PATCH 14/18] Update zm_create.sql.in Add Control 3S N5071 Dome Ptz Camera --- db/zm_create.sql.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index c08bf06d8..416e0c513 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -557,7 +557,7 @@ INSERT INTO Controls VALUES (NULL,'Foscam FI9821W','Ffmpeg','FI9821W_Y2k',1,0,1, INSERT INTO Controls VALUES (NULL,'Loftek Sentinel','Remote','LoftekSentinel',0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,255,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,6,1,1,0,0,0,1,10,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0); INSERT INTO Controls VALUES (NULL,'Toshiba IK-WB11A','Remote','Toshiba_IK_WB11A',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,10,0,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0); INSERT INTO Controls VALUES (NULL,'WanscamPT','Remote','Wanscam',1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,16,0,0,0,0,0,1,16,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0); - +INSERT INTO Controls VALUES (NULL,'3S Domo N5071', 'Remote', '3S', 0, 0, 1, 1, 0, 1, 1, 0, 0, 9999, 0, 9999, 0, 0, 0, 1, 1, 1, 1, 0, 0, 9999, 20, 9999, 0, 0, 0, 1, 1, 1, 1, 0, 0, 9999, 1, 9999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 64, 1, 0, 1, 1, 0, 0, 0, 0, 1, -180, 180, 40, 100, 1, 40, 100, 0, 0, 1, -180, 180, 40, 100, 1, 40, 100, 0, 0, 0, 0); -- -- Add some monitor preset values -- From bcbb0c56a6bd63dbb608bc8a94e2e9a9c513a92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Wed, 12 Nov 2014 22:39:54 +0100 Subject: [PATCH 15/18] Apply knnniggett's solution on gnutls-openssl issue which adds support for RPM based distros. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec4befb07..f8c48a83d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,6 +225,10 @@ endif(GCRYPT_LIBRARIES) # gnutls (using find_library and find_path) find_library(GNUTLS_LIBRARIES gnutls-openssl) +if(NOT GNUTLS_LIBRARIES) + find_library(GNUTLS_LIBRARIES gnutls) +endif(NOT GNUTLS_LIBRARIES) + if(GNUTLS_LIBRARIES) set(HAVE_LIBGNUTLS 1) list(APPEND ZM_BIN_LIBS "${GNUTLS_LIBRARIES}") From ebe35c2135abd32be41cfea933170ad0723b3b2f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 13 Nov 2014 09:17:54 -0500 Subject: [PATCH 16/18] handle empty [file] to prevent logzilla --- web/ajax/log.php | 3 ++- web/js/logger.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/web/ajax/log.php b/web/ajax/log.php index e5096b03d..4fb1ebed7 100644 --- a/web/ajax/log.php +++ b/web/ajax/log.php @@ -10,7 +10,8 @@ switch ( $_REQUEST['task'] ) logInit( array( 'id' => "web_js" ) ); $string = $_POST['message']; - $file = preg_replace( '/\w+:\/\/\w+\//', '', $_POST['file'] ); + + $file = !empty($_POST['file']) ? preg_replace( '/\w+:\/\/\w+\//', '', $_POST['file'] ) : ''; if ( !empty( $_POST['line'] ) ) $line = $_POST['line']; else diff --git a/web/js/logger.js b/web/js/logger.js index e7f98c301..1f4eb6752 100644 --- a/web/js/logger.js +++ b/web/js/logger.js @@ -57,8 +57,10 @@ function logReport( level, message, file, line ) requestParms += "&level="+level+"&message="+encodeURIComponent(message); if ( file ) requestParms += "&file="+file; - else + else if ( location.search ) { + //location.search is the querystring part, so ?blah=blah but there is almost never any value to this requestParms += "&file="+location.search; + } if ( line ) requestParms += "&line="+line; debugReq.send( requestParms ); From 9c30b806f2bd6e2a40730ff06417accc26c48090 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 13 Nov 2014 10:38:20 -0500 Subject: [PATCH 17/18] don't require SystemView to view/select groups. Change the way the groups ine is displayed to give people some idea that it might have something to do with grouping use _POST instead of _REQUEST --- web/includes/actions.php | 34 ++++++++++------------------- web/skins/classic/views/console.php | 2 +- web/skins/classic/views/groups.php | 14 ++---------- web/skins/flat/views/console.php | 16 +++++++------- web/skins/flat/views/groups.php | 14 ++---------- 5 files changed, 25 insertions(+), 55 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index b00328d9f..437a4d9fd 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -654,21 +654,14 @@ if ( !empty($action) ) } // System view actions - if ( canView( 'System' ) ) - { - if ( $action == "setgroup" ) - { - if ( !empty($_REQUEST['gid']) ) - { - setcookie( "zmGroup", validInt($_REQUEST['gid']), time()+3600*24*30*12*10 ); - } - else - { - setcookie( "zmGroup", "", time()-3600*24*2 ); - } - $refreshParent = true; - } - } + if ( $action == "setgroup" ) { + if ( !empty($_REQUEST['gid']) ) { + setcookie( "zmGroup", validInt($_REQUEST['gid']), time()+3600*24*30*12*10 ); + } else { + setcookie( "zmGroup", "", time()-3600*24*2 ); + } + $refreshParent = true; + } // System edit actions if ( canEdit( 'System' ) ) @@ -861,13 +854,10 @@ if ( !empty($action) ) } elseif ( $action == "group" ) { - if ( !empty($_REQUEST['gid']) ) - { - dbQuery( "update Groups set Name=?, MonitorIds=? WHERE Id=?", array($_REQUEST['newGroup']['Name'], join(',',$_REQUEST['newGroup']['MonitorIds']), $_REQUEST['gid']) ); - } - else - { - dbQuery( "insert into Groups set Name=?, MonitorIds=?", array( $_REQUEST['newGroup']['Name'], join(',',$_REQUEST['newGroup']['MonitorIds'])) ); + if ( !empty($_POST['gid']) ) { + dbQuery( "UPDATE Groups SET Name=?, MonitorIds=? WHERE Id=?", array($_POST['newGroup']['Name'], $_POST['newGroup']['MonitorIds'], $_POST['gid']) ); + } else { + dbQuery( "INSERT INTO Groups SET Name=?, MonitorIds=?", array( $_POST['newGroup']['Name'], empty($_POST['newGroup']['MonitorIds']) ? array() : $_POST['newGroup']['MonitorIds'] ) ); } $refreshParent = true; $view = 'none'; diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 001d56e2d..ffe6f8821 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -190,7 +190,7 @@ xhtmlHeaders( __FILE__, $SLANG['Console'] );

: / : %

ZoneMinder - - v'.ZM_VERSION.'', canEdit( 'System' ) ) ?>

-
+
onclick="configureButtons( this );"/> - + onclick="configureButtons( this );"/> - +
diff --git a/web/skins/flat/views/console.php b/web/skins/flat/views/console.php index 27228444d..ffe6f8821 100644 --- a/web/skins/flat/views/console.php +++ b/web/skins/flat/views/console.php @@ -73,7 +73,7 @@ $status = $running?$SLANG['Running']:$SLANG['Stopped']; $group = NULL; if ( ! empty($_COOKIE['zmGroup']) ) { - if ( $group = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($_COOKIE['zmGroup']) ) ) + if ( $group = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_COOKIE['zmGroup'])) ) $groupIds = array_flip(explode( ',', $group['MonitorIds'] )); } @@ -85,7 +85,7 @@ $cycleCount = 0; $minSequence = 0; $maxSequence = 1; $seqIdList = array(); -$monitors = dbFetchAll( 'SELECT * FROM Monitors ORDER BY Sequence ASC' ); +$monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); $displayMonitors = array(); for ( $i = 0; $i < count($monitors); $i++ ) { @@ -108,7 +108,7 @@ for ( $i = 0; $i < count($monitors); $i++ ) } $monitors[$i]['zmc'] = zmcStatus( $monitors[$i] ); $monitors[$i]['zma'] = zmaStatus( $monitors[$i] ); - $monitors[$i]['ZoneCount'] = dbFetchOne( 'SELECT count(Id) AS ZoneCount FROM Zones WHERE MonitorId = ?', 'ZoneCount', array( $monitors[$i]['Id'] ) ); + $monitors[$i]['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']) ); $counts = array(); for ( $j = 0; $j < count($eventCounts); $j++ ) { @@ -117,8 +117,8 @@ for ( $i = 0; $i < count($monitors); $i++ ) $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; $monitors[$i]['eventCounts'][$j]['filter'] = $filter; } - $sql = 'SELECT '.join($counts,', ').' FROM Events AS E WHERE MonitorId = ?'; - $counts = dbFetchOne( $sql, NULL, array( $monitors[$i]['Id'] ) ); + $sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?"; + $counts = dbFetchOne( $sql, NULL, array($monitors[$i]['Id']) ); if ( $monitors[$i]['Function'] != 'None' ) { $cycleCount++; @@ -190,7 +190,7 @@ xhtmlHeaders( __FILE__, $SLANG['Console'] );

: / : %

ZoneMinder - - v'.ZM_VERSION.'', canEdit( 'System' ) ) ?>

-
+
  +?> 
@@ -302,7 +302,7 @@ foreach( $displayMonitors as $monitor ) $scale = max( reScale( SCALE_BASE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); ?> - + diff --git a/web/skins/flat/views/groups.php b/web/skins/flat/views/groups.php index 87f8b9ebe..70dc79f9c 100644 --- a/web/skins/flat/views/groups.php +++ b/web/skins/flat/views/groups.php @@ -18,11 +18,6 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -if ( !canView( 'System' ) ) -{ - $view = "error"; - return; -} $sql = "select * from Groups order by Name"; $groups = array(); @@ -66,18 +61,13 @@ xhtmlHeaders(__FILE__, $SLANG['Groups'] ); - + - +
'.$monitor['Function'].( empty($monitor['Enabled']) ? ', disabled' : '' ).'', canEdit( 'Monitors' ) ) ?>'.$SLANG['Fn'.$monitor['Function']].( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit( 'Monitors' ) ) ?> '.$monitor['Device'].' ('.$monitor['Channel'].')', canEdit( 'Monitors' ) ) ?> onclick="configureButtons( this );"/>
onclick="configureButtons( this );"/>
From 72f34203a09949a87b04de183817379e57538831 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 13 Sep 2013 11:04:38 -0400 Subject: [PATCH 18/18] remove the case for level >= 2. Since level is a bool, this code can never execute. Also, there are no calls to tidy in the current code with values other than 0 or 1, so it's safe to do. Also it removes an error message when using clang++ --- src/zm_buffer.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/zm_buffer.h b/src/zm_buffer.h index 3f2343b1a..af043ae13 100644 --- a/src/zm_buffer.h +++ b/src/zm_buffer.h @@ -151,7 +151,7 @@ public: { if ( mSize == 0 ) mHead = mTail = mStorage; - else if ( level >= 1 ) + else if ( level ) { if ( (mHead-mStorage) > mSize ) { @@ -159,12 +159,6 @@ public: mHead = mStorage; mTail = mHead + mSize; } - else if ( level >= 2 ) - { - memmove( mStorage, mHead, mSize ); - mHead = mStorage; - mTail = mHead + mSize; - } } } }