@@ -184,6 +184,16 @@ struct av_file_context {
184
184
185
185
typedef struct av_file_context av_file_context_t ;
186
186
187
+ #if (LIBAVFORMAT_VERSION_MAJOR >= 60 )
188
+ typedef struct FFOutputFormat {
189
+ int priv_data_size ;
190
+ } FFOutputFormat ;
191
+
192
+ static inline int priv_data_size (const AVOutputFormat * fmt )
193
+ {
194
+ return ((const struct FFOutputFormat * )fmt )-> priv_data_size ;
195
+ }
196
+ #endif
187
197
188
198
/**
189
199
* Fill the provided buffer with a string containing a timestamp
@@ -455,8 +465,13 @@ static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, const cha
455
465
}
456
466
457
467
s -> oformat = oformat ;
468
+ #if (LIBAVFORMAT_VERSION_MAJOR < 60 )
458
469
if (s -> oformat -> priv_data_size > 0 ) {
459
470
s -> priv_data = av_mallocz (s -> oformat -> priv_data_size );
471
+ #else
472
+ if (priv_data_size (s -> oformat ) > 0 ) {
473
+ s -> priv_data = av_mallocz (priv_data_size (s -> oformat ));
474
+ #endif
460
475
if (!s -> priv_data ) {
461
476
goto nomem ;
462
477
}
@@ -621,7 +636,9 @@ static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst,
621
636
c -> rc_initial_buffer_occupancy = buffer_bytes * 8 ;
622
637
623
638
if (codec_id == AV_CODEC_ID_H264 ) {
639
+ #if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT (60 ,31 ,102 ))
624
640
c -> ticks_per_frame = 2 ;
641
+ #endif
625
642
626
643
627
644
c -> flags |=AV_CODEC_FLAG_LOOP_FILTER ; // flags=+loop
@@ -1410,8 +1427,10 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h
1410
1427
switch_goto_status (SWITCH_STATUS_FALSE , err );
1411
1428
}
1412
1429
1430
+ #if (LIBAVFORMAT_VERSION_MAJOR < 61 )
1413
1431
handle -> seekable = context -> fc -> iformat -> read_seek2 ? 1 : (context -> fc -> iformat -> read_seek ? 1 : 0 );
1414
1432
switch_log_printf (SWITCH_CHANNEL_LOG , SWITCH_LOG_INFO , "file %s is %sseekable\n" , filename , handle -> seekable ? "" : "not " );
1433
+ #endif
1415
1434
1416
1435
/** Get information on the input file (number of streams etc.). */
1417
1436
if ((error = avformat_find_stream_info (context -> fc , opts ? & opts : NULL )) < 0 ) {
@@ -1502,7 +1521,11 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h
1502
1521
1503
1522
switch_log_printf (SWITCH_CHANNEL_LOG , SWITCH_LOG_ERROR , "Could not open input audio codec channel 2 (error '%s')\n" , get_error_text (error , ebuf , sizeof (ebuf )));
1504
1523
if ((cc = av_get_codec_context (& context -> audio_st [0 ]))) {
1524
+ #if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT (57 ,48 ,101 ))
1505
1525
avcodec_close (cc );
1526
+ #else
1527
+ avcodec_free_context (& cc );
1528
+ #endif
1506
1529
}
1507
1530
1508
1531
context -> has_audio = 0 ;
@@ -3084,14 +3107,11 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
3084
3107
void * pop ;
3085
3108
MediaStream * mst = & context -> video_st ;
3086
3109
AVStream * st = mst -> st ;
3087
- int ticks = 0 ;
3088
3110
int64_t max_delta = 1 * AV_TIME_BASE ; // 1 second
3089
3111
switch_status_t status = SWITCH_STATUS_SUCCESS ;
3090
3112
double fl_to = 0.02 ;
3091
3113
int do_fl = 0 ;
3092
3114
int smaller_ts = context -> read_fps ;
3093
- AVCodecContext * c = NULL ;
3094
- AVCodecParserContext * cp = NULL ;
3095
3115
3096
3116
if (!context -> has_video ) return SWITCH_STATUS_FALSE ;
3097
3117
@@ -3199,6 +3219,10 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
3199
3219
}
3200
3220
#endif
3201
3221
3222
+ #if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT (60 ,31 ,102 ))
3223
+ int ticks = 0 ;
3224
+ AVCodecContext * c = NULL ;
3225
+ AVCodecParserContext * cp = NULL ;
3202
3226
if ((c = av_get_codec_context (mst )) && c -> time_base .num ) {
3203
3227
cp = av_stream_get_parser (st );
3204
3228
ticks = cp ? cp -> repeat_pict + 1 : c -> ticks_per_frame ;
@@ -3210,6 +3234,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
3210
3234
context -> video_start_time , ticks , c ? c -> ticks_per_frame : -1 , st -> time_base .num , st -> time_base .den , c ? c -> time_base .num : -1 , c ? c -> time_base .den : -1 ,
3211
3235
st -> start_time , st -> duration == AV_NOPTS_VALUE ? context -> fc -> duration / AV_TIME_BASE * 1000 : st -> duration , st -> nb_frames , av_q2d (st -> time_base ));
3212
3236
}
3237
+ #endif
3213
3238
3214
3239
again :
3215
3240
0 commit comments