Skip to content

Commit 9909bc2

Browse files
committed
Use (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO now in place of bit-mapped AV_CH_LAYOUT_STEREO -- possible from FFmpeg 5.1, mandatory in FFmpeg 7. Also remove deprecated avcodec_close.
1 parent 9809f9d commit 9909bc2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rtp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ void avcodec_alloc_context3_cleanup_handler(void *arg) {
20972097
void avcodec_open2_cleanup_handler(void *arg) {
20982098
debug(3, "avcodec_open2_cleanup_handler");
20992099
AVCodecContext *codec_context = arg;
2100-
avcodec_close(codec_context);
2100+
avcodec_free_context(&codec_context);
21012101
}
21022102

21032103
void av_parser_init_cleanup_handler(void *arg) {
@@ -2313,8 +2313,15 @@ void *rtp_buffered_audio_processor(void *arg) {
23132313
// push a deallocator -- av_packet_free(pkt);
23142314
pthread_cleanup_push(swr_alloc_cleanup_handler, &swr);
23152315

2316+
2317+
// FFmpeg 5.1 or later...
2318+
#if LIBAVUTIL_VERSION_MAJOR >= 57
2319+
av_opt_set_chlayout(swr, "in_chlayout", &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO, 0);
2320+
av_opt_set_chlayout(swr, "out_chlayout", &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO, 0);
2321+
#else
23162322
av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_STEREO, 0);
23172323
av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
2324+
#endif
23182325
av_opt_set_int(swr, "in_sample_rate", conn->input_rate, 0);
23192326
av_opt_set_int(swr, "out_sample_rate", conn->input_rate,
23202327
0); // must match or the timing will be wrong`

0 commit comments

Comments
 (0)