[FFmpeg-devel] [PATCH 4/6] avformat/mpegtsenc: use increasing numbers in default service names

Marton Balint cus at passwd.hu
Fri Aug 9 00:27:51 EEST 2019


Maybe we should use service ID instead of increasing numbers?

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/mpegtsenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 68af45d8b5..f4c1bb4717 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -218,7 +218,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id,
 /* mpegts writer */
 
 #define DEFAULT_PROVIDER_NAME   "FFmpeg"
-#define DEFAULT_SERVICE_NAME    "Service01"
+#define DEFAULT_SERVICE_NAME    "Service"
 
 /* we retransmit the SI info at this rate */
 #define SDT_RETRANS_TIME 500
@@ -749,13 +749,15 @@ static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
     MpegTSWrite *ts = s->priv_data;
     MpegTSService *service;
     AVDictionaryEntry *title, *provider;
+    char default_service_name[32];
     const char *service_name;
     const char *provider_name;
 
     title = av_dict_get(metadata, "service_name", NULL, 0);
     if (!title)
         title = av_dict_get(metadata, "title", NULL, 0);
-    service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
+    snprintf(default_service_name, sizeof(default_service_name), "%s%02d", DEFAULT_SERVICE_NAME, ts->nb_services + 1);
+    service_name  = title ? title->value : default_service_name;
     provider      = av_dict_get(metadata, "service_provider", NULL, 0);
     provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
 
-- 
2.16.4



More information about the ffmpeg-devel mailing list