[FFmpeg-devel] [PATCH] sdp: Emit only one c= line for multiple streams, if they have the same destination

Martin Storsjo martin
Tue Oct 5 15:20:48 CEST 2010


VLC/Live555 is unable to play a stream with multiple c= lines.
---
 libavformat/sdp.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index a4bf7fb..a884d2c 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -466,6 +466,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
     AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
     struct sdp_session_level s;
     int i, j, port, ttl;
+    int samedest = 0;
     char dst[32], dst_type[5];
 
     memset(buff, 0, size);
@@ -477,7 +478,19 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
 
     port = 0;
     ttl = 0;
-    if (n_files == 1) {
+    if (n_files > 1) {
+        sdp_get_address(dst, sizeof(dst), &ttl, ac[0]->filename);
+        samedest = 1;
+        for (i = 1; i < n_files && samedest; i++) {
+            char dst_tmp[32];
+            int ttl_tmp = 0;
+            sdp_get_address(dst_tmp, sizeof(dst_tmp), &ttl_tmp,
+                            ac[i]->filename);
+            if (strcmp(dst_tmp, dst) || ttl_tmp != ttl)
+                samedest = 0;
+        }
+    }
+    if (n_files == 1 || samedest) {
         port = sdp_get_address(dst, sizeof(dst), &ttl, ac[0]->filename);
         resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type));
         if (dst[0]) {
@@ -497,6 +510,8 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
         if (n_files != 1) {
             port = sdp_get_address(dst, sizeof(dst), &ttl, ac[i]->filename);
             resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type));
+            if (samedest)
+                dst[0] = 0;
         }
         for (j = 0; j < ac[i]->nb_streams; j++) {
             ff_sdp_write_media(buff, size,
-- 
1.7.3.1




More information about the ffmpeg-devel mailing list