medialibrary: Update to recent API changes

This commit is contained in:
Hugo Beauzée-Luyssen 2021-06-03 15:01:29 +02:00
parent f831ed899c
commit 5e40633713
9 changed files with 60 additions and 46 deletions

View File

@ -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

View File

@ -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;

View File

@ -190,7 +190,6 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
@property (readwrite) int lastTitle;
@property (readwrite) int lastChapter;
@property (readwrite) int lastProgram;
@property (readwrite) BOOL seen;
@property (readwrite) int lastVideoTrack;
@property (readwrite) NSString *lastAspectRatio;
@property (readwrite) NSString *lastZoom;

View File

@ -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];

View File

@ -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() );

View File

@ -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;

View File

@ -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;
};

View File

@ -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:

View File

@ -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,