[vlc-commits] macosx/library data types: expose show episodes, movies and album tracks

Felix Paul Kühne git at videolan.org
Mon Apr 29 19:26:45 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Apr 21 18:45:55 2019 +0200| [a1006afe5e8e0b0dc9064d221bdc5ef971319857] | committer: Felix Paul Kühne

macosx/library data types: expose show episodes, movies and album tracks

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

 modules/gui/macosx/library/VLCLibraryDataTypes.h |  43 ++++++++-
 modules/gui/macosx/library/VLCLibraryDataTypes.m | 116 +++++++++++++++++------
 2 files changed, 127 insertions(+), 32 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index cb91ca7b2b..e2a9ac77ef 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCMediaLibraryFile : NSObject
 
-- (instancetype)initWithFile:(struct vlc_ml_file_t *)file;
+- (instancetype)initWithFile:(struct vlc_ml_file_t *)p_file;
 
 @property (readonly) NSString *MRL;
 @property (readonly) vlc_ml_file_type_t fileType;
@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCMediaLibraryTrack : NSObject
 
-- (instancetype)initWithTrack:(struct vlc_ml_media_track_t *)track;
+- (instancetype)initWithTrack:(struct vlc_ml_media_track_t *)p_track;
 
 @property (readonly) NSString *codec;
 @property (readonly) NSString *language;
@@ -59,6 +59,39 @@ NS_ASSUME_NONNULL_BEGIN
 
 @end
 
+ at interface VLCMediaLibraryMovie : NSObject
+
+- (instancetype)initWithMovie:(struct vlc_ml_movie_t *)p_movie;
+
+ at property (readonly) NSString *summary;
+ at property (readonly) NSString *imdbID;
+
+ at end
+
+ at interface VLCMediaLibraryShowEpisode : NSObject
+
+- (instancetype)initWithShowEpisode:(struct vlc_ml_show_episode_t *)p_showEpisode;
+
+ at property (readonly) NSString *summary;
+ at property (readonly) NSString *tvdbID;
+ at property (readonly) uint32_t episodeNumber;
+ at property (readonly) uint32_t seasonNumber;
+
+ at end
+
+ at interface VLCMediaLibraryAlbumTrack : NSObject
+
+- (instancetype)initWithAlbumTrack:(struct vlc_ml_album_track_t *)p_albumTrack;
+
+ at property (readonly) int64_t artistID;
+ at property (readonly) int64_t albumID;
+ at property (readonly) int64_t genreID;
+
+ at property (readonly) int trackNumber;
+ at property (readonly) int discNumber;
+
+ at end
+
 @interface VLCMediaLibraryMediaItem : NSObject
 
 - (instancetype)initWithMediaItem:(struct vlc_ml_media_t *)mediaItem;
@@ -81,9 +114,9 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) BOOL artworkGenerated;
 @property (readonly) BOOL favorited;
 
- at property (readonly) vlc_ml_show_episode_t showEpisode;
- at property (readonly) vlc_ml_movie_t movie;
- at property (readonly) vlc_ml_album_track_t albumTrack;
+ at property (readonly, nullable) VLCMediaLibraryShowEpisode *showEpisode;
+ at property (readonly, nullable) VLCMediaLibraryMovie *movie;
+ at property (readonly, nullable) VLCMediaLibraryAlbumTrack *albumTrack;
 
 @end
 
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index b3cf00fcbf..a42a2e6306 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -26,15 +26,15 @@
 
 @implementation VLCMediaLibraryFile
 
