[vlc-commits] chromecast: don't restart if casting streams didn't change

Thomas Guillem git at videolan.org
Fri Jan 26 13:08:35 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jan 26 13:07:10 2018 +0100| [5a44c99e6a3f9cac1d23239f0a266c6a6410bc46] | committer: Thomas Guillem

chromecast: don't restart if casting streams didn't change

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5a44c99e6a3f9cac1d23239f0a266c6a6410bc46
---

 modules/stream_out/chromecast/cast.cpp | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index ae4bb5ca36..c4356ad2a1 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -438,7 +438,8 @@ bool sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )
     vlc_fourcc_t i_codec_video = 0, i_codec_audio = 0;
     const es_format_t *p_original_audio = NULL;
     const es_format_t *p_original_video = NULL;
-    out_streams.clear();
+    bool b_out_streams_changed = false;
+    std::vector<sout_stream_id_sys_t*> new_streams;
 
     for (std::vector<sout_stream_id_sys_t*>::iterator it = streams.begin(); it != streams.end(); ++it)
     {
@@ -453,7 +454,7 @@ bool sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )
             else if (i_codec_audio == 0)
                 i_codec_audio = p_es->i_codec;
             p_original_audio = p_es;
-            out_streams.push_back(*it);
+            new_streams.push_back(*it);
         }
         else if (b_supports_video)
         {
@@ -468,18 +469,38 @@ bool sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )
                 else if (i_codec_video == 0)
                     i_codec_video = p_es->i_codec;
                 p_original_video = p_es;
-                out_streams.push_back(*it);
+                new_streams.push_back(*it);
             }
+            else
+                continue;
             /* TODO: else handle ttml/webvtt */
         }
+        else
+            continue;
+
+        bool b_found = false;
+        for (std::vector<sout_stream_id_sys_t*>::iterator out_it = out_streams.begin();
+             out_it != out_streams.end() && !b_found; ++out_it)
+        {
+            if (*out_it == *it)
+                b_found = true;
+        }
+        if (!b_found)
+            b_out_streams_changed = true;
     }
 
-    if (out_streams.empty())
+    if (new_streams.empty())
     {
         p_intf->requestPlayerStop();
         return true;
     }
 
+    /* Don't restart sout and CC session if streams didn't change */
+    if (new_streams.size() == out_streams.size() && !b_out_streams_changed)
+        return true;
+
+    out_streams = new_streams;
+
     std::stringstream ssout;
     if ( !canRemux )
     {



More information about the vlc-commits mailing list