Skip to content

Commit

Permalink
pp-rec: fix leaks on exit with h264/h264
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed May 29, 2024
1 parent 82efb6f commit 2a1db57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
14 changes: 2 additions & 12 deletions src/postprocessing/pp-h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ int janus_pp_h264_process(FILE *file, janus_pp_frame_packet *list, int *working)

/* Close MP4 file */
void janus_pp_h264_close(void) {
if(fctx != NULL)
if(fctx != NULL) {
av_write_trailer(fctx);
#ifdef USE_CODECPAR
if(vEncoder != NULL)
Expand All @@ -552,17 +552,7 @@ void janus_pp_h264_close(void) {
if(vStream != NULL && vStream->codec != NULL)
avcodec_close(vStream->codec);
#endif
if(fctx != NULL && fctx->streams[0] != NULL) {
#ifndef USE_CODECPAR
av_free(fctx->streams[0]->codec);
#endif
av_free(fctx->streams[0]);
}
if(fctx != NULL) {
avio_close(fctx->pb);
#if LIBAVFORMAT_VER_AT_LEAST(58, 7)
g_free(fctx->url);
#endif
av_free(fctx);
avformat_free_context(fctx);
}
}
14 changes: 2 additions & 12 deletions src/postprocessing/pp-h265.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ int janus_pp_h265_process(FILE *file, janus_pp_frame_packet *list, int *working)

/* Close MP4 file */
void janus_pp_h265_close(void) {
if(fctx != NULL)
if(fctx != NULL) {
av_write_trailer(fctx);
#ifdef USE_CODECPAR
if(vEncoder != NULL)
Expand All @@ -641,17 +641,7 @@ void janus_pp_h265_close(void) {
if(vStream != NULL && vStream->codec != NULL)
avcodec_close(vStream->codec);
#endif
if(fctx != NULL && fctx->streams[0] != NULL) {
#ifndef USE_CODECPAR
av_free(fctx->streams[0]->codec);
#endif
av_free(fctx->streams[0]);
}
if(fctx != NULL) {
avio_close(fctx->pb);
#if LIBAVFORMAT_VER_AT_LEAST(58, 7)
g_free(fctx->url);
#endif
av_free(fctx);
avformat_free_context(fctx);
}
}

0 comments on commit 2a1db57

Please sign in to comment.