[vlc-devel] [PATCHv3 12/17] lib: video: use libvlc_media_player_get_selected_track()

Thomas Guillem thomas at gllm.fr
Wed Jun 10 14:57:51 CEST 2020


---
 lib/video.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/video.c b/lib/video.c
index a31db38524d..07e26c038b5 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -155,25 +155,25 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
     return 0;
 }
 
-int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
+int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned ignored,
                            unsigned *restrict px, unsigned *restrict py )
 {
+    (void) ignored;
     if (p_mi->p_md == NULL)
         return -1;
 
-    libvlc_media_track_t **tracks;
-    unsigned count = libvlc_media_tracks_get(p_mi->p_md, &tracks);
     int ret = -1;
+    libvlc_media_track_t *track =
+        libvlc_media_player_get_selected_track( p_mi, libvlc_track_video );
 
-    for (unsigned i = 0; i < count; i++)
-        if (tracks[i]->i_type == libvlc_track_video && num-- == 0) {
-            *px = tracks[i]->video->i_width;
-            *py = tracks[i]->video->i_height;
-            ret = 0;
-            break;
-        }
+    if (track)
+    {
+        *px = track->video->i_width;
+        *py = track->video->i_height;
+        ret = 0;
+    }
 
-    libvlc_media_tracks_release(tracks, count);
+    libvlc_media_track_release(track);
     return ret;
 }
 
-- 
2.20.1



More information about the vlc-devel mailing list