Merge branch 'storageareas' into zma_to_thread
commit
0ea6fd9807
|
@ -173,7 +173,7 @@ sub Path {
|
|||
$$event{Path} = join('/',
|
||||
$Storage->Path(),
|
||||
$event->{MonitorId},
|
||||
strftime( '%y-%m-%d', localtime($event->Time())),
|
||||
strftime( '%Y-%m-%d', localtime($event->Time())),
|
||||
$event->{Id},
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -101,7 +101,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
char id_file[PATH_MAX];
|
||||
struct tm *stime = localtime( &start_time.tv_sec );
|
||||
|
||||
if ( storage->Scheme() == Storage::Schemes::DEEP ) {
|
||||
if ( storage->Scheme() == Storage::DEEP ) {
|
||||
char *path_ptr = path;
|
||||
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", storage->Path(), monitor->Id() );
|
||||
|
||||
|
@ -135,10 +135,10 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
|
||||
if ( symlink( time_path, id_file ) < 0 )
|
||||
Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
|
||||
} else if ( storage->Scheme() == Storage::Schemes::MEDIUM ) {
|
||||
} else if ( storage->Scheme() == Storage::MEDIUM ) {
|
||||
char *path_ptr = path;
|
||||
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d/%02d-%02d-%02d",
|
||||
storage->Path(), monitor->Id(), stime->tm_year-100, stime->tm_mon+1, stime->tm_mday
|
||||
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d/%04d-%02d-%02d",
|
||||
storage->Path(), monitor->Id(), stime->tm_year+1900, stime->tm_mon+1, stime->tm_mday
|
||||
);
|
||||
if ( mkdir( path, 0755 ) ) {
|
||||
// FIXME This should not be fatal. Should probably move to a different storage area.
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "zm_stream.h"
|
||||
#include "zm_video.h"
|
||||
#include "zm_packet.h"
|
||||
#include "zm_storage.h"
|
||||
|
||||
class VideoStore;
|
||||
class Zone;
|
||||
|
@ -92,6 +93,7 @@ class Event {
|
|||
bool have_video_keyframe; // a flag to tell us if we have had a video keyframe when writing an mp4. The first frame SHOULD be a video keyframe.
|
||||
|
||||
void createNotes( std::string ¬es );
|
||||
Storage::Schemes scheme;
|
||||
|
||||
public:
|
||||
static bool OpenFrameSocket( int );
|
||||
|
|
|
@ -103,7 +103,7 @@ bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_fra
|
|||
bool EventStream::loadEventData( int event_id ) {
|
||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
|
||||
snprintf( sql, sizeof(sql), "SELECT MonitorId, StorageId, Frames, unix_timestamp( StartTime ) AS StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) AS Duration, DefaultVideo FROM Events WHERE Id = %d", event_id );
|
||||
snprintf( sql, sizeof(sql), "SELECT MonitorId, StorageId, Frames, unix_timestamp( StartTime ) AS StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) AS Duration, DefaultVideo, Scheme FROM Events WHERE Id = %d", event_id );
|
||||
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
|
@ -137,18 +137,35 @@ bool EventStream::loadEventData( int event_id ) {
|
|||
event_data->start_time = atoi(dbrow[3]);
|
||||
event_data->duration = atof(dbrow[4]);
|
||||
strncpy( event_data->video_file, dbrow[5], sizeof(event_data->video_file)-1 );
|
||||
std::string scheme_str = std::string(dbrow[6]);
|
||||
if ( scheme_str == "Deep" ) {
|
||||
event_data->scheme = Storage::DEEP;
|
||||
} else if ( scheme_str == "Medium" ) {
|
||||
event_data->scheme = Storage::MEDIUM;
|
||||
} else {
|
||||
event_data->scheme = Storage::SHALLOW;
|
||||
}
|
||||
mysql_free_result( result );
|
||||
|
||||
Storage * storage = new Storage( event_data->storage_id );
|
||||
const char *storage_path = storage->Path();
|
||||
|
||||
if ( config.use_deep_storage ) {
|
||||
if ( event_data->scheme == Storage::DEEP ) {
|
||||
struct tm *event_time = localtime( &event_data->start_time );
|
||||
|
||||
if ( storage_path[0] == '/' )
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
||||
else
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
||||
} else if ( event_data->scheme == Storage::MEDIUM ) {
|
||||
struct tm *event_time = localtime( &event_data->start_time );
|
||||
if ( storage_path[0] == '/' )
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%04d-%02d-%02d/%ld",
|
||||
storage_path, event_data->monitor_id, event_time->tm_year+1900, event_time->tm_mon+1, event_time->tm_mday, event_data->event_id );
|
||||
else
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%04d-%02d-%02d/%ld",
|
||||
staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_time->tm_year+1900, event_time->tm_mon+1, event_time->tm_mday,
|
||||
event_data->event_id );
|
||||
|
||||
} else {
|
||||
if ( storage_path[0] == '/' )
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "zm_video.h"
|
||||
#include "zm_ffmpeg_input.h"
|
||||
#include "zm_monitor.h"
|
||||
#include "zm_storage.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -63,6 +64,7 @@ class EventStream : public StreamBase {
|
|||
int n_frames;
|
||||
FrameData *frames;
|
||||
char video_file[PATH_MAX];
|
||||
Storage::Schemes scheme;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
|
@ -434,7 +434,7 @@ int zm_receive_frame( AVCodecContext *context, AVFrame *frame, AVPacket &packet
|
|||
#endif
|
||||
return 1;
|
||||
} // end int zm_receive_frame( AVCodecContext *context, AVFrame *frame, AVPacket &packet )
|
||||
void dumpPacket(AVPacket *pkt) {
|
||||
void dumpPacket(AVPacket *pkt, const char *text) {
|
||||
char b[10240];
|
||||
|
||||
snprintf(b, sizeof(b),
|
||||
|
@ -456,5 +456,5 @@ void dumpPacket(AVPacket *pkt) {
|
|||
pkt->flags & AV_PKT_FLAG_KEY,
|
||||
pkt->pos,
|
||||
pkt->duration);
|
||||
Debug(1, "%s:%d:DEBUG: %s", __FILE__, __LINE__, b);
|
||||
Debug(1, "%s:%d:%s: %s", __FILE__, __LINE__, text, b);
|
||||
}
|
||||
|
|
|
@ -327,5 +327,5 @@ int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt);
|
|||
bool is_video_stream( AVStream * stream );
|
||||
bool is_audio_stream( AVStream * stream );
|
||||
int zm_receive_frame( AVCodecContext *context, AVFrame *frame, AVPacket &packet );
|
||||
void dumpPacket(AVPacket *);
|
||||
void dumpPacket(AVPacket *,const char *text="DEBUG");
|
||||
#endif // ZM_FFMPEG_H
|
||||
|
|
|
@ -175,7 +175,11 @@ int FfmpegCamera::Capture( ZMPacket &zm_packet ) {
|
|||
Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, ret, av_make_error_string(ret).c_str() );
|
||||
return -1;
|
||||
}
|
||||
Debug( 5, "Got packet from stream %d dts (%d) pts(%d)", packet.stream_index, packet.pts, packet.dts );
|
||||
dumpPacket(&packet, "ffmpeg_camera in");
|
||||
if ( 0 && ( packet.dts < 0 ) ) {
|
||||
zm_av_packet_unref( &packet );
|
||||
return 0;
|
||||
}
|
||||
|
||||
zm_packet.set_packet( &packet );
|
||||
zm_av_packet_unref( &packet );
|
||||
|
|
|
@ -2777,7 +2777,7 @@ int Monitor::Capture() {
|
|||
shared_data->last_read_index = image_buffer_count;
|
||||
}
|
||||
} else {
|
||||
Debug(2,"Current write index %d, last read index %d, current (%d)", shared_data->last_write_index, shared_data->last_read_index, index );
|
||||
Debug(2,"Capture: Current write index %d, last read index %d, current (%d)", shared_data->last_write_index, shared_data->last_read_index, index );
|
||||
}
|
||||
|
||||
ZMPacket *packet = &image_buffer[index];
|
||||
|
@ -2933,6 +2933,8 @@ int Monitor::Capture() {
|
|||
} // end if report fps
|
||||
} else { // result == 0
|
||||
// Question is, do we update last_write_index etc?
|
||||
packet->unlock();
|
||||
return 0;
|
||||
|
||||
} // end if result
|
||||
} // end if deinterlacing
|
||||
|
|
|
@ -195,7 +195,7 @@ AVPacket *ZMPacket::set_packet( AVPacket *p ) {
|
|||
if ( zm_av_packet_ref( &packet, p ) < 0 ) {
|
||||
Error("error refing packet");
|
||||
}
|
||||
dumpPacket(&packet);
|
||||
dumpPacket(&packet, "zmpacket:");
|
||||
gettimeofday( timestamp, NULL );
|
||||
keyframe = p->flags & AV_PKT_FLAG_KEY;
|
||||
return &packet;
|
||||
|
|
|
@ -36,8 +36,8 @@ Storage::Storage() {
|
|||
} else {
|
||||
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path)-1 );
|
||||
}
|
||||
scheme = Schemes::SHALLOW;
|
||||
scheme_str = "Shallow";
|
||||
scheme = DEEP;
|
||||
scheme_str = "Deep";
|
||||
}
|
||||
|
||||
Storage::Storage( MYSQL_ROW &dbrow ) {
|
||||
|
@ -48,11 +48,11 @@ Storage::Storage( MYSQL_ROW &dbrow ) {
|
|||
type_str = std::string(dbrow[index++]);
|
||||
scheme_str = std::string(dbrow[index++]);
|
||||
if ( scheme_str == "Deep" ) {
|
||||
scheme = Schemes::DEEP;
|
||||
scheme = DEEP;
|
||||
} else if ( scheme_str == "Medium" ) {
|
||||
scheme = Schemes::MEDIUM;
|
||||
scheme = MEDIUM;
|
||||
} else {
|
||||
scheme = Schemes::SHALLOW;
|
||||
scheme = SHALLOW;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,11 @@ Storage::Storage( unsigned int p_id ) {
|
|||
type_str = std::string(dbrow[index++]);
|
||||
scheme_str = std::string(dbrow[index++]);
|
||||
if ( scheme_str == "Deep" ) {
|
||||
scheme = Schemes::DEEP;
|
||||
scheme = DEEP;
|
||||
} else if ( scheme_str == "Medium" ) {
|
||||
scheme = Schemes::MEDIUM;
|
||||
scheme = MEDIUM;
|
||||
} else {
|
||||
scheme = Schemes::SHALLOW;
|
||||
scheme = SHALLOW;
|
||||
}
|
||||
Debug( 1, "Loaded Storage area %d '%s'", id, this->Name() );
|
||||
}
|
||||
|
|
|
@ -1075,6 +1075,11 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
// Need to adjust pts/dts values from codec time to stream time
|
||||
if ( opkt.pts != AV_NOPTS_VALUE)
|
||||
opkt.pts = av_rescale_q(opkt.pts, video_out_ctx->time_base, video_out_stream->time_base);
|
||||
if ( opkt.dts != AV_NOPTS_VALUE)
|
||||
opkt.dts = av_rescale_q(opkt.dts, video_out_ctx->time_base, video_out_stream->time_base);
|
||||
|
||||
} else {
|
||||
AVPacket *ipkt = &zm_packet->packet;
|
||||
|
@ -1085,12 +1090,21 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
opkt.size = ipkt->size;
|
||||
opkt.flags = ipkt->flags;
|
||||
if ( ! video_start_pts ) {
|
||||
video_start_pts = ipkt->pts;
|
||||
// If video has b-frames, pts can be AV_NOPTS_VALUE so use dts intead
|
||||
video_start_pts = ipkt->dts;
|
||||
Debug(2, "No video_lsat_pts, set to (%" PRId64 ")", video_start_pts );
|
||||
opkt.dts = opkt.pts = 0;
|
||||
} else {
|
||||
dumpPacket(ipkt);
|
||||
opkt.dts = opkt.pts = av_rescale_q( ipkt->pts - video_start_pts, video_in_stream->time_base, video_out_stream->time_base );
|
||||
if ( ipkt->pts != AV_NOPTS_VALUE )
|
||||
opkt.pts = av_rescale_q( ipkt->pts - video_start_pts, video_in_stream->time_base, video_out_stream->time_base );
|
||||
else
|
||||
opkt.pts = 0;
|
||||
|
||||
if ( ipkt->dts != AV_NOPTS_VALUE )
|
||||
opkt.dts = av_rescale_q( ipkt->dts - video_start_pts, video_in_stream->time_base, video_out_stream->time_base );
|
||||
else
|
||||
opkt.dts = 0;
|
||||
Debug(2, "out_stream_time_base(%d/%d) in_stream_time_base(%d/%d) video_start_pts(%" PRId64 ")",
|
||||
video_out_stream->time_base.num, video_out_stream->time_base.den,
|
||||
video_in_stream->time_base.num, video_in_stream->time_base.den,
|
||||
|
|
|
@ -90,7 +90,7 @@ class Event {
|
|||
if ( $this->{'Scheme'} == 'Deep' ) {
|
||||
$event_path = $this->{'MonitorId'} .'/'.strftime( '%y/%m/%d/%H/%M/%S', $this->Time()) ;
|
||||
} else if ( $this->{'Scheme'} == 'Medium' ) {
|
||||
$event_path = $this->{'MonitorId'} .'/'.strftime( '%y-%m-%d', $this->Time() ) . '/'.$this->{'Id'};
|
||||
$event_path = $this->{'MonitorId'} .'/'.strftime( '%Y-%m-%d', $this->Time() ) . '/'.$this->{'Id'};
|
||||
} else {
|
||||
$event_path = $this->{'MonitorId'} .'/'.$this->{'Id'};
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ function userLogin( $username, $password='', $passwordHashed=false ) {
|
|||
$_SESSION['loginFailed'] = true;
|
||||
unset( $user );
|
||||
}
|
||||
if ( $cookies )
|
||||
session_write_close();
|
||||
//if ( $cookies )
|
||||
//session_write_close();
|
||||
}
|
||||
|
||||
function userLogout() {
|
||||
|
|
|
@ -122,8 +122,8 @@ function parseRows (rows) {
|
|||
obrSelect.append('<option value="' + i + '">' + '('.repeat(i) + '</option>');
|
||||
cbrSelect.append('<option value="' + i + '">' + ')'.repeat(i) + '</option>');
|
||||
}
|
||||
let obrVal = inputTds.eq(1).children().val(); //Save currently selected bracket option
|
||||
let cbrVal = inputTds.eq(5).children().val();
|
||||
let obrVal = inputTds.eq(1).children().val() != undefined ? inputTds.eq(1).children().val() : 0; //Save currently selected bracket option
|
||||
let cbrVal = inputTds.eq(5).children().val() != undefined ? inputTds.eq(5).children().val() : 0;
|
||||
inputTds.eq(1).html(obrSelect).children().val(obrVal); //Set bracket contents and assign saved value
|
||||
inputTds.eq(5).html(cbrSelect).children().val(cbrVal);
|
||||
} else {
|
||||
|
|
|
@ -765,6 +765,27 @@ function initPage() {
|
|||
//setFit(fitMode); // will redraw
|
||||
//setLive(liveMode); // will redraw
|
||||
redrawScreen();
|
||||
$j('#minTime').datetimepicker({
|
||||
timeFormat: "HH:mm:ss",
|
||||
dateFormat: "yy-mm-dd",
|
||||
maxDate: +0,
|
||||
onClose: function (newDate, oldData) {
|
||||
if (newDate !== oldData.lastVal) {
|
||||
changeDateTime();
|
||||
}
|
||||
}
|
||||
});
|
||||
$j('#maxTime').datetimepicker({
|
||||
timeFormat: "HH:mm:ss",
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: $j('#minTime').val(),
|
||||
maxDate: +0,
|
||||
onClose: function (newDate, oldData) {
|
||||
if (newDate !== oldData.lastVal) {
|
||||
changeDateTime();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener("resize",redrawScreen);
|
||||
// Kick everything off
|
||||
|
|
|
@ -219,8 +219,8 @@ xhtmlHeaders(__FILE__, translate('MontageReview') );
|
|||
<div id="header">
|
||||
<?php echo $filter_bar ?>
|
||||
<div id="DateTimeDiv">
|
||||
<input type="datetime-local" name="minTime" id="minTime" value="<?php echo preg_replace('/ /', 'T', $minTime ) ?>" onchange="changeDateTime(this);"> to
|
||||
<input type="datetime-local" name="maxTime" id="maxTime" value="<?php echo preg_replace('/ /', 'T', $maxTime ) ?>" onchange="changeDateTime(this);">
|
||||
<input type="text" name="minTime" id="minTime" value="<?php echo preg_replace('/T/', ' ', $minTime ) ?>"> to
|
||||
<input type="text" name="maxTime" id="maxTime" value="<?php echo preg_replace('/T/', ' ', $maxTime ) ?>">
|
||||
</div>
|
||||
<div id="ScaleDiv">
|
||||
<label for="scaleslider"><?php echo translate('Scale')?></label>
|
||||
|
|
Loading…
Reference in New Issue