fix memleak
parent
792d8640c2
commit
259b7f7655
|
@ -270,15 +270,15 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
}
|
||||
|
||||
// Set transport method as specified by method field, rtpUni is default
|
||||
if (Method() == "rtpMulti") {
|
||||
if ( Method() == "rtpMulti" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "udp_multicast", 0);
|
||||
} else if (Method() == "rtpRtsp") {
|
||||
} else if ( Method() == "rtpRtsp" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0);
|
||||
} else if (Method() == "rtpRtspHttp") {
|
||||
} else if ( Method() == "rtpRtspHttp" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "http", 0);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
if ( ret < 0 ) {
|
||||
Warning("Could not set rtsp_transport method '%s'\n", Method().c_str());
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
}
|
||||
|
||||
AVDictionaryEntry *e;
|
||||
if ((e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL) {
|
||||
if ( (e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL ) {
|
||||
Warning( "Option %s not recognized by ffmpeg", e->key);
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY;
|
||||
|
||||
// Try and get the codec from the codec context
|
||||
if ((mVideoCodec = avcodec_find_decoder(mVideoCodecContext->codec_id)) == NULL) {
|
||||
if ( (mVideoCodec = avcodec_find_decoder(mVideoCodecContext->codec_id)) == NULL ) {
|
||||
Fatal("Can't find codec for video stream from %s", mPath.c_str());
|
||||
} else {
|
||||
Debug(1, "Video Found decoder");
|
||||
|
@ -388,10 +388,10 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
// Open the codec
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)
|
||||
Debug ( 1, "Calling avcodec_open" );
|
||||
if (avcodec_open(mVideoCodecContext, mVideoCodec) < 0)
|
||||
if ( avcodec_open(mVideoCodecContext, mVideoCodec) < 0 )
|
||||
#else
|
||||
Debug ( 1, "Calling avcodec_open2" );
|
||||
if (avcodec_open2(mVideoCodecContext, mVideoCodec, 0) < 0)
|
||||
if ( avcodec_open2(mVideoCodecContext, mVideoCodec, 0) < 0 )
|
||||
#endif
|
||||
Fatal( "Unable to open codec for video stream from %s", mPath.c_str() );
|
||||
}
|
||||
|
@ -837,11 +837,9 @@ else if ( packet.pts && video_last_pts > packet.pts ) {
|
|||
Debug( 3, "Some other stream index %d", packet.stream_index );
|
||||
#endif
|
||||
}
|
||||
//if ( videoStore ) {
|
||||
|
||||
// the packet contents are ref counted... when queuing, we allocate another packet and reference it with that one, so we should always need to unref here, which should not affect the queued version.
|
||||
zm_av_packet_unref( &packet );
|
||||
//}
|
||||
// the packet contents are ref counted... when queuing, we allocate another packet and reference it with that one, so we should always need to unref here, which should not affect the queued version.
|
||||
zm_av_packet_unref( &packet );
|
||||
} // end while ! frameComplete
|
||||
return (frameCount);
|
||||
} // end FfmpegCamera::CaptureAndRecord
|
||||
|
|
|
@ -30,7 +30,7 @@ zm_packetqueue::zm_packetqueue(){
|
|||
}
|
||||
|
||||
zm_packetqueue::~zm_packetqueue() {
|
||||
|
||||
clearQueue();
|
||||
}
|
||||
|
||||
bool zm_packetqueue::queuePacket( ZMPacket* zm_packet ) {
|
||||
|
|
|
@ -189,6 +189,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
audio_output_codec = NULL;
|
||||
audio_input_context = NULL;
|
||||
audio_output_stream = NULL;
|
||||
input_frame = NULL;
|
||||
output_frame = NULL;
|
||||
#ifdef HAVE_LIBAVRESAMPLE
|
||||
resample_context = NULL;
|
||||
#endif
|
||||
|
@ -391,6 +393,15 @@ Debug(2, "writing flushed packet pts(%d) dts(%d) duration(%d)", pkt.pts, pkt.dts
|
|||
|
||||
/* free the stream */
|
||||
avformat_free_context(oc);
|
||||
|
||||
if ( input_frame ) {
|
||||
av_frame_free( &input_frame );
|
||||
input_frame = NULL;
|
||||
}
|
||||
if ( output_frame ) {
|
||||
av_frame_free( &output_frame );
|
||||
output_frame = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoStore::setup_resampler() {
|
||||
|
@ -495,13 +506,13 @@ bool VideoStore::setup_resampler() {
|
|||
}
|
||||
|
||||
/** Create a new frame to store the audio samples. */
|
||||
if (!(input_frame = zm_av_frame_alloc())) {
|
||||
if ( !(input_frame = zm_av_frame_alloc()) ) {
|
||||
Error("Could not allocate input frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Create a new frame to store the audio samples. */
|
||||
if (!(output_frame = zm_av_frame_alloc())) {
|
||||
if ( !(output_frame = zm_av_frame_alloc()) ) {
|
||||
Error("Could not allocate output frame");
|
||||
av_frame_free( &input_frame );
|
||||
return false;
|
||||
|
|
|
@ -68,7 +68,7 @@ void Zone::Setup(
|
|||
overload_frames = p_overload_frames;
|
||||
extend_alarm_frames = p_extend_alarm_frames;
|
||||
|
||||
Debug( 1, "Initialised zone %d/%s - %d - %dx%d - Rgb:%06x, CM:%d, MnAT:%d, MxAT:%d, MnAP:%d, MxAP:%d, FB:%dx%d, MnFP:%d, MxFP:%d, MnBS:%d, MxBS:%d, MnB:%d, MxB:%d, OF: %d, AF: %d", id, label, type, polygon.Width(), polygon.Height(), alarm_rgb, check_method, min_pixel_threshold, max_pixel_threshold, min_alarm_pixels, max_alarm_pixels, filter_box.X(), filter_box.Y(), min_filter_pixels, max_filter_pixels, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs, overload_frames, extend_alarm_frames );
|
||||
//Debug( 1, "Initialised zone %d/%s - %d - %dx%d - Rgb:%06x, CM:%d, MnAT:%d, MxAT:%d, MnAP:%d, MxAP:%d, FB:%dx%d, MnFP:%d, MxFP:%d, MnBS:%d, MxBS:%d, MnB:%d, MxB:%d, OF: %d, AF: %d", id, label, type, polygon.Width(), polygon.Height(), alarm_rgb, check_method, min_pixel_threshold, max_pixel_threshold, min_alarm_pixels, max_alarm_pixels, filter_box.X(), filter_box.Y(), min_filter_pixels, max_filter_pixels, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs, overload_frames, extend_alarm_frames );
|
||||
|
||||
alarmed = false;
|
||||
was_alarmed = false;
|
||||
|
|
|
@ -193,7 +193,9 @@ foreach ( $events as $event ) {
|
|||
<tr>
|
||||
<td class="colId"><?php echo makePopupLink( '?view=event&eid='.$event->Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), $event->Id().($event->Archived()?'*':'') ) ?></td>
|
||||
<td class="colName"><?php echo makePopupLink( '?view=event&eid='.$event->Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), reScale( $event->Height(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ) ), validHtmlStr($event->Name()).($event->Archived()?'*':'' ) ) ?></td>
|
||||
<td class="colMonitorName"><?php echo $event->MonitorName() ?></td>
|
||||
<td class="colMonitorName"><?php echo
|
||||
makePopupLink( '?view=monitor&mid='.$event->MonitorId(), 'zmMonitor'.$event->Monitorid(), 'monitor', $event->MonitorName(), canEdit( 'Monitors' ) )
|
||||
?></td>
|
||||
<td class="colCause"><?php echo makePopupLink( '?view=eventdetail&eid='.$event->Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?></td>
|
||||
<td class="colTime"><?php echo strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event->StartTime()) ) ?></td>
|
||||
<td class="colDuration"><?php echo gmdate("H:i:s", $event->Length() ) ?></td>
|
||||
|
|
Loading…
Reference in New Issue