[vlc-commits] [Git][videolan/vlc][master] 5 commits: macosx: Move artwork image generation out of playlist item and into playlist...

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Feb 7 06:31:07 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
53aa9e6d by Claudio Cambra at 2023-02-07T06:14:10+00:00
macosx: Move artwork image generation out of playlist item and into playlist able view cell, as we do with other data classes

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
7ac1f216 by Claudio Cambra at 2023-02-07T06:14:10+00:00
macosx: Add ability to fetch image for VLCPlaylistItem in VLCLibraryImageCache

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
cae196e9 by Claudio Cambra at 2023-02-07T06:14:10+00:00
macosx: Fetch thumbnail for playlist item that does not have a predefined artwork url

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
6f42c652 by Claudio Cambra at 2023-02-07T06:14:10+00:00
macosx: Always use the VLCLibraryImageCache in VLCPlaylistTableCellView

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
16668b08 by Claudio Cambra at 2023-02-07T06:14:10+00:00
macosx: Remove VLCPlaylistImageCache, which duplicates VLCLibraryImageCache and is no longer used

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


10 changed files:

- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/library/VLCLibraryImageCache.h
- modules/gui/macosx/library/VLCLibraryImageCache.m
- − modules/gui/macosx/playlist/VLCPlaylistImageCache.h
- − modules/gui/macosx/playlist/VLCPlaylistImageCache.m
- modules/gui/macosx/playlist/VLCPlaylistItem.h
- modules/gui/macosx/playlist/VLCPlaylistItem.m
- modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
- po/POTFILES.in


Changes:

=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -186,7 +186,6 @@
 		7DB7F20920CC07FD00C2CAED /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F20820CC07FD00C2CAED /* WebKit.framework */; };
 		7DB7F20B20CC082800C2CAED /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F20A20CC082800C2CAED /* QuartzCore.framework */; };
 		7DBB7639227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DBB7638227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m */; };
-		7DBFDD4723DE1FBB00722E3D /* VLCPlaylistImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DBFDD4623DE1FBB00722E3D /* VLCPlaylistImageCache.m */; };
 		7DC21A7422049A6600F98A02 /* VLCOpenInputMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC21A7322049A6600F98A02 /* VLCOpenInputMetadata.m */; };
 		7DD2F5C52081B73B007EE187 /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD2F5C42081B73B007EE187 /* VLCRemoteControlService.m */; };
 		7DE2F0442282C84A0040DD0A /* VLCLibraryAudioDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE2F0432282C84A0040DD0A /* VLCLibraryAudioDataSource.m */; };
@@ -656,8 +655,6 @@
 		7DBB06631CC2314D004C74D2 /* caopengllayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = caopengllayer.m; path = ../../../modules/video_output/caopengllayer.m; sourceTree = "<group>"; };
 		7DBB7637227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryCollectionViewSupplementaryElementView.h; sourceTree = "<group>"; };
 		7DBB7638227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryCollectionViewSupplementaryElementView.m; sourceTree = "<group>"; };
-		7DBFDD4523DE1FBB00722E3D /* VLCPlaylistImageCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistImageCache.h; sourceTree = "<group>"; };
-		7DBFDD4623DE1FBB00722E3D /* VLCPlaylistImageCache.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistImageCache.m; sourceTree = "<group>"; };
 		7DC21A7222049A6600F98A02 /* VLCOpenInputMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCOpenInputMetadata.h; sourceTree = "<group>"; };
 		7DC21A7322049A6600F98A02 /* VLCOpenInputMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCOpenInputMetadata.m; sourceTree = "<group>"; };
 		7DD2F5C32081B73B007EE187 /* VLCRemoteControlService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCRemoteControlService.h; sourceTree = "<group>"; };
@@ -1199,8 +1196,6 @@
 				7D0F640B2202163E00FDB91F /* VLCPlaylistDataSource.m */,
 				7D445D822202524D00263D34 /* VLCPlaylistItem.h */,
 				7D445D832202524D00263D34 /* VLCPlaylistItem.m */,
-				7DBFDD4523DE1FBB00722E3D /* VLCPlaylistImageCache.h */,
-				7DBFDD4623DE1FBB00722E3D /* VLCPlaylistImageCache.m */,
 				7D445D8C2203375100263D34 /* VLCPlaylistMenuController.h */,
 				7D445D8D2203375100263D34 /* VLCPlaylistMenuController.m */,
 				7D1BF28B22A192000027C50F /* VLCPlaylistSortingMenuController.h */,
@@ -1924,7 +1919,6 @@
 				7D404ABF2281892C00B28EF4 /* NSView+VLCAdditions.m in Sources */,
 				7DE9C7DD220728420089108F /* VLCPlayerController.m in Sources */,
 				536283F4291146BC00640C15 /* VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m in Sources */,
