[vlc-devel] [PATCH 3/7] player: Update media type when it is unknown
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Jan 6 13:38:46 CET 2020
---
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))
--
2.20.1
More information about the vlc-devel
mailing list