Merge branch 'updated-console' into storageareas

This commit is contained in:
Isaac Connor 2016-05-03 14:34:58 -04:00
commit c3628a8dfd
8 changed files with 1596 additions and 1585 deletions

View File

@ -168,18 +168,18 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint
/* Check the buffer sizes */
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
size_t insize = av_image_get_buffer_size(in_pf, width, height,1);
size_t insize = av_image_get_buffer_size(in_pf, width, height,1);
#else
size_t insize = avpicture_get_size(in_pf, width, height);
size_t insize = avpicture_get_size(in_pf, width, height);
#endif
if(insize != in_buffer_size) {
Error("The input buffer size does not match the expected size for the input format. Required: %d Available: %d", insize, in_buffer_size);
return -4;
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
size_t outsize = av_image_get_buffer_size(out_pf, width, height,1);
size_t outsize = av_image_get_buffer_size(out_pf, width, height,1);
#else
size_t outsize = avpicture_get_size(out_pf, width, height);
size_t outsize = avpicture_get_size(out_pf, width, height);
#endif
if(outsize < out_buffer_size) {
@ -196,37 +196,30 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint
/* Fill in the buffers */
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if(av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
(uint8_t*)in_buffer, in_pf, width, height, 1) <= 0)
{
if(av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
(uint8_t*)in_buffer, in_pf, width, height, 1) <= 0)
{
#else
if(avpicture_fill( (AVPicture*)input_avframe, (uint8_t*)in_buffer,
in_pf, width, height ) <= 0)
{
in_pf, width, height ) <= 0)
{
#endif
Error("Failed filling input frame with input buffer");
return -7;
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if(av_image_fill_arrays(output_avframe->data, output_avframe->linesize,
out_buffer, out_pf, width, height, 1) <= 0)
{
#else
if(avpicture_fill( (AVPicture*)output_avframe, out_buffer,
out_pf, width, height ) <= 0)
{
#endif
Error("Failed filling output frame with output buffer");
return -8;
Error("Failed filling input frame with input buffer");
return -7;
}
/* Do the conversion */
if(!sws_scale(swscale_ctx, input_avframe->data, input_avframe->linesize, 0, height, output_avframe->data, output_avframe->linesize ) ) {
Error("swscale conversion failed");
return -10;
}
if(!avpicture_fill( (AVPicture*)output_avframe, out_buffer, out_pf, width, height ) ) {
Error("Failed filling output frame with output buffer");
return -8;
}
return 0;
/* Do the conversion */
if(!sws_scale(swscale_ctx, input_avframe->data, input_avframe->linesize, 0, height, output_avframe->data, output_avframe->linesize ) ) {
Error("swscale conversion failed");
return -10;
}
return 0;
}
int SWScale::Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {

View File

@ -51,8 +51,6 @@ extern "C" {
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
#include <libavutil/imgutils.h>
#else
#include <libavutil/avutil.h>
#endif
#elif HAVE_FFMPEG_AVUTIL_H
#include <ffmpeg/avutil.h>

View File

@ -182,43 +182,43 @@ int FfmpegCamera::Capture( Image &image )
if ( packet.stream_index == mVideoStreamId )
{
#if LIBAVCODEC_VERSION_CHECK(52, 23, 0, 23, 0)
if ( avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ) < 0 )
if ( avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ) < 0 )
#else
if ( avcodec_decode_video( mCodecContext, mRawFrame, &frameComplete, packet.data, packet.size ) < 0 )
if ( avcodec_decode_video( mCodecContext, mRawFrame, &frameComplete, packet.data, packet.size ) < 0 )
#endif
Fatal( "Unable to decode frame at frame %d", frameCount );
Fatal( "Unable to decode frame at frame %d", frameCount );
Debug( 4, "Decoded video packet at frame %d", frameCount );
Debug( 4, "Decoded video packet at frame %d", frameCount );
if ( frameComplete ) {
Debug( 4, "Got frame %d", frameCount );
if ( frameComplete ) {
Debug( 4, "Got frame %d", frameCount );
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(mFrame->data, mFrame->linesize,
directbuffer, imagePixFormat, width, height, 1);
av_image_fill_arrays(mFrame->data, mFrame->linesize,
directbuffer, imagePixFormat, width, height, 1);
#else
avpicture_fill( (AVPicture *)mFrame, directbuffer,
imagePixFormat, width, height);
avpicture_fill( (AVPicture *)mFrame, directbuffer,
imagePixFormat, width, height);
#endif
#if HAVE_LIBSWSCALE
if(mConvertContext == NULL) {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
if(mConvertContext == NULL) {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
if(mConvertContext == NULL)
Fatal( "Unable to create conversion context for %s", mPath.c_str() );
}
if(mConvertContext == NULL)
Fatal( "Unable to create conversion context for %s", mPath.c_str() );
}
if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 )
Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount );
if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 )
Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount );
#else // HAVE_LIBSWSCALE
Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" );
Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" );
#endif // HAVE_LIBSWSCALE
frameCount++;
} // end if frameComplete
frameCount++;
} // end if frameComplete
} else {
Debug( 4, "Different stream_index %d", packet.stream_index );
Debug( 4, "Different stream_index %d", packet.stream_index );
} // end if packet.stream_index == mVideoStreamId
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( &packet);
@ -399,19 +399,19 @@ int FfmpegCamera::OpenFfmpeg() {
if(mRawFrame == NULL || mFrame == NULL)
Fatal( "Unable to allocate frame for %s", mPath.c_str() );
Debug ( 1, "Allocated frames" );
Debug ( 1, "Allocated frames" );
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
#else
int pSize = avpicture_get_size( imagePixFormat, width, height );
int pSize = avpicture_get_size( imagePixFormat, width, height );
#endif
if( (unsigned int)pSize != imagesize) {
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
}
if( (unsigned int)pSize != imagesize) {
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
}
Debug ( 1, "Validated imagesize %d", pSize );
Debug ( 1, "Validated imagesize" );
#if HAVE_LIBSWSCALE
Debug ( 1, "Calling sws_isSupportedInput" );

File diff suppressed because it is too large Load Diff

View File

@ -328,82 +328,82 @@ void VideoStream::OpenStream( )
#else
opicture = avcodec_alloc_frame( );
#endif
if ( !opicture )
{
Panic( "Could not allocate opicture" );
}
if ( !opicture )
{
Panic( "Could not allocate opicture" );
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int size = av_image_get_buffer_size( c->pix_fmt, c->width,
c->height, 1 );
int size = av_image_get_buffer_size( c->pix_fmt, c->width,
c->height, 1 );
#else
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
#endif
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
if ( !opicture_buf )
{
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
if ( !opicture_buf )
{
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &opicture );
#else
av_freep( &opicture );
#endif
Panic( "Could not allocate opicture_buf" );
}
Panic( "Could not allocate opicture_buf" );
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(opicture->data, opicture->linesize,
opicture_buf, c->pix_fmt, c->width, c->height, 1);
av_image_fill_arrays(opicture->data, opicture->linesize,
opicture_buf, c->pix_fmt, c->width, c->height, 1);
#else
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt,
c->width, c->height );
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt,
c->width, c->height );
#endif
/* if the output format is not identical to the input format, then a temporary
picture is needed too. It is then converted to the required
output format */
tmp_opicture = NULL;
if ( c->pix_fmt != pf )
{
/* if the output format is not identical to the input format, then a temporary
picture is needed too. It is then converted to the required
output format */
tmp_opicture = NULL;
if ( c->pix_fmt != pf )
{
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
tmp_opicture = av_frame_alloc( );
#else
tmp_opicture = avcodec_alloc_frame( );
#endif
if ( !tmp_opicture )
{
Panic( "Could not allocate tmp_opicture" );
}
if ( !tmp_opicture )
{
Panic( "Could not allocate tmp_opicture" );
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int size = av_image_get_buffer_size( pf, c->width,
c->height,1 );
int size = av_image_get_buffer_size( pf, c->width,
c->height,1 );
#else
int size = avpicture_get_size( pf, c->width, c->height );
int size = avpicture_get_size( pf, c->width, c->height );
#endif
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
if ( !tmp_opicture_buf )
{
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
if ( !tmp_opicture_buf )
{
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &tmp_opicture );
av_frame_free( &tmp_opicture );
#else
av_freep( &tmp_opicture );
av_freep( &tmp_opicture );
#endif
Panic( "Could not allocate tmp_opicture_buf" );
}
Panic( "Could not allocate tmp_opicture_buf" );
}
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(tmp_opicture->data,
tmp_opicture->linesize, tmp_opicture_buf, pf,
c->width, c->height, 1);
av_image_fill_arrays(tmp_opicture->data,
tmp_opicture->linesize, tmp_opicture_buf, pf,
c->width, c->height, 1);
#else
avpicture_fill( (AVPicture *)tmp_opicture,
tmp_opicture_buf, pf, c->width, c->height );
avpicture_fill( (AVPicture *)tmp_opicture,
tmp_opicture_buf, pf, c->width, c->height );
#endif
}
}
}
}
/* open the output file, if needed */
if ( !(of->flags & AVFMT_NOFILE) )
{
int ret;
/* open the output file, if needed */
if ( !(of->flags & AVFMT_NOFILE) )
{
int ret;
#if LIBAVFORMAT_VERSION_CHECK(53, 15, 0, 21, 0)
ret = avio_open2( &ofc->pb, filename, AVIO_FLAG_WRITE, NULL, NULL );
#elif LIBAVFORMAT_VERSION_CHECK(52, 102, 0, 102, 0)
@ -700,31 +700,31 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size,
pkt->data = got_packet ? video_outbuf : NULL;
pkt->size = got_packet ? out_size : 0;
#endif
if ( got_packet )
{
// if ( c->coded_frame->key_frame )
// {
if ( got_packet )
{
// if ( c->coded_frame->key_frame )
// {
//#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
// pkt->flags |= AV_PKT_FLAG_KEY;
// pkt->flags |= AV_PKT_FLAG_KEY;
//#else
// pkt->flags |= PKT_FLAG_KEY;
// pkt->flags |= PKT_FLAG_KEY;
//#endif
// }
// }
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
{
pkt->pts = av_rescale_q( pkt->pts, c->time_base, ost->time_base );
}
if ( pkt->dts != (int64_t)AV_NOPTS_VALUE )
{
pkt->dts = av_rescale_q( pkt->dts, c->time_base, ost->time_base );
}
pkt->duration = av_rescale_q( pkt->duration, c->time_base, ost->time_base );
pkt->stream_index = ost->index;
}
}
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
{
pkt->pts = av_rescale_q( pkt->pts, c->time_base, ost->time_base );
}
if ( pkt->dts != (int64_t)AV_NOPTS_VALUE )
{
pkt->dts = av_rescale_q( pkt->dts, c->time_base, ost->time_base );
}
pkt->duration = av_rescale_q( pkt->duration, c->time_base, ost->time_base );
pkt->stream_index = ost->index;
}
}
return ( opicture_ptr->pts);
return ( opicture_ptr->pts);
}
int VideoStream::SendPacket(AVPacket *packet) {

View File

@ -238,13 +238,13 @@ int RemoteCameraRtsp::PrimeCapture()
mFrame = avcodec_alloc_frame();
#endif
if(mRawFrame == NULL || mFrame == NULL)
Fatal( "Unable to allocate frame(s)");
if(mRawFrame == NULL || mFrame == NULL)
Fatal( "Unable to allocate frame(s)");
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int pSize = av_image_get_buffer_size( imagePixFormat, width, height, 1 );
int pSize = av_image_get_buffer_size( imagePixFormat, width, height, 1 );
#else
int pSize = avpicture_get_size( imagePixFormat, width, height );
int pSize = avpicture_get_size( imagePixFormat, width, height );
#endif
if( (unsigned int)pSize != imagesize) {
@ -488,11 +488,11 @@ int RemoteCameraRtsp::CaptureAndRecord( Image &image, bool recording, char* even
Debug( 3, "Got frame %d", frameCount );
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(mFrame->data, mFrame->linesize,
directbuffer, imagePixFormat, width, height, 1);
av_image_fill_arrays(mFrame->data, mFrame->linesize,
directbuffer, imagePixFormat, width, height, 1);
#else
avpicture_fill( (AVPicture *)mFrame, directbuffer,
imagePixFormat, width, height);
avpicture_fill( (AVPicture *)mFrame, directbuffer,
imagePixFormat, width, height);
#endif
//Video recording

View File

@ -1,10 +1,84 @@
<?php
require_once('includes/Server.php');
//
// ZoneMinder web console file, $Date$, $Revision$
// Copyright (C) 2001-2008 Philip Coombes
//
// 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.
//
$servers = Server::find_all();
require_once('includes/Storage.php');
$storage_areas = Storage::find_all();
$show_storage_areas = count($storage_areas) > 1 and canEdit( 'System' ) ? 1 : 0;
$eventCounts = array(
array(
"title" => translate('Events'),
"filter" => array(
"terms" => array(
)
),
),
array(
"title" => translate('Hour'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 hour" ),
)
),
),
array(
"title" => translate('Day'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 day" ),
)
),
),
array(
"title" => translate('Week'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-7 day" ),
)
),
),
array(
"title" => translate('Month'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 month" ),
)
),
),
array(
"title" => translate('Archived'),
"filter" => array(
"terms" => array(
array( "attr" => "Archived", "op" => "=", "val" => "1" ),
)
),
),
);
noCacheHeaders();
$seqUpFile = getSkinFile( 'graphics/seq-u.gif' );
$seqDownFile = getSkinFile( 'graphics/seq-d.gif' );
xhtmlHeaders( __FILE__, translate('Console') );
?>
<body>
@ -54,9 +128,10 @@ if ( canEdit('Monitors') )
if ( $show_storage_areas ) { $columns += 1; }
echo $columns;
?>">
<input type="button" value="<?php echo translate('Refresh') ?>" onclick="location.reload(true);"/>
<input type="button" class="btn btn-primary" name="addBtn" value="<?php echo translate('AddNewMonitor') ?>" onclick="addMonitor( this )"/>
<!-- <?php echo makePopupButton( '?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), (canEdit( 'Monitors' ) && !$user['MonitorIds']) ) ?> -->
<?php echo makePopupButton( '?view=filter&amp;filter[terms][0][attr]=DateTime&amp;filter[terms][0][op]=%3c&amp;filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?>
</td>
<?php
for ( $i = 0; $i < count($eventCounts); $i++ )

View File

@ -21,56 +21,6 @@
require_once('includes/Server.php');
$servers = Server::find_all();
$eventCounts = array(
array(
"title" => translate('Events'),
"filter" => array(
"terms" => array(
)
),
),
array(
"title" => translate('Hour'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 hour" ),
)
),
),
array(
"title" => translate('Day'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 day" ),
)
),
),
array(
"title" => translate('Week'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-7 day" ),
)
),
),
array(
"title" => translate('Month'),
"filter" => array(
"terms" => array(
array( "attr" => "DateTime", "op" => ">=", "val" => "-1 month" ),
)
),
),
array(
"title" => translate('Archived'),
"filter" => array(
"terms" => array(
array( "attr" => "Archived", "op" => "=", "val" => "1" ),
)
),
),
);
$running = daemonCheck();
$states = dbFetchAll( "select * from States" );
$status = $running?translate('Running'):translate('Stopped');
@ -82,8 +32,6 @@ if ( ! empty($_COOKIE['zmGroup']) ) {
$groupIds = array_flip(explode( ',', $group['MonitorIds'] ));
}
noCacheHeaders();
$maxWidth = 0;
$maxHeight = 0;
$cycleCount = 0;
@ -178,9 +126,6 @@ foreach( $displayMonitors as $monitor )
$zoneCount += $monitor['ZoneCount'];
}
$seqUpFile = getSkinFile( 'graphics/seq-u.gif' );
$seqDownFile = getSkinFile( 'graphics/seq-d.gif' );
$versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':'';