[vlc-commits] chromecast: send/transcode only one audio/video track

Thomas Guillem git at videolan.org
Fri Jan 19 18:44:21 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jan 19 13:48:30 2018 +0100| [b6e1d93a9d3c9612694f4daf4417cbb6f9587f72] | committer: Jean-Baptiste Kempf

chromecast: send/transcode only one audio/video track

It's useless to send tracks that are not supported by the CC.

(cherry picked from commit 2fa9ea9b07965321d69f4a5926787c0bd4da02f5)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

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

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 0da18a867f..46dc3ddcfc 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -80,6 +80,7 @@ struct sout_stream_sys_t
 
     bool                               es_changed;
     std::vector<sout_stream_id_sys_t*> streams;
+    std::vector<sout_stream_id_sys_t*> out_streams;
     unsigned int                       transcode_attempt_idx;
     States                             previous_state;
 
@@ -227,7 +228,19 @@ static void Del(sout_stream_t *p_stream, sout_stream_id_sys_t *id)
         if ( p_sys_id == id )
         {
             if ( p_sys_id->p_sub_id != NULL )
+            {
                 sout_StreamIdDel( p_sys->p_out, p_sys_id->p_sub_id );
+                for (std::vector<sout_stream_id_sys_t*>::iterator out_it = p_sys->out_streams.begin();
+                     out_it != p_sys->out_streams.end(); )
+                {
+                    if (*out_it == id)
+                    {
+                        p_sys->out_streams.erase(out_it);
+                        break;
+                    }
+                    out_it++;
+                }
+            }
 
             es_format_Clean( &p_sys_id->fmt );
             free( p_sys_id );
@@ -238,7 +251,7 @@ static void Del(sout_stream_t *p_stream, sout_stream_id_sys_t *id)
         it++;
     }
 
-    if ( p_sys->streams.empty() )
+    if ( p_sys->out_streams.empty() )
     {
         p_sys->p_intf->requestPlayerStop();
 
@@ -316,7 +329,8 @@ bool sout_stream_sys_t::startSoutChain( sout_stream_t *p_stream )
     }
 
     /* check the streams we can actually add */
-    for (std::vector<sout_stream_id_sys_t*>::iterator it = streams.begin(); it != streams.end(); )
+    for (std::vector<sout_stream_id_sys_t*>::iterator it = out_streams.begin();
+         it != out_streams.end(); )
     {
         sout_stream_id_sys_t *p_sys_id = *it;
         p_sys_id->p_sub_id = sout_StreamIdAdd( p_out, &p_sys_id->fmt );
@@ -324,13 +338,12 @@ bool sout_stream_sys_t::startSoutChain( sout_stream_t *p_stream )
         {
             msg_Err( p_stream, "can't handle %4.4s stream", (char *)&p_sys_id->fmt.i_codec );
             es_format_Clean( &p_sys_id->fmt );
-            free( p_sys_id );
-            it = streams.erase( it );
+            it = out_streams.erase( it );
         }
         else
             ++it;
     }
-    return streams.empty() == false;
+    return out_streams.empty() == false;
 }
 
 bool sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )
@@ -346,6 +359,7 @@ 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();
 
     for (std::vector<sout_stream_id_sys_t*>::iterator it = streams.begin(); it != streams.end(); ++it)
     {
@@ -360,6 +374,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);
         }
         else if (b_supports_video)
         {
@@ -374,11 +389,15 @@ 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);
             }
             /* TODO: else handle ttml/webvtt */
         }
     }
 
+    if (out_streams.empty())
+        return true;
+
     std::stringstream ssout;
     if ( !canRemux )
     {



More information about the vlc-commits mailing list