[vlc-commits] [Git][videolan/vlc][master] 2 commits: medialibrary: fix subtitle tracks metadata extraction

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Jun 17 06:05:20 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6e1c4328 by Prince Gupta at 2024-06-17T05:45:06+00:00
medialibrary: fix subtitle tracks metadata extraction

- - - - -
e19dc449 by Prince Gupta at 2024-06-17T05:45:06+00:00
medialibrary: add subtitle tracks in media's tracks list

- - - - -


4 changed files:

- include/vlc_media_library.h
- modules/misc/medialibrary/MetadataExtractor.cpp
- modules/misc/medialibrary/entities.cpp
- src/misc/medialibrary.c


Changes:

=====================================
include/vlc_media_library.h
=====================================
@@ -66,6 +66,7 @@ typedef enum vlc_ml_track_type_t
     VLC_ML_TRACK_TYPE_UNKNOWN,
     VLC_ML_TRACK_TYPE_VIDEO,
     VLC_ML_TRACK_TYPE_AUDIO,
+    VLC_ML_TRACK_TYPE_SUBTITLE,
 } vlc_ml_track_type_t;
 
 typedef enum vlc_ml_thumbnail_size_t
@@ -191,6 +192,11 @@ typedef struct vlc_ml_media_track_t
             uint32_t i_fpsNum;
             uint32_t i_fpsDen;
         } v;
+        struct
+        {
+            // Subtitle
+            char* psz_encoding;
+        } s;
     };
 } vlc_ml_media_track_t;
 


=====================================
modules/misc/medialibrary/MetadataExtractor.cpp
=====================================
@@ -157,6 +157,9 @@ void MetadataExtractor::populateItem( medialibrary::parser::IItem& item, input_i
                 t.u.v.sarNum = p_es->video.i_sar_num;
                 t.u.v.sarDen = p_es->video.i_sar_den;
                 break;
+            case SPU_ES:
+                t.type = medialibrary::parser::IItem::Track::Type::Subtitle;
+                break;
             default:
                 continue;
         }


=====================================
modules/misc/medialibrary/entities.cpp
=====================================
@@ -37,6 +37,7 @@
 #include <medialibrary/IPlaylist.h>
 #include <medialibrary/IAudioTrack.h>
 #include <medialibrary/IVideoTrack.h>
+#include <medialibrary/ISubtitleTrack.h>
 #include <medialibrary/IFolder.h>
 #include <medialibrary/filesystem/IDevice.h>
 #include <medialibrary/filesystem/Errors.h>
@@ -132,7 +133,9 @@ static bool convertTracks( const medialibrary::IMedia* inputMedia, vlc_ml_media_
 {
     auto videoTracks = inputMedia->videoTracks()->all();
     auto audioTracks = inputMedia->audioTracks()->all();
-    auto nbItems = videoTracks.size() + audioTracks.size();
+    auto subtitleTracks = inputMedia->subtitleTracks()->all();
+
+    auto nbItems = videoTracks.size() + audioTracks.size() + subtitleTracks.size();
     outputMedia.p_tracks = static_cast<vlc_ml_media_track_list_t*>(
                 calloc( 1, sizeof( *outputMedia.p_tracks ) +
                         nbItems * sizeof( *outputMedia.p_tracks->p_items ) ) );
@@ -167,6 +170,19 @@ static bool convertTracks( const medialibrary::IMedia* inputMedia, vlc_ml_media_
         output->a.i_nbChannels = t->nbChannels();
         output->a.i_sampleRate = t->sampleRate();
     }
+
+    for ( const auto& t : subtitleTracks )
+    {
+        vlc_ml_media_track_t* output = &items[outputMedia.p_tracks->i_nb_items++];
+
+        if ( convertTracksCommon( output, t->codec(), t->language(), t->description() ) == false )
+            return false;
+
+        output->i_type = VLC_ML_TRACK_TYPE_SUBTITLE;
+        if ( !strdup_helper( t->encoding(), output->s.psz_encoding ) )
+            return false;
+    }
+
     return true;
 }
 


=====================================
src/misc/medialibrary.c
=====================================
@@ -164,6 +164,9 @@ static void vlc_ml_media_release_tracks_inner( vlc_ml_media_track_list_t* p_trac
         free( p_track->psz_codec );
         free( p_track->psz_language );
         free( p_track->psz_description );
+
+        if ( p_track->i_type == VLC_ML_TRACK_TYPE_SUBTITLE )
+            free( p_track->s.psz_encoding );
     }
     free( p_tracks );
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8488b93bb1a44dc21e5242874c624547d4c69191...e19dc449339e740a579d44e81ceed72ba56914e5

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8488b93bb1a44dc21e5242874c624547d4c69191...e19dc449339e740a579d44e81ceed72ba56914e5
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list