[vlc-commits] [Git][videolan/vlc][master] 2 commits: medialibrary: Update to recent API changes
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri Sep 10 09:52:38 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
5e406337 by Hugo Beauzée-Luyssen at 2021-09-10T08:49:48+00:00
medialibrary: Update to recent API changes
- - - - -
a95365ba by Hugo Beauzée-Luyssen at 2021-09-10T08:49:48+00:00
contrib: Bump medialibrary
- - - - -
10 changed files:
- configure.ac
- contrib/src/medialibrary/rules.mak
- include/vlc_media_library.h
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/misc/medialibrary/entities.cpp
- modules/misc/medialibrary/fs/fs.cpp
- modules/misc/medialibrary/fs/fs.h
- modules/misc/medialibrary/medialibrary.cpp
- modules/misc/medialibrary/medialibrary.h
Changes:
=====================================
configure.ac
=====================================
@@ -4355,7 +4355,7 @@ dnl Libnotify notification plugin
dnl
PKG_ENABLE_MODULES_VLC([NOTIFY], [], [libnotify], [libnotify notification], [auto])
-PKG_ENABLE_MODULES_VLC([MEDIALIBRARY], [medialibrary], [medialibrary >= 0.9.2], (medialibrary support), [auto])
+PKG_ENABLE_MODULES_VLC([MEDIALIBRARY], [medialibrary], [medialibrary >= 0.9.3], (medialibrary support), [auto])
dnl
dnl Endianness check
=====================================
contrib/src/medialibrary/rules.mak
=====================================
@@ -1,9 +1,9 @@
-MEDIALIBRARY_HASH := f541a77c9a3b107970e5650d8db2de0294aea8c3
+MEDIALIBRARY_HASH := 363bb8fcf50851a0ce7438ee5a9ad35f6f8954d0
MEDIALIBRARY_VERSION := git-$(MEDIALIBRARY_HASH)
MEDIALIBRARY_GITURL := https://code.videolan.org/videolan/medialibrary.git
PKGS += medialibrary
-ifeq ($(call need_pkg,"medialibrary >= 0.9.2"),)
+ifeq ($(call need_pkg,"medialibrary >= 0.9.3"),)
PKGS_FOUND += medialibrary
endif
=====================================
include/vlc_media_library.h
=====================================
@@ -575,7 +575,6 @@ enum vlc_ml_playback_state
VLC_ML_PLAYBACK_STATE_TITLE,
VLC_ML_PLAYBACK_STATE_CHAPTER,
VLC_ML_PLAYBACK_STATE_PROGRAM,
- VLC_ML_PLAYBACK_STATE_SEEN,
VLC_ML_PLAYBACK_STATE_VIDEO_TRACK,
VLC_ML_PLAYBACK_STATE_ASPECT_RATIO,
VLC_ML_PLAYBACK_STATE_ZOOM,
@@ -638,11 +637,13 @@ enum vlc_ml_event_type
VLC_ML_EVENT_BOOKMARKS_DELETED,
/**
* A discovery started.
- * For each VLC_ML_EVENT_DISCOVERY_STARTED event, there will be
- * 1 VLC_ML_EVENT_DISCOVERY_COMPLETED event, and N
- * VLC_ML_EVENT_DISCOVERY_PROGRESS events.
- * The entry point being discovered is stored in
- * vlc_ml_event_t::discovery_started::psz_entry_point.
+ *
+ * This event will be emitted when the media library starts discovering a
+ * scheduled entry point.
+ * If more than a single entry point are queued, this event won't be fired
+ * again until all operations are completed and a new operation is scheduled.
+ * Once all currently queued operations are done
+ * VLC_ML_EVENT_DISCOVERY_COMPLETED will be emitted.
*/
VLC_ML_EVENT_DISCOVERY_STARTED,
/**
@@ -652,13 +653,15 @@ enum vlc_ml_event_type
*/
VLC_ML_EVENT_DISCOVERY_PROGRESS,
/**
- * Sent when an entry point discovery is completed.
- * The entry point that was being discovered is stored in
- * vlc_ml_event_t::discovery_completed::psz_entry_point.
- * The success or failure state is stored in
- * vlc_ml_event_t::discovery_completed::b_success
+ * Sent when all queued discovery operations are done being processed.
*/
VLC_ML_EVENT_DISCOVERY_COMPLETED,
+ /**
+ * This event is sent when a discovery failed. The entry point that failed to
+ * be discovered is stored in
+ * vlc_ml_event_t::discovery_failed::psz_entry_point
+ */
+ VLC_ML_EVENT_DISCOVERY_FAILED,
/**
* Sent when a new entry point gets added to the database.
* The entry point that was added is stored in
@@ -730,10 +733,6 @@ typedef struct vlc_ml_event_t
int i_type;
union
{
- struct
- {
- const char* psz_entry_point;
- } discovery_started;
struct
{
const char* psz_entry_point;
@@ -741,8 +740,7 @@ typedef struct vlc_ml_event_t
struct
{
const char* psz_entry_point;
- bool b_success;
- } discovery_completed;
+ } discovery_failed;
struct
{
const char* psz_entry_point;
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -190,7 +190,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
@property (readwrite) int lastTitle;
@property (readwrite) int lastChapter;
@property (readwrite) int lastProgram;
- at property (readwrite) BOOL seen;
@property (readwrite) int lastVideoTrack;
@property (readwrite) NSString *lastAspectRatio;
@property (readwrite) NSString *lastZoom;
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -639,16 +639,6 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
[self setIntegerPreference:lastProgram forKey:VLC_ML_PLAYBACK_STATE_PROGRAM];
}
-- (BOOL)seen
-{
- return [self integerPreferenceForKey:VLC_ML_PLAYBACK_STATE_SEEN] > 0 ? YES : NO;
-}
-
-- (void)setSeen:(BOOL)seen
-{
- [self setIntegerPreference:seen forKey:VLC_ML_PLAYBACK_STATE_SEEN];
-}
-
- (int)lastVideoTrack
{
return [self integerPreferenceForKey:VLC_ML_PLAYBACK_STATE_VIDEO_TRACK];
=====================================
modules/misc/medialibrary/entities.cpp
=====================================
@@ -252,7 +252,7 @@ bool Convert( const medialibrary::IMedia* input, vlc_ml_media_t& output )
output.i_duration = input->duration();
output.b_is_favorite = input->isFavorite();
output.i_playcount = input->playCount();
- output.f_progress = input->progress();
+ output.f_progress = input->lastPosition();
output.i_last_played_date = input->lastPlayedDate();
output.psz_title = strdup( input->title().c_str() );
=====================================
modules/misc/medialibrary/fs/fs.cpp
=====================================
@@ -172,6 +172,19 @@ void vlc::medialibrary::SDFileSystemFactory::onDeviceUnmounted(const std::string
m_callbacks->onDeviceUnmounted(*device, mountpoint);
}
+bool SDFileSystemFactory::waitForDevice(const std::string& mrl,
+ uint32_t timeout) const
+{
+ auto deadline = vlc_tick_now() + VLC_TICK_FROM_MS(timeout);
+ vlc::threads::mutex_locker lock{ m_mutex };
+ while ( deviceByMrl(mrl) == nullptr )
+ {
+ if ( m_cond.timedwait(m_mutex, deadline) != 0 )
+ return false;
+ }
+ return true;
+}
+
std::shared_ptr<IDevice> SDFileSystemFactory::deviceByUuid(const std::string& uuid)
{
auto it = std::find_if( begin( m_devices ), end( m_devices ),
@@ -188,7 +201,7 @@ bool SDFileSystemFactory::isStarted() const
return m_callbacks != nullptr;
}
-std::shared_ptr<IDevice> SDFileSystemFactory::deviceByMrl(const std::string& mrl)
+std::shared_ptr<IDevice> SDFileSystemFactory::deviceByMrl(const std::string& mrl) const
{
std::shared_ptr<fs::IDevice> res;
std::string mountpoint;
=====================================
modules/misc/medialibrary/fs/fs.h
=====================================
@@ -87,13 +87,16 @@ public:
void
onDeviceUnmounted(const std::string& uuid, const std::string& mountpoint) override;
+ bool
+ waitForDevice(const std::string& mrl, uint32_t timeout) const override;
+
private:
std::shared_ptr<fs::IDevice>
deviceByUuid(const std::string& uuid);
bool isStarted() const override;
- std::shared_ptr<fs::IDevice> deviceByMrl(const std::string& mrl);
+ std::shared_ptr<fs::IDevice> deviceByMrl(const std::string& mrl) const;
private:
vlc_object_t *const m_parent;
@@ -103,7 +106,8 @@ private:
IFileSystemFactoryCb *m_callbacks;
bool m_isNetwork;
- vlc::threads::mutex m_mutex;
+ mutable vlc::threads::mutex m_mutex;
+ mutable vlc::threads::condition_variable m_cond;
std::vector<std::shared_ptr<IDevice>> m_devices;
};
=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -150,6 +150,10 @@ void MediaLibrary::onMediaDeleted( std::set<int64_t> mediaIds )
wrapEntityDeletedEventCallback( m_vlc_ml, mediaIds, VLC_ML_EVENT_MEDIA_DELETED );
}
+void MediaLibrary::onMediaConvertedToExternal(std::set<int64_t>)
+{
+}
+
void MediaLibrary::onArtistsAdded( std::vector<medialibrary::ArtistPtr> artists )
{
wrapEntityCreatedEventCallback<vlc_ml_artist_t>( m_vlc_ml, artists, VLC_ML_EVENT_ARTIST_ADDED );
@@ -248,11 +252,10 @@ void MediaLibrary::onBookmarksDeleted( std::set<int64_t> bookmarkIds )
VLC_ML_EVENT_BOOKMARKS_DELETED );
}
-void MediaLibrary::onDiscoveryStarted( const std::string& entryPoint )
+void MediaLibrary::onDiscoveryStarted()
{
vlc_ml_event_t ev;
ev.i_type = VLC_ML_EVENT_DISCOVERY_STARTED;
- ev.discovery_started.psz_entry_point = entryPoint.c_str();
m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
@@ -264,15 +267,22 @@ void MediaLibrary::onDiscoveryProgress( const std::string& entryPoint )
m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
-void MediaLibrary::onDiscoveryCompleted( const std::string& entryPoint, bool success )
+void MediaLibrary::onDiscoveryCompleted()
{
vlc_ml_event_t ev;
ev.i_type = VLC_ML_EVENT_DISCOVERY_COMPLETED;
- ev.discovery_completed.psz_entry_point = entryPoint.c_str();
- ev.discovery_completed.b_success = success;
m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
+void MediaLibrary::onDiscoveryFailed( const std::string& entryPoint )
+{
+ vlc_ml_event_t ev;
+ ev.i_type = VLC_ML_EVENT_DISCOVERY_FAILED;
+ ev.discovery_failed.psz_entry_point = entryPoint.c_str();
+ m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
+}
+
+
void MediaLibrary::onEntryPointAdded( const std::string& entryPoint, bool success )
{
vlc_ml_event_t ev;
@@ -309,11 +319,11 @@ void MediaLibrary::onEntryPointUnbanned( const std::string& entryPoint, bool suc
m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
-void MediaLibrary::onParsingStatsUpdated( uint32_t progress )
+void MediaLibrary::onParsingStatsUpdated( uint32_t done, uint32_t scheduled )
{
vlc_ml_event_t ev;
ev.i_type = VLC_ML_EVENT_PARSING_PROGRESS_UPDATED;
- ev.parsing_progress.i_percent = progress;
+ ev.parsing_progress.i_percent = (float)done / (float)scheduled * 100.f;
m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
@@ -1162,8 +1172,6 @@ medialibrary::IMedia::MetadataType MediaLibrary::metadataType( int meta )
return medialibrary::IMedia::MetadataType::Chapter;
case VLC_ML_PLAYBACK_STATE_PROGRAM:
return medialibrary::IMedia::MetadataType::Program;
- case VLC_ML_PLAYBACK_STATE_SEEN:
- return medialibrary::IMedia::MetadataType::Seen;
case VLC_ML_PLAYBACK_STATE_VIDEO_TRACK:
return medialibrary::IMedia::MetadataType::VideoTrack;
case VLC_ML_PLAYBACK_STATE_ASPECT_RATIO:
@@ -1349,7 +1357,7 @@ int MediaLibrary::controlMedia( int query, va_list args )
switch( query )
{
case VLC_ML_MEDIA_UPDATE_PROGRESS:
- if ( m->setProgress( va_arg( args, double ) ) == false )
+ if ( m->setLastPosition( va_arg( args, double ) ) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
case VLC_ML_MEDIA_GET_MEDIA_PLAYBACK_STATE:
=====================================
modules/misc/medialibrary/medialibrary.h
=====================================
@@ -198,6 +198,7 @@ public:
virtual void onMediaAdded(std::vector<medialibrary::MediaPtr> media) override;
virtual void onMediaModified(std::set<int64_t> media) override;
virtual void onMediaDeleted(std::set<int64_t> mediaIds) override;
+ virtual void onMediaConvertedToExternal(std::set<int64_t> mediaIds) override;
virtual void onArtistsAdded(std::vector<medialibrary::ArtistPtr> artists) override;
virtual void onArtistsModified(std::set<int64_t> artists) override;
virtual void onArtistsDeleted(std::set<int64_t> artistsIds) override;
@@ -216,14 +217,15 @@ public:
virtual void onBookmarksAdded( std::vector<medialibrary::BookmarkPtr> bookmarks ) override;
virtual void onBookmarksModified( std::set<int64_t> bookmarksIds ) override;
virtual void onBookmarksDeleted( std::set<int64_t> bookmarksIds ) override;
- virtual void onDiscoveryStarted(const std::string& entryPoint) override;
+ virtual void onDiscoveryStarted() override;
virtual void onDiscoveryProgress(const std::string& entryPoint) override;
- virtual void onDiscoveryCompleted(const std::string& entryPoint, bool success) override;
+ virtual void onDiscoveryCompleted() override;
+ virtual void onDiscoveryFailed( const std::string& entryPoint ) override;
virtual void onEntryPointAdded(const std::string& entryPoint, bool success) override;
virtual void onEntryPointRemoved(const std::string& entryPoint, bool success) override;
virtual void onEntryPointBanned(const std::string& entryPoint, bool success) override;
virtual void onEntryPointUnbanned(const std::string& entryPoint, bool success) override;
- virtual void onParsingStatsUpdated(uint32_t percent) override;
+ virtual void onParsingStatsUpdated(uint32_t done, uint32_t scheduled) override;
virtual void onBackgroundTasksIdleChanged(bool isIdle) override;
virtual void onMediaThumbnailReady(medialibrary::MediaPtr media,
medialibrary::ThumbnailSizeType sizeType,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f831ed899c4d2d3af15ad8ff706cae3f6c98fb2a...a95365ba80b8696cc54ee76fbaa85a3e48fc0af8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f831ed899c4d2d3af15ad8ff706cae3f6c98fb2a...a95365ba80b8696cc54ee76fbaa85a3e48fc0af8
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list