[vlc-commits] player: Update media type when it is unknown
Hugo Beauzée-Luyssen
git at videolan.org
Thu Jan 9 16:54:44 CET 2020
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Nov 26 16:13:32 2019 +0100| [a71dd3df85822324d1bcbe7f4608f14fd8249b58] | committer: Hugo Beauzée-Luyssen
player: Update media type when it is unknown
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a71dd3df85822324d1bcbe7f4608f14fd8249b58
---
src/player/medialib.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/player/medialib.c b/src/player/medialib.c
index 1d2665c17c..27f51b6970 100644
--- a/src/player/medialib.c
+++ b/src/player/medialib.c
@@ -129,6 +129,24 @@ end_of_media(struct vlc_player_input *input)
input->length - input->time < VLC_TICK_FROM_SEC(end_of_media_sec);
}
+static bool
+vlc_player_UpdateMediaType(const struct vlc_player_input* input,
+ vlc_medialibrary_t* ml, vlc_ml_media_t* media)
+{
+ assert(media->i_type == VLC_ML_MEDIA_TYPE_UNKNOWN);
+ vlc_ml_media_type_t media_type;
+ if (input->video_track_vector.size > 0)
+ media_type = VLC_ML_MEDIA_TYPE_VIDEO;
+ else if (input->audio_track_vector.size > 0)
+ media_type = VLC_ML_MEDIA_TYPE_AUDIO;
+ else
+ return false;
+ if (vlc_ml_media_set_type(ml, media->i_id, media_type) != VLC_SUCCESS)
+ return false;
+ media->i_type = media_type;
+ return true;
+}
+
void
vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
{
@@ -154,6 +172,13 @@ vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
return;
}
+ if (media->i_type == VLC_ML_MEDIA_TYPE_UNKNOWN)
+ {
+ if (!vlc_player_UpdateMediaType(input, ml, media))
+ return;
+ }
+ assert(media->i_type != VLC_ML_MEDIA_TYPE_UNKNOWN);
+
/* If we reached end of the media, bump the play count & the media in the
* history */
if (end_of_media(input))
More information about the vlc-commits
mailing list