avformat/mpegtsenc: use increasing numbers in default service names
authorMarton Balint <cus@passwd.hu>
Fri, 2 Aug 2019 21:51:57 +0000 (23:51 +0200)
committerMarton Balint <cus@passwd.hu>
Wed, 14 Aug 2019 20:50:11 +0000 (22:50 +0200)
Maybe we should use service ID instead of increasing numbers?

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/mpegtsenc.c

index 68af45d..f4c1bb4 100644 (file)
@@ -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;