[vlc-commits] chromecast: keep track of the current media session ID reported by the device

Steve Lhomme git at videolan.org
Fri Mar 25 09:06:41 CET 2016


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Mon Mar 21 14:54:39 2016 +0100| [5becc75df4ca113add9afac76eb84ca54f1dc78f] | committer: Jean-Baptiste Kempf

chromecast: keep track of the current media session ID reported by the device

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

 modules/stream_out/chromecast/chromecast.h        |    1 +
 modules/stream_out/chromecast/chromecast_ctrl.cpp |   17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 43031a0..ddba2c2 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -67,6 +67,7 @@ struct intf_sys_t
     vlc_object_t  * const p_module;
     std::string    serverIP;
     std::string appTransportId;
+    std::string mediaSessionId;
 
     int i_sock_fd;
     vlc_tls_creds_t *p_creds;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 90df111..384bbac 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -306,6 +306,8 @@ void intf_sys_t::disconnectChromecast()
         vlc_tls_Delete(p_creds);
         p_tls = NULL;
         setConnectionStatus(CHROMECAST_DISCONNECTED);
+        appTransportId = "";
+        mediaSessionId = ""; // this session is not valid anymore
     }
 }
 
@@ -525,6 +527,8 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
                 case CHROMECAST_AUTHENTICATED:
                     msg_Dbg( p_module, "Chromecast was running no app, launch media_app");
                     appTransportId = "";
+                    mediaSessionId = ""; // this session is not valid anymore
+                    receiverState = RECEIVER_IDLE;
                     msgReceiverLaunchApp();
                     break;
 
@@ -559,6 +563,19 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
             msg_Dbg( p_module, "Player state: %s sessionId:%d",
                     status[0]["playerState"].operator const char *(),
                     (int)(json_int_t) status[0]["mediaSessionId"]);
+
+            char session_id[32];
+            if( snprintf( session_id, sizeof(session_id), "%" PRId64, (json_int_t) status[0]["mediaSessionId"] ) >= (int)sizeof(session_id) )
+            {
+                msg_Err( p_module, "snprintf() truncated string for mediaSessionId" );
+                session_id[sizeof(session_id) - 1] = '\0';
+            }
+            if (!mediaSessionId.empty() && session_id[0] && mediaSessionId != session_id) {
+                msg_Warn( p_module, "different mediaSessionId detected %s was %s", mediaSessionId.c_str(), this->mediaSessionId.c_str());
+            }
+
+            mediaSessionId = session_id;
+
         }
         else if (type == "LOAD_FAILED")
         {



More information about the vlc-commits mailing list