-				7DBFDD4723DE1FBB00722E3D /* VLCPlaylistImageCache.m in Sources */,
 				7D93D8FC2316C2DC001C0063 /* VLCCustomCropArWindowController.m in Sources */,
 				1C3113941E508C6900D4DD76 /* VLCAddonsWindowController.m in Sources */,
 				7D92AF2123DDCA8D00D81EA3 /* VLCLibraryImageCache.m in Sources */,


=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -211,8 +211,6 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/playlist/VLCPlaylistController.m \
 	gui/macosx/playlist/VLCPlaylistDataSource.h \
 	gui/macosx/playlist/VLCPlaylistDataSource.m \
-	gui/macosx/playlist/VLCPlaylistImageCache.h \
-	gui/macosx/playlist/VLCPlaylistImageCache.m \
 	gui/macosx/playlist/VLCPlaylistItem.h \
 	gui/macosx/playlist/VLCPlaylistItem.m \
 	gui/macosx/playlist/VLCPlaylistMenuController.h \


=====================================
modules/gui/macosx/library/VLCLibraryImageCache.h
=====================================
@@ -25,12 +25,14 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @class VLCInputItem;
+ at class VLCPlaylistItem;
 @protocol VLCMediaLibraryItemProtocol;
 
 @interface VLCLibraryImageCache : NSObject
 
 + (nullable NSImage *)thumbnailForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
 + (nullable NSImage *)thumbnailForInputItem:(VLCInputItem*)inputItem;
++ (nullable NSImage *)thumbnailForPlaylistItem:(VLCPlaylistItem*)playlistItem;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryImageCache.m
=====================================
@@ -27,6 +27,8 @@
 
 #import "main/VLCMain.h"
 
+#import "playlist/VLCPlaylistItem.h"
+
 NSUInteger kVLCMaximumLibraryImageCacheSize = 50;
 uint32_t kVLCDesiredThumbnailWidth = 512;
 uint32_t kVLCDesiredThumbnailHeight = 512;
@@ -143,4 +145,9 @@ float kVLCDefaultThumbnailPosition = .15;
     return image;
 }
 
++ (NSImage *)thumbnailForPlaylistItem:(VLCPlaylistItem *)playlistItem
+{
+    return [VLCLibraryImageCache.sharedImageCache imageForInputItem:playlistItem.inputItem];
+}
+
 @end


=====================================
modules/gui/macosx/playlist/VLCPlaylistImageCache.h deleted
=====================================
@@ -1,34 +0,0 @@
-/*****************************************************************************
-* VLCPlaylistImageCache.h: MacOS X interface module
-*****************************************************************************
-* Copyright (C) 2020 VLC authors and VideoLAN
-*
-* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
-*****************************************************************************/
-
-#import <Cocoa/Cocoa.h>
-#import <vlc_playlist.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
- at interface VLCPlaylistImageCache : NSObject
-
-+ (nullable NSImage *)artworkForPlaylistItemWithURL:(NSURL *)artworkURL;
-
- at end
-
-NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/playlist/VLCPlaylistImageCache.m deleted
=====================================
@@ -1,82 +0,0 @@
-/*****************************************************************************
-* VLCPlaylistImageCache.m: MacOS X interface module
-*****************************************************************************
-* Copyright (C) 2020 VLC authors and VideoLAN
-*
-* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org>
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
-*****************************************************************************/
-
-#import "VLCPlaylistImageCache.h"
-#import "extensions/NSString+Helpers.h"
-#import <vlc_input.h>
-#import <vlc_url.h>
-
-NSUInteger kVLCMaximumPlaylistImageCacheSize = 100;
-
- at interface VLCPlaylistImageCache()
-{
-    NSCache *_imageCache;
-}
- at end
-
- at implementation VLCPlaylistImageCache
-
-- (instancetype)init
-{
-    self = [super init];
-    if (self) {
-        _imageCache = [[NSCache alloc] init];
-        _imageCache.countLimit = kVLCMaximumPlaylistImageCacheSize;
-    }
-    return self;
-}
-
-+ (instancetype)sharedImageCache
-{
-    static dispatch_once_t onceToken;
-    static VLCPlaylistImageCache *sharedImageCache;
-    dispatch_once(&onceToken, ^{
-        sharedImageCache = [[VLCPlaylistImageCache alloc] init];
-    });
-    return sharedImageCache;
-}
-
-+ (NSImage *)artworkForPlaylistItemWithURL:(NSURL *)artworkURL
-{
-    return [[VLCPlaylistImageCache sharedImageCache] imageForPlaylistItemWithArtworkURL:artworkURL];
-}
-
-- (NSImage *)imageForPlaylistItemWithArtworkURL:(NSURL *)artworkURL
-{
-    if (artworkURL == nil) {
-        return nil;
-    }
-
-    NSImage *artwork = [_imageCache objectForKey:artworkURL];
-    if (artwork) {
-        return artwork;
-    }
-
-    artwork = [[NSImage alloc] initWithContentsOfURL:artworkURL];
-    if (artwork) {
-        [_imageCache setObject:artwork forKey:artworkURL];
-    }
-
-    return artwork;
-}
-
- at end


