[vlc-commits] adaptive: privatize str_duration()

Rémi Denis-Courmont git at videolan.org
Sun Nov 29 15:09:46 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 29 15:40:34 2015 +0200| [69200883960358225afb16b48197c03d74e59b45] | committer: Rémi Denis-Courmont

adaptive: privatize str_duration()

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

 include/vlc_strings.h                          |    2 -
 modules/demux/adaptative/tools/Conversions.cpp |   61 +++++++++++++++++++++++-
 src/libvlccore.sym                             |    1 -
 src/text/strings.c                             |   59 -----------------------
 4 files changed, 60 insertions(+), 63 deletions(-)

diff --git a/include/vlc_strings.h b/include/vlc_strings.h
index c1f13bb..dc800f4 100644
--- a/include/vlc_strings.h
+++ b/include/vlc_strings.h
@@ -137,8 +137,6 @@ static inline char *str_format( input_thread_t *input, const char *fmt )
  VLC_API void filename_sanitize( char * );
 VLC_API void path_sanitize( char * );
 
-VLC_API time_t str_duration( const char * );
-
 /**
  * @}
  */
diff --git a/modules/demux/adaptative/tools/Conversions.cpp b/modules/demux/adaptative/tools/Conversions.cpp
index 9065da3..127c56f 100644
--- a/modules/demux/adaptative/tools/Conversions.cpp
+++ b/modules/demux/adaptative/tools/Conversions.cpp
@@ -19,9 +19,68 @@
  *****************************************************************************/
 #include "Conversions.hpp"
 
-#include <vlc_strings.h>
+#include <vlc_charset.h>
 #include <sstream>
 
+/*
+  Decodes a duration as defined by ISO 8601
+  http://en.wikipedia.org/wiki/ISO_8601#Durations
+  @param str A null-terminated string to convert
+  @return: The duration in seconds. -1 if an error occurred.
+
+  Exemple input string: "PT0H9M56.46S"
+ */
+static time_t str_duration( const char *psz_duration )
+{
+    bool        timeDesignatorReached = false;
+    time_t      res = 0;
+    char*       end_ptr;
+
+    if ( psz_duration == NULL )
+        return -1;
+    if ( ( *(psz_duration++) ) != 'P' )
+        return -1;
+    do
+    {
+        double number = us_strtod( psz_duration, &end_ptr );
+        double      mul = 0;
+        if ( psz_duration != end_ptr )
+            psz_duration = end_ptr;
+        switch( *psz_duration )
+        {
+            case 'M':
+            {
+                //M can mean month or minutes, if the 'T' flag has been reached.
+                //We don't handle months though.
+                if ( timeDesignatorReached == true )
+                    mul = 60.0;
+                break ;
+            }
+            case 'Y':
+            case 'W':
+                break ; //Don't handle this duration.
+            case 'D':
+                mul = 86400.0;
+                break ;
+            case 'T':
+                timeDesignatorReached = true;
+                break ;
+            case 'H':
+                mul = 3600.0;
+                break ;
+            case 'S':
+                mul = 1.0;
+                break ;
+            default:
+                break ;
+        }
+        res += (time_t)(mul * number);
+        if ( *psz_duration )
+            psz_duration++;
+    } while ( *psz_duration );
+    return res;
+}
+
 IsoTime::IsoTime(const std::string &str)
 {
     time = str_duration(str.c_str());
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e56fbd0..77b4b48 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -413,7 +413,6 @@ stream_ReadDir
 stream_FilterDefaultReadDir
 str_format_meta
 str_format_time
-str_duration
 subpicture_Delete
 subpicture_New
 subpicture_NewFromPicture
diff --git a/src/text/strings.c b/src/text/strings.c
index 40f7903..d2fb608 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -913,62 +913,3 @@ void path_sanitize( char *str )
         str++;
     }
 }
-
-/*
-  Decodes a duration as defined by ISO 8601
-  http://en.wikipedia.org/wiki/ISO_8601#Durations
-  @param str A null-terminated string to convert
-  @return: The duration in seconds. -1 if an error occurred.
-
-  Exemple input string: "PT0H9M56.46S"
- */
-time_t str_duration( const char *psz_duration )
-{
-    bool        timeDesignatorReached = false;
-    time_t      res = 0;
-    char*       end_ptr;
-
-    if ( psz_duration == NULL )
-        return -1;
-    if ( ( *(psz_duration++) ) != 'P' )
-        return -1;
-    do
-    {
-        double number = us_strtod( psz_duration, &end_ptr );
-        double      mul = 0;
-        if ( psz_duration != end_ptr )
-            psz_duration = end_ptr;
-        switch( *psz_duration )
-        {
-            case 'M':
-            {
-                //M can mean month or minutes, if the 'T' flag has been reached.
-                //We don't handle months though.
-                if ( timeDesignatorReached == true )
-                    mul = 60.0;
-                break ;
-            }
-            case 'Y':
-            case 'W':
-                break ; //Don't handle this duration.
-            case 'D':
-                mul = 86400.0;
-                break ;
-            case 'T':
-                timeDesignatorReached = true;
-                break ;
-            case 'H':
-                mul = 3600.0;
-                break ;
-            case 'S':
-                mul = 1.0;
-                break ;
-            default:
-                break ;
-        }
-        res += (time_t)(mul * number);
-        if ( *psz_duration )
-            psz_duration++;
-    } while ( *psz_duration );
-    return res;
-}



More information about the vlc-commits mailing list