]> git.sesse.net Git - vlc/blobdiff - modules/demux/vorbis.h
vorbis demux: convert generic field names to uppercase (fix #8105)
[vlc] / modules / demux / vorbis.h
index a643048259ff31d951f03a3edbb6608af4b571be..ccb3d7f355c5d26265b70ff03de5d68cdc0b89d5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <vlc_charset.h>
 #include <vlc_strings.h>
+#include <vlc_input.h>
 
 static input_attachment_t* ParseFlacPicture( const uint8_t *p_data, int i_data, int i_attachments, int *i_type )
 {
@@ -70,12 +71,15 @@ error:
     return p_attachment;
 }
 
-static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_data, int i_data,
-        int *i_attachments, input_attachment_t ***attachments)
+static inline void vorbis_ParseComment( vlc_meta_t **pp_meta,
+        const uint8_t *p_data, int i_data,
+        int *i_attachments, input_attachment_t ***attachments,
+        int *i_seekpoint, seekpoint_t ***ppp_seekpoint )
 {
     int n;
     int i_comment;
     int i_attach = 0;
+    seekpoint_t *sk = NULL;
 
     if( i_data < 8 )
         return;
@@ -185,12 +189,43 @@ static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_d
                     *i_attachments, *attachments, p_attachment );
             }
         }
+        else if( !strncasecmp(psz_comment, "chapter", strlen("chapter")) )
+        {
+            if( ppp_seekpoint == NULL )
+                continue;
+
+            int i_chapt;
+            if( strstr( psz_comment, "name") && sscanf( psz_comment, "chapter%i=", &i_chapt ) == 1 )
+            {
+                char *p = strchr( psz_comment, '=' );
+                *p++ = '\0';
+                sk->psz_name = strdup( p );
+            }
+            else if( sscanf( psz_comment, "chapter %i=", &i_chapt ) == 1 )
+            {
+                int h, m, s, ms;
+                char *p = strchr( psz_comment, '=' );
+                *p++ = '\0';
+
+                if( sscanf( p, "%d:%d:%d.%d", &h, &m, &s, &ms ) == 4 )
+                {
+                    sk = vlc_seekpoint_New();
+                    sk->i_time_offset = ((h * 3600 + m * 60 + s) *1000 + ms) * 1000;
+                    TAB_APPEND_CAST( (seekpoint_t**), *i_seekpoint, *ppp_seekpoint, sk );
+                }
+            }
+        }
         else if( strchr( psz_comment, '=' ) )
         {
             /* generic (PERFORMER/LICENSE/ORGANIZATION/LOCATION/CONTACT/ISRC,
              * undocumented tags and replay gain ) */
             char *p = strchr( psz_comment, '=' );
             *p++ = '\0';
+
+            for( int i = 0; psz_comment[i]; i++ )
+                if( psz_comment[i] >= 'a' && psz_comment[i] <= 'z' )
+                    psz_comment[i] -= 'a' - 'A';
+
             vlc_meta_AddExtra( p_meta, psz_comment, p );
         }
 #undef IF_EXTRACT