=====================================
modules/gui/macosx/playlist/VLCPlaylistItem.h
=====================================
@@ -43,7 +43,7 @@ extern NSString *VLCPlaylistItemPasteboardType;
 
 @property (readwrite, retain, nullable) NSString *artistName;
 @property (readwrite, retain, nullable) NSString *albumName;
- at property (readonly, copy) NSImage *artworkImage;
+ at property (readonly) NSURL *artworkURL;
 
 - (instancetype)initWithPlaylistItem:(vlc_playlist_item_t *)p_item;
 - (void)updateRepresentation;


=====================================
modules/gui/macosx/playlist/VLCPlaylistItem.m
=====================================
@@ -25,19 +25,12 @@
 #import <vlc_input.h>
 #import <vlc_url.h>
 
-#import "playlist/VLCPlaylistImageCache.h"
 #import "extensions/NSString+Helpers.h"
 #import "library/VLCInputItem.h"
 #import "library/VLCLibraryDataTypes.h"
 
 NSString *VLCPlaylistItemPasteboardType = @"org.videolan.vlc.playlistitemtype";
 
- at interface VLCPlaylistItem()
-{
-    NSURL *_artworkURL;
-}
- at end
-
 @implementation VLCPlaylistItem
 
 - (instancetype)initWithPlaylistItem:(vlc_playlist_item_t *)p_item
@@ -142,13 +135,4 @@ NSString *VLCPlaylistItemPasteboardType = @"org.videolan.vlc.playlistitemtype";
     return path;
 }
 
-- (NSImage *)artworkImage
-{
-    NSImage *image = [VLCPlaylistImageCache artworkForPlaylistItemWithURL:_artworkURL];
-    if (!image) {
-        image = [NSImage imageNamed: @"noart.png"];
-    }
-    return image;
-}
-
 @end


=====================================
modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
=====================================
@@ -21,11 +21,17 @@
  *****************************************************************************/
 
 #import "VLCPlaylistTableCellView.h"
+
 #import "extensions/NSString+Helpers.h"
 #import "extensions/NSFont+VLCAdditions.h"
+
+#import "library/VLCLibraryImageCache.h"
+
+#import "main/VLCMain.h"
+
 #import "playlist/VLCPlaylistItem.h"
+
 #import "views/VLCImageView.h"
-#import "main/VLCMain.h"
 
 @interface VLCPlaylistTableCellView ()
 {
@@ -62,6 +68,14 @@
 
 - (void)setRepresentedPlaylistItem:(VLCPlaylistItem *)item
 {
+    dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
+        NSImage *image = [VLCLibraryImageCache thumbnailForPlaylistItem:item];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            self.audioArtworkImageView.image = image;
+            self.mediaImageView.image = image;
+        });
+    });
+
     NSString *artist = item.artistName;
     if (artist && artist.length > 0) {
         self.mediaTitleTextField.hidden = YES;
@@ -69,17 +83,19 @@
         self.artistTextField.hidden = NO;
         self.secondaryMediaTitleTextField.stringValue = item.title;
         self.artistTextField.stringValue = artist;
-        self.audioArtworkImageView.image = item.artworkImage;
         self.audioMediaTypeIndicator.hidden = NO;
+
+        self.audioArtworkImageView.hidden = NO;
         self.mediaImageView.hidden = YES;
     } else {
         self.mediaTitleTextField.hidden = NO;
         self.secondaryMediaTitleTextField.hidden = YES;
         self.artistTextField.hidden = YES;
         self.mediaTitleTextField.stringValue = item.title;
-        self.mediaImageView.image = item.artworkImage;
-        self.audioArtworkImageView.hidden = YES;
         self.audioMediaTypeIndicator.hidden = YES;
+
+        self.audioArtworkImageView.hidden = YES;
+        self.mediaImageView.hidden = NO;
     }
 
     self.durationTextField.stringValue = [NSString stringWithTimeFromTicks:item.duration];


=====================================
po/POTFILES.in
=====================================
@@ -559,8 +559,6 @@ modules/gui/macosx/playlist/VLCPlaylistController.h
 modules/gui/macosx/playlist/VLCPlaylistController.m
 modules/gui/macosx/playlist/VLCPlaylistDataSource.h
 modules/gui/macosx/playlist/VLCPlaylistDataSource.m
-modules/gui/macosx/playlist/VLCPlaylistImageCache.h
-modules/gui/macosx/playlist/VLCPlaylistImageCache.m
 modules/gui/macosx/playlist/VLCPlaylistItem.h
 modules/gui/macosx/playlist/VLCPlaylistItem.m
 modules/gui/macosx/playlist/VLCPlaylistMenuController.h



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bec23231a2f7b5fb13d64dcaa1fbf6fbb4e4f7a0...16668b08237c918f6d4c9264c7b5cb778f6ca64e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bec23231a2f7b5fb13d64dcaa1fbf6fbb4e4f7a0...16668b08237c918f6d4c9264c7b5cb778f6ca64e
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