[vlc-commits] chromecast: rework VLCToCC time conversion

Thomas Guillem git at videolan.org
Fri Feb 23 08:29:24 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb  7 17:27:33 2018 +0100| [4ddf9dda1bd0922711461760e7c1477c8a21415e] | committer: Thomas Guillem

chromecast: rework VLCToCC time conversion

(cherry picked from commit 2a21859e4a7a012c238e2c8eec946bd4b469947f)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/stream_out/chromecast/chromecast.h        |  2 ++
 modules/stream_out/chromecast/chromecast_ctrl.cpp | 17 +++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 570486fcc0..d928524ef8 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -228,6 +228,8 @@ private:
 
     void prepareHttpArtwork();
 
+    static std::string  timeVLCToCC(mtime_t);
+
 private:
     vlc_object_t  * const m_module;
     const int      m_streaming_port;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 3b9107566f..d8541bff55 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -35,6 +35,7 @@
 
 #include <cassert>
 #include <cerrno>
+#include <iomanip>
 
 #include <vlc_stream.h>
 
@@ -926,18 +927,22 @@ States intf_sys_t::state() const
     return m_state;
 }
 
+std::string intf_sys_t::timeVLCToCC(mtime_t time)
+{
+    std::stringstream ss;
+    ss.setf(std::ios_base::fixed, std::ios_base::floatfield);
+    ss << std::setprecision(6) << (double (time) / 1000000.0);
+    return ss.str();
+}
+
 bool intf_sys_t::requestPlayerSeek(mtime_t pos)
 {
     vlc_mutex_locker locker(&m_lock);
     if( !isStatePlaying() || m_mediaSessionId == 0 )
         return false;
 
-    char current_time[32];
-    if( snprintf( current_time, sizeof(current_time), "%.3f",
-                  double( pos ) / 1000000.0 ) >= (int)sizeof(current_time) )
-        return false;
-
-    int ret = m_communication.msgPlayerSeek( m_appTransportId, m_mediaSessionId, current_time );
+    int ret = m_communication.msgPlayerSeek( m_appTransportId, m_mediaSessionId,
+                                             timeVLCToCC( pos ) );
     if( ret == VLC_SUCCESS )
     {
         setState( Seeking );



More information about the vlc-commits mailing list