-- (instancetype)initWithFile:(struct vlc_ml_file_t *)file
+- (instancetype)initWithFile:(struct vlc_ml_file_t *)p_file
 {
     self = [super init];
-    if (self && file != NULL) {
-        _MRL = toNSStr(file->psz_mrl);
-        _fileType = file->i_type;
-        _external = file->b_external;
-        _removable = file->b_removable;
-        _present = file->b_present;
+    if (self && p_file != NULL) {
+        _MRL = toNSStr(p_file->psz_mrl);
+        _fileType = p_file->i_type;
+        _external = p_file->b_external;
+        _removable = p_file->b_removable;
+        _present = p_file->b_present;
     }
     return self;
 }
@@ -48,25 +48,25 @@
 
 @implementation VLCMediaLibraryTrack
 
-- (instancetype)initWithTrack:(struct vlc_ml_media_track_t *)track
+- (instancetype)initWithTrack:(struct vlc_ml_media_track_t *)p_track
 {
     self = [super init];
-    if (self && track != NULL) {
-        _codec = toNSStr(track->psz_codec);
-        _language = toNSStr(track->psz_language);
-        _trackDescription = toNSStr(track->psz_description);
-        _trackType = track->i_type;
-        _bitrate = track->i_bitrate;
-
-        _numberOfAudioChannels = track->a.i_nbChannels;
-        _audioSampleRate = track->a.i_sampleRate;
-
-        _videoHeight = track->v.i_height;
-        _videoWidth = track->v.i_width;
-        _sourceAspectRatio = track->v.i_sarNum;
-        _sourceAspectRatioDenominator = track->v.i_sarDen;
-        _frameRate = track->v.i_fpsNum;
-        _frameRateDenominator = track->v.i_fpsDen;
+    if (self && p_track != NULL) {
+        _codec = toNSStr(p_track->psz_codec);
+        _language = toNSStr(p_track->psz_language);
+        _trackDescription = toNSStr(p_track->psz_description);
+        _trackType = p_track->i_type;
+        _bitrate = p_track->i_bitrate;
+
+        _numberOfAudioChannels = p_track->a.i_nbChannels;
+        _audioSampleRate = p_track->a.i_sampleRate;
+
+        _videoHeight = p_track->v.i_height;
+        _videoWidth = p_track->v.i_width;
+        _sourceAspectRatio = p_track->v.i_sarNum;
+        _sourceAspectRatioDenominator = p_track->v.i_sarDen;
+        _frameRate = p_track->v.i_fpsNum;
+        _frameRateDenominator = p_track->v.i_fpsDen;
     }
     return self;
 }
@@ -78,6 +78,54 @@
 
 @end
 
+ at implementation VLCMediaLibraryMovie
+
+- (instancetype)initWithMovie:(struct vlc_ml_movie_t *)p_movie
+{
+    self = [super init];
+    if (self && p_movie != NULL) {
+        _summary = toNSStr(p_movie->psz_summary);
+        _imdbID = toNSStr(p_movie->psz_imdb_id);
+    }
+    return self;
+}
+
+ at end
+
+ at implementation VLCMediaLibraryShowEpisode
+
+- (instancetype)initWithShowEpisode:(struct vlc_ml_show_episode_t *)p_showEpisode
+{
+    self = [super init];
+    if (self && p_showEpisode != NULL) {
+        _summary = toNSStr(p_showEpisode->psz_summary);
+        _tvdbID = toNSStr(p_showEpisode->psz_tvdb_id);
+        _episodeNumber = p_showEpisode->i_episode_nb;
+        _seasonNumber = p_showEpisode->i_season_number;
+    }
+    return self;
+}
+
+ at end
+
+ at implementation VLCMediaLibraryAlbumTrack
+
+- (instancetype)initWithAlbumTrack:(struct vlc_ml_album_track_t *)p_albumTrack
+{
+    self = [super init];
+    if (self && p_albumTrack != NULL) {
+        _artistID = p_albumTrack->i_artist_id;
+        _albumID = p_albumTrack->i_album_id;
+        _genreID = p_albumTrack->i_genre_id;
+
+        _trackNumber = p_albumTrack->i_track_nb;
+        _discNumber = p_albumTrack->i_disc_nb;
+    }
+    return self;
+}
+
+ at end
+
 @implementation VLCMediaLibraryMediaItem
 
 - (instancetype)initWithMediaItem:(struct vlc_ml_media_t *)p_mediaItem
@@ -111,9 +159,23 @@
         _artworkMRL = toNSStr(p_mediaItem->psz_artwork_mrl);
         _artworkGenerated = p_mediaItem->b_artwork_generated;
         _favorited = p_mediaItem->b_is_favorite;
-        _showEpisode = p_mediaItem->show_episode;
-        _movie = p_mediaItem->movie;
-        _albumTrack = p_mediaItem->album_track;
+
+        switch (p_mediaItem->i_subtype) {
+            case VLC_ML_MEDIA_SUBTYPE_MOVIE:
+                _movie = [[VLCMediaLibraryMovie alloc] initWithMovie:&p_mediaItem->movie];
+                break;
+
+            case VLC_ML_MEDIA_SUBTYPE_SHOW_EPISODE:
+                _showEpisode = [[VLCMediaLibraryShowEpisode alloc] initWithShowEpisode:&p_mediaItem->show_episode];
+                break;
+
+            case VLC_ML_MEDIA_SUBTYPE_ALBUMTRACK:
+                _albumTrack = [[VLCMediaLibraryAlbumTrack alloc] initWithAlbumTrack:&p_mediaItem->album_track];
+                break;
+
+            default:
+                break;
+        }
     }
     return self;
 }



More information about the vlc-commits mailing list