redo fix_rotate

This commit is contained in:
Isaac Connor 2016-04-25 15:57:39 -04:00
commit 851e8f46ff
6 changed files with 33 additions and 64 deletions

View File

@ -286,8 +286,8 @@ Monitor::Monitor(
storage_id( p_storage_id ), storage_id( p_storage_id ),
function( (Function)p_function ), function( (Function)p_function ),
enabled( p_enabled ), enabled( p_enabled ),
width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ),
height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ),
orientation( (Orientation)p_orientation ), orientation( (Orientation)p_orientation ),
deinterlacing( p_deinterlacing ), deinterlacing( p_deinterlacing ),
savejpegspref( p_savejpegs ), savejpegspref( p_savejpegs ),
@ -2182,9 +2182,6 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
col++; col++;
bool embed_exif = (*dbrow[col] != '0'); col++; bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
int extras = (deinterlacing>>24)&0xff; int extras = (deinterlacing>>24)&0xff;
Camera *camera = new LocalCamera( Camera *camera = new LocalCamera(
@ -2195,8 +2192,8 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
v4l_multi_buffer, v4l_multi_buffer,
v4l_captures_per_frame, v4l_captures_per_frame,
method, method,
cam_width, width,
cam_height, height,
colours, colours,
palette, palette,
brightness, brightness,
@ -2349,9 +2346,6 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
int track_motion = atoi(dbrow[col]); col++; int track_motion = atoi(dbrow[col]); col++;
bool embed_exif = (*dbrow[col] != '0'); col++; bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
Camera *camera = 0; Camera *camera = 0;
if ( protocol == "http" ) { if ( protocol == "http" ) {
camera = new RemoteCameraHttp( camera = new RemoteCameraHttp(
@ -2360,8 +2354,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
host, // Host host, // Host
port, // Port port, // Port
path, // Path path, // Path
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2379,8 +2373,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
host, // Host host, // Host
port, // Port port, // Port
path, // Path path, // Path
cam_width, width,
cam_height, height,
rtsp_describe, rtsp_describe,
colours, colours,
brightness, brightness,
@ -2531,14 +2525,11 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
int track_motion = atoi(dbrow[col]); col++; int track_motion = atoi(dbrow[col]); col++;
bool embed_exif = (*dbrow[col] != '0'); col++; bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
Camera *camera = new FileCamera( Camera *camera = new FileCamera(
id, id,
path, // File path, // File
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2688,16 +2679,13 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
int track_motion = atoi(dbrow[col]); col++; int track_motion = atoi(dbrow[col]); col++;
bool embed_exif = (*dbrow[col] != '0'); col++; bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
Camera *camera = new FfmpegCamera( Camera *camera = new FfmpegCamera(
id, id,
path, // File path, // File
method, method,
options, options,
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2869,9 +2857,6 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
col++; col++;
bool embed_exif = (*dbrow[col] != '0'); col++; bool embed_exif = (*dbrow[col] != '0'); col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
int extras = (deinterlacing>>24)&0xff; int extras = (deinterlacing>>24)&0xff;
Camera *camera = 0; Camera *camera = 0;
@ -2885,8 +2870,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
v4l_multi_buffer, v4l_multi_buffer,
v4l_captures_per_frame, v4l_captures_per_frame,
method, method,
cam_width, width,
cam_height, height,
colours, colours,
palette, palette,
brightness, brightness,
@ -2908,8 +2893,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
host.c_str(), host.c_str(),
port.c_str(), port.c_str(),
path.c_str(), path.c_str(),
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2926,8 +2911,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
host.c_str(), host.c_str(),
port.c_str(), port.c_str(),
path.c_str(), path.c_str(),
cam_width, width,
cam_height, height,
rtsp_describe, rtsp_describe,
colours, colours,
brightness, brightness,
@ -2947,8 +2932,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
camera = new FileCamera( camera = new FileCamera(
id, id,
path.c_str(), path.c_str(),
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2964,8 +2949,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
path.c_str(), path.c_str(),
method, method,
options, options,
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -2984,8 +2969,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
path.c_str(), path.c_str(),
method, method,
options, options,
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,
@ -3004,8 +2989,8 @@ Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
path.c_str(), path.c_str(),
user.c_str(), user.c_str(),
pass.c_str(), pass.c_str(),
cam_width, width,
cam_height, height,
colours, colours,
brightness, brightness,
contrast, contrast,

View File

@ -417,8 +417,8 @@ public:
return( embed_exif ); return( embed_exif );
} }
unsigned int Width() const { return( width ); } unsigned int Width() const { return ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); }
unsigned int Height() const { return( height ); } unsigned int Height() const { return ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); }
unsigned int Colours() const { return( camera->Colours() ); } unsigned int Colours() const { return( camera->Colours() ); }
unsigned int SubpixelOrder() const { return( camera->SubpixelOrder() ); } unsigned int SubpixelOrder() const { return( camera->SubpixelOrder() ); }

View File

@ -304,24 +304,6 @@ int RemoteCameraRtsp::Capture( Image &image ) {
if ( !buffer.size() ) if ( !buffer.size() )
return( -1 ); return( -1 );
int avResult = av_read_frame( mFormatContext, &packet );
if ( avResult < 0 ) {
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 \"%s\". Reopening stream.", errbuf);
//ReopenFfmpeg();
}
Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, avResult, errbuf );
return( -1 );
}
if(mCodecContext->codec_id == AV_CODEC_ID_H264) { if(mCodecContext->codec_id == AV_CODEC_ID_H264) {
// SPS and PPS frames should be saved and appended to IDR frames // SPS and PPS frames should be saved and appended to IDR frames
int nalType = (buffer.head()[3] & 0x1f); int nalType = (buffer.head()[3] & 0x1f);
@ -344,6 +326,8 @@ int avResult = av_read_frame( mFormatContext, &packet );
buffer += lastSps; buffer += lastSps;
buffer += lastPps; buffer += lastPps;
} }
} else {
Debug(3, "Not an h264 packet");
} }
av_init_packet( &packet ); av_init_packet( &packet );

View File

@ -48,7 +48,7 @@ var popupSizes = {
'log': { 'width': 1080, 'height': 720 }, 'log': { 'width': 1080, 'height': 720 },
'login': { 'width': 720, 'height': 480 }, 'login': { 'width': 720, 'height': 480 },
'logout': { 'width': 260, 'height': 100 }, 'logout': { 'width': 260, 'height': 100 },
'monitor': { 'width': 450, 'height': 440 }, 'monitor': { 'width': 700, 'height': 640 },
'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorpreset':{ 'width': 440, 'height': 200 },
'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorprobe': { 'width': 500, 'height': 240 },
'monitorselect':{ 'width': 160, 'height': 200 }, 'monitorselect':{ 'width': 160, 'height': 200 },

View File

@ -48,7 +48,7 @@ var popupSizes = {
'log': { 'width': 1080, 'height': 720 }, 'log': { 'width': 1080, 'height': 720 },
'login': { 'width': 720, 'height': 480 }, 'login': { 'width': 720, 'height': 480 },
'logout': { 'width': 260, 'height': 150 }, 'logout': { 'width': 260, 'height': 150 },
'monitor': { 'width': 600, 'height': 780 }, 'monitor': { 'width': 800, 'height': 780 },
'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorpreset':{ 'width': 440, 'height': 200 },
'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorprobe': { 'width': 500, 'height': 240 },
'monitorselect':{ 'width': 160, 'height': 200 }, 'monitorselect':{ 'width': 160, 'height': 200 },

View File

@ -27,7 +27,7 @@ if ( !canView( 'Events' ) )
$eid = validInt( $_REQUEST['eid'] ); $eid = validInt( $_REQUEST['eid'] );
$fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1; $fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1;
$sql = 'SELECT E.*,M.Name AS MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale,M.VideoWriter,M.SaveJPEGs,M.Orientation,M.LabelFormat FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'; $sql = 'SELECT E.*,M.Name AS MonitorName,E.Width,E.Height,M.DefaultRate,M.DefaultScale,M.VideoWriter,M.SaveJPEGs,M.Orientation,M.LabelFormat FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?';
$sql_values = array( $eid ); $sql_values = array( $eid );
if ( $user['MonitorIds'] ) { if ( $user['MonitorIds'] ) {