vlc | branch: master | Thomas Guillem <tho...@gllm.fr> | Wed Feb  7 17:27:33 
2018 +0100| [2a21859e4a7a012c238e2c8eec946bd4b469947f] | committer: Thomas 
Guillem

chromecast: rework VLCToCC time conversion

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

 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 );

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to