Просмотр исходного кода

ffserver: reflow start_multicast()

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
Reynaldo H. Verdejo Pinochet 10 лет назад
Родитель
Сommit
719cc02586
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      ffserver.c

+ 9 - 6
ffserver.c

@@ -489,12 +489,14 @@ static void start_multicast(void)
     HTTPContext *rtp_c;
     HTTPContext *rtp_c;
     struct sockaddr_in dest_addr = {0};
     struct sockaddr_in dest_addr = {0};
     int default_port, stream_index;
     int default_port, stream_index;
+    unsigned int random0, random1;
 
 
     default_port = 6000;
     default_port = 6000;
     for(stream = config.first_stream; stream; stream = stream->next) {
     for(stream = config.first_stream; stream; stream = stream->next) {
-        if (stream->is_multicast) {
-            unsigned random0 = av_lfg_get(&random_state);
-            unsigned random1 = av_lfg_get(&random_state);
+        if (!stream->is_multicast)
+            continue;
+            random0 = av_lfg_get(&random_state);
+            random1 = av_lfg_get(&random_state);
             /* open the RTP connection */
             /* open the RTP connection */
             snprintf(session_id, sizeof(session_id), "%08x%08x",
             snprintf(session_id, sizeof(session_id), "%08x%08x",
                      random0, random1);
                      random0, random1);
@@ -525,15 +527,16 @@ static void start_multicast(void)
                 stream_index++) {
                 stream_index++) {
                 dest_addr.sin_port = htons(stream->multicast_port +
                 dest_addr.sin_port = htons(stream->multicast_port +
                                            2 * stream_index);
                                            2 * stream_index);
-                if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, NULL) < 0) {
+                if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, NULL)
+                    >= 0) {
+                    continue;
+                }
                     http_log("Could not open output stream '%s/streamid=%d'\n",
                     http_log("Could not open output stream '%s/streamid=%d'\n",
                              stream->filename, stream_index);
                              stream->filename, stream_index);
                     exit(1);
                     exit(1);
-                }
             }
             }
 
 
             rtp_c->state = HTTPSTATE_SEND_DATA;
             rtp_c->state = HTTPSTATE_SEND_DATA;
-        }
     }
     }
 }
 }