wip
This commit is contained in:
parent
392e6c28a1
commit
4a9c31a15d
|
@ -1243,17 +1243,14 @@ bool Monitor::Analyse() {
|
|||
Warning("SHouldn't be doing Analyze when not Enabled");
|
||||
return false;
|
||||
}
|
||||
GetLastEventId();
|
||||
|
||||
// if have event, sent frames until we find a video packet, at which point do analysis. Adaptive skip should only affect which frames we do analysis on.
|
||||
|
||||
// If do have an event, then analysis_it should point to the head of the queue, because we would have emptied it on event creation.
|
||||
unsigned int index = ( shared_data->last_read_index + 1 ) % image_buffer_count;
|
||||
|
||||
int packets_processed = 0;
|
||||
|
||||
ZMPacket *snap;
|
||||
while ( ( snap = packetqueue->get_analysis_packet() ) && ( snap->score == -1 ) ) {
|
||||
unsigned int index = snap->image_index;
|
||||
Debug(2, "Analysis index (%d), last_Write(%d)", index, shared_data->last_write_index);
|
||||
packets_processed += 1;
|
||||
|
||||
|
@ -1411,8 +1408,12 @@ bool Monitor::Analyse() {
|
|||
Info( "%s: %03d - Gone into alarm state", name, analysis_image_count );
|
||||
shared_data->state = state = ALARM;
|
||||
if ( (function != MOCORD && state != ALERT) ) {
|
||||
if ( event ) {
|
||||
Error("Already ahve evnet!");
|
||||
} else {
|
||||
event = new Event( this, *timestamp, cause, noteSetMap );
|
||||
shared_data->last_event_id = event->Id();
|
||||
}
|
||||
}
|
||||
} else if ( state != PREALARM ) {
|
||||
Info( "%s: %03d - Gone into prealarm state", name, analysis_image_count );
|
||||
|
@ -1510,24 +1511,32 @@ bool Monitor::Analyse() {
|
|||
} // end if ( trigger_data->trigger_state != TRIGGER_OFF )
|
||||
|
||||
if ( event ) {
|
||||
int last_write = shared_data->last_write_index;
|
||||
int written = 0;
|
||||
ZMPacket *queued_packet;
|
||||
//popPacket will increment analysis_it if neccessary, so this will write out all packets in queue
|
||||
// We can't just loop here forever, because we may be capturing just as fast, and never leave the loop.
|
||||
// Only loop until we hit the analysis index
|
||||
while ( ( queued_packet = packetqueue->popPacket() ) ) {
|
||||
Debug(2,"adding packet (%x) (%d)", queued_packet, queued_packet->image_index );
|
||||
Debug(2,"adding packet (%d) qp lwindex(%d), written(%d)", queued_packet->image_index, last_write, written );
|
||||
event->AddPacket( queued_packet );
|
||||
written ++;
|
||||
if ( queued_packet->image_index == -1 ) {
|
||||
delete queued_packet;
|
||||
queued_packet = NULL;
|
||||
} else if ( snap == queued_packet ) {
|
||||
packetqueue->increment_analysis_it();
|
||||
break;
|
||||
}
|
||||
// encoding can take a long time, so
|
||||
shared_data->last_read_time = time(NULL);
|
||||
} // end while write out queued_packets
|
||||
queued_packet = NULL;
|
||||
} else {
|
||||
packetqueue->increment_analysis_it();
|
||||
}
|
||||
|
||||
shared_data->last_read_index = snap->image_index;
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
shared_data->last_read_time = now.tv_sec;
|
||||
shared_data->last_read_time = time(NULL);
|
||||
analysis_image_count++;
|
||||
} // end while not at end of packetqueue
|
||||
if ( packets_processed > 0 )
|
||||
|
@ -2760,7 +2769,6 @@ int Monitor::Capture() {
|
|||
}
|
||||
|
||||
ZMPacket *packet = &image_buffer[index];
|
||||
Debug(2,"Reset index(%d) of (%d)", index, image_buffer_count );
|
||||
packet->reset();
|
||||
Image* capture_image = packet->image;
|
||||
int captureResult = 0;
|
||||
|
@ -2781,7 +2789,6 @@ int Monitor::Capture() {
|
|||
}
|
||||
} else {
|
||||
captureResult = camera->Capture(*packet);
|
||||
Debug(2, "Reset timestamp");
|
||||
gettimeofday( packet->timestamp, NULL );
|
||||
if ( captureResult < 0 ) {
|
||||
// Unable to capture image for temporary reason
|
||||
|
@ -2814,7 +2821,6 @@ int Monitor::Capture() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
Debug(2, "Have video packet");
|
||||
packet->codec_type = camera->get_VideoStream()->codecpar->codec_type;
|
||||
|
||||
if ( packet->packet.size && ! packet->in_frame ) {
|
||||
|
@ -2826,8 +2832,11 @@ int Monitor::Capture() {
|
|||
// Have an av_packet,
|
||||
mutex.lock();
|
||||
if ( packetqueue->video_packet_count || packet->keyframe || event ) {
|
||||
Debug(2, "Have video packet for index (%d)", index );
|
||||
//Debug(2, "Queueing video packet");
|
||||
packetqueue->queuePacket( packet );
|
||||
} else {
|
||||
Debug(2, "Not queiing video packet for index (%d)", index );
|
||||
}
|
||||
mutex.unlock();
|
||||
} else {
|
||||
|
@ -3202,7 +3211,7 @@ int Monitor::PrimeCapture() {
|
|||
int ret = camera->PrimeCapture();
|
||||
if ( ret == 0 ) {
|
||||
video_stream_id = camera->get_VideoStreamId();
|
||||
packetqueue = new zm_packetqueue( pre_event_buffer_count, video_stream_id );
|
||||
packetqueue = new zm_packetqueue( image_buffer_count, video_stream_id );
|
||||
}
|
||||
Debug(2, "Video stream id is (%d), minimum_packets to keep in buffer(%d)", video_stream_id, pre_event_buffer_count );
|
||||
return ret;
|
||||
|
|
|
@ -208,6 +208,7 @@ int RemoteCameraNVSocket::Capture( ZMPacket &zm_packet ) {
|
|||
}
|
||||
|
||||
zm_packet.image->Assign( width, height, colours, subpixelorder, buffer, imagesize );
|
||||
zm_packet.keyframe = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -233,9 +234,8 @@ AVStream *RemoteCameraNVSocket::get_VideoStream() {
|
|||
} else {
|
||||
Error("Can't create video stream");
|
||||
}
|
||||
} else {
|
||||
Debug(2,"Have videostream");
|
||||
} else {
|
||||
Debug(5,"Have videostream");
|
||||
}
|
||||
Debug(2,"Get videoStream");
|
||||
return video_stream;
|
||||
}
|
||||
|
|
|
@ -1003,6 +1003,13 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
} else {
|
||||
zm_packet->out_frame->pts = ( zm_packet->timestamp->tv_sec*1000000 + zm_packet->timestamp->tv_usec ) - video_last_pts;
|
||||
}
|
||||
if ( zm_packet->keyframe ) {
|
||||
Debug(2, "Setting keyframe");
|
||||
zm_packet->out_frame->key_frame =1;
|
||||
Debug(2, "Setting keyframe (%d)", zm_packet->out_frame->key_frame );
|
||||
} else {
|
||||
Debug(2, "Not Setting keyframe");
|
||||
}
|
||||
|
||||
// Do this to allow the encoder to choose whether to use I/P/B frame
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
|
@ -1043,8 +1050,6 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
}
|
||||
#endif
|
||||
opkt.dts = opkt.pts;
|
||||
if ( zm_packet->keyframe )
|
||||
opkt.flags |= AV_PKT_FLAG_KEY;
|
||||
|
||||
} else {
|
||||
AVPacket *ipkt = &zm_packet->packet;
|
||||
|
|
|
@ -222,7 +222,7 @@ Warning("Not Using snapshot" . $event->Path().'/snapshot.jpg' );
|
|||
$imgHtml = '<img id="thumbnail'.$event->id().'" src="'.$imgSrc.'" alt="'. validHtmlStr('Event '.$event->Id()) .'" style="width:'. validInt($thumbData['Width']) .'px;height:'. validInt( $thumbData['Height'] ).'px;" onmouseover="this.src=\''.$streamSrc.'\';" onmouseout="this.src=\''.$imgSrc.'\';"/>';
|
||||
|
||||
echo makePopupLink(
|
||||
'?view=frame&eid='.$event->Id().'&fid='.$thumbData['FrameId'],
|
||||
'?view=frame&eid='.$event->Id().'&fid='.( isset($thumbData['FrameId']) ? $thumbData['FrameId'] : 'snapshot' ),
|
||||
'zmImage',
|
||||
array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ),
|
||||
$imgHtml
|
||||
|
|
Loading…
Reference in New Issue