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

Submitted by Marton Balint on Aug. 8, 2019, 9:27 p.m.

Details

Message ID 20190808212753.29467-4-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint Aug. 8, 2019, 9:27 p.m.
Maybe we should use service ID instead of increasing numbers?

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

Patch hide | download patch | download mbox

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;