@@ -63,16 +63,14 @@ void ffmpeg_mpegts_log_error(int log_level, struct ffmpeg_data *data,
63
63
blog (log_level , "%s" , out );
64
64
}
65
65
66
- static bool is_rist (struct ffmpeg_output * stream )
66
+ static bool is_rist (const char * url )
67
67
{
68
- return !strncmp (stream -> ff_data .config .url , RIST_PROTO ,
69
- sizeof (RIST_PROTO ) - 1 );
68
+ return !strncmp (url , RIST_PROTO , sizeof (RIST_PROTO ) - 1 );
70
69
}
71
70
72
- static bool is_srt (struct ffmpeg_output * stream )
71
+ static bool is_srt (const char * url )
73
72
{
74
- return !strncmp (stream -> ff_data .config .url , SRT_PROTO ,
75
- sizeof (SRT_PROTO ) - 1 );
73
+ return !strncmp (url , SRT_PROTO , sizeof (SRT_PROTO ) - 1 );
76
74
}
77
75
78
76
static bool proto_is_allowed (struct ffmpeg_output * stream )
@@ -467,8 +465,8 @@ static inline int open_output_file(struct ffmpeg_output *stream,
467
465
struct ffmpeg_data * data )
468
466
{
469
467
int ret ;
470
- bool rist = is_rist ( stream ) ;
471
- bool srt = is_srt ( stream ) ;
468
+ bool rist = data -> config . is_rist ;
469
+ bool srt = data -> config . is_srt ;
472
470
bool allowed_proto = proto_is_allowed (stream );
473
471
AVDictionary * dict = NULL ;
474
472
@@ -591,10 +589,7 @@ static void close_audio(struct ffmpeg_data *data)
591
589
static void close_mpegts_url (struct ffmpeg_output * stream , bool is_rist )
592
590
{
593
591
int err = 0 ;
594
- AVIOContext * s = stream -> s ;
595
- if (!s )
596
- return ;
597
- URLContext * h = s -> opaque ;
592
+ URLContext * h = stream -> h ;
598
593
if (!h )
599
594
return ; /* can happen when opening the url fails */
600
595
@@ -608,10 +603,14 @@ static void close_mpegts_url(struct ffmpeg_output *stream, bool is_rist)
608
603
av_freep (h );
609
604
610
605
/* close custom avio_context for srt or rist */
611
- avio_flush (stream -> s );
612
- stream -> s -> opaque = NULL ;
613
- av_freep (& stream -> s -> buffer );
614
- avio_context_free (& stream -> s );
606
+ AVIOContext * s = stream -> s ;
607
+ if (!s )
608
+ return ;
609
+
610
+ avio_flush (s );
611
+ s -> opaque = NULL ;
612
+ av_freep (& s -> buffer );
613
+ avio_context_free (& s );
615
614
616
615
if (err )
617
616
info ("[ffmpeg mpegts muxer]: Error closing URL %s" ,
@@ -632,8 +631,8 @@ void ffmpeg_mpegts_data_free(struct ffmpeg_output *stream,
632
631
}
633
632
634
633
if (data -> output ) {
635
- if (is_rist ( stream ) || is_srt ( stream ) ) {
636
- close_mpegts_url (stream , is_rist ( stream ) );
634
+ if (data -> config . is_rist || data -> config . is_srt ) {
635
+ close_mpegts_url (stream , data -> config . is_rist );
637
636
} else {
638
637
avio_close (data -> output -> pb );
639
638
}
@@ -757,11 +756,10 @@ static void ffmpeg_mpegts_destroy(void *data)
757
756
struct ffmpeg_output * output = data ;
758
757
759
758
if (output ) {
759
+ ffmpeg_mpegts_full_stop (output );
760
760
if (output -> connecting )
761
761
pthread_join (output -> start_thread , NULL );
762
762
763
- ffmpeg_mpegts_full_stop (output );
764
-
765
763
pthread_mutex_destroy (& output -> write_mutex );
766
764
os_sem_destroy (output -> write_sem );
767
765
os_event_destroy (output -> stop_event );
@@ -910,7 +908,8 @@ static bool set_config(struct ffmpeg_output *stream)
910
908
service , OBS_SERVICE_CONNECT_INFO_ENCRYPT_PASSPHRASE );
911
909
config .format_name = "mpegts" ;
912
910
config .format_mime_type = "video/M2PT" ;
913
-
911
+ config .is_rist = is_rist (config .url );
912
+ config .is_srt = is_srt (config .url );
914
913
/* 2. video settings */
915
914
916
915
// 2.a) set width & height
@@ -1110,6 +1109,7 @@ static void ffmpeg_mpegts_full_stop(void *data)
1110
1109
obs_output_end_data_capture (output -> output );
1111
1110
ffmpeg_mpegts_deactivate (output );
1112
1111
}
1112
+ ffmpeg_mpegts_data_free (output , & output -> ff_data );
1113
1113
}
1114
1114
1115
1115
static void ffmpeg_mpegts_stop (void * data , uint64_t ts )
@@ -1144,8 +1144,6 @@ static void ffmpeg_mpegts_deactivate(struct ffmpeg_output *output)
1144
1144
da_free (output -> packets );
1145
1145
1146
1146
pthread_mutex_unlock (& output -> write_mutex );
1147
-
1148
- ffmpeg_mpegts_data_free (output , & output -> ff_data );
1149
1147
}
1150
1148
1151
1149
static uint64_t ffmpeg_mpegts_total_bytes (void * data )
0 commit comments