[Android] Preview: Add language and frame rate for each track

Sébastien Toque git at videolan.org
Wed Apr 11 21:44:46 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Apr 11 21:39:49 2012 +0200| [57fb5cde432a24c61cf95da8831eed645160b17c] | committer: Sébastien Toque

Preview: Add language and frame rate for each track

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=57fb5cde432a24c61cf95da8831eed645160b17c
---

 ...language-and-frame-rate-to-libvlc_media_t.patch |   56 ++++++++++++++++++++
 vlc-android/jni/libvlcjni.c                        |   19 +++++++
 vlc-android/res/values-fr/strings.xml              |    7 ++-
 vlc-android/res/values/strings.xml                 |    7 ++-
 vlc-android/src/org/videolan/vlc/TrackInfo.java    |    2 +
 .../videolan/vlc/gui/video/MediaInfoAdapter.java   |    7 ++-
 6 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/patches/0003-libvlc-add-language-and-frame-rate-to-libvlc_media_t.patch b/patches/0003-libvlc-add-language-and-frame-rate-to-libvlc_media_t.patch
new file mode 100644
index 0000000..d12f362
--- /dev/null
+++ b/patches/0003-libvlc-add-language-and-frame-rate-to-libvlc_media_t.patch
@@ -0,0 +1,56 @@
+From 283011cced8ee43f19747d14f5b257d0b00e5039 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=A9bastien=20Toque?= <xilasz at gmail.com>
+Date: Wed, 11 Apr 2012 21:30:31 +0200
+Subject: [PATCH 3/3] libvlc: add language and frame rate to
+ libvlc_media_track_info_t
+
+---
+ include/vlc/libvlc_media.h |    3 +++
+ lib/media.c                |    3 +++
+ 2 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
+index 279a29c..e43a5b4 100644
+--- a/include/vlc/libvlc_media.h
++++ b/include/vlc/libvlc_media.h
+@@ -150,6 +150,8 @@ typedef struct libvlc_media_track_info_t
+     int         i_id;
+     libvlc_track_type_t i_type;
+ 
++    char        *psz_language;
++
+     /* Codec specific */
+     int         i_profile;
+     int         i_level;
+@@ -164,6 +166,7 @@ typedef struct libvlc_media_track_info_t
+             /* Video specific */
+             unsigned    i_height;
+             unsigned    i_width;
++            float       f_frame_rate;
+         } video;
+     } u;
+ 
+diff --git a/lib/media.c b/lib/media.c
+index 2c01c80..4bc832b 100644
+--- a/lib/media.c
++++ b/lib/media.c
+@@ -707,6 +707,8 @@ libvlc_media_get_tracks_info( libvlc_media_t *p_md, libvlc_media_track_info_t **
+         p_mes->i_codec = p_es->i_codec;
+         p_mes->i_id = p_es->i_id;
+ 
++        p_mes->psz_language = p_es->psz_language != NULL ? strdup(p_es->psz_language) : NULL;
++
+         p_mes->i_profile = p_es->i_profile;
+         p_mes->i_level = p_es->i_level;
+ 
+@@ -720,6 +722,7 @@ libvlc_media_get_tracks_info( libvlc_media_t *p_md, libvlc_media_track_info_t **
+             p_mes->i_type = libvlc_track_video;
+             p_mes->u.video.i_height = p_es->video.i_height;
+             p_mes->u.video.i_width = p_es->video.i_width;
++            p_mes->u.video.f_frame_rate = p_es->video.i_frame_rate / (float) p_es->video.i_frame_rate_base;
+             break;
+         case AUDIO_ES:
+             p_mes->i_type = libvlc_track_audio;
+-- 
+1.7.5.4
+
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index c402558..d2c6af3 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -344,6 +344,22 @@ void setInt(JNIEnv *env, jobject item, const char* field, int value)
     (*env)->SetIntField(env, item, fieldId, value);
 }
 
+void SetFloat(JNIEnv *env, jobject item, const char* field, float value)
+{
+    jclass cls;
+    jfieldID fieldId;
+
+    /* Get a reference to item's class */
+    cls = (*env)->GetObjectClass(env, item);
+
+    /* Look for the instance field s in cls */
+    fieldId = (*env)->GetFieldID(env, cls, field, "F");
+    if (fieldId == NULL)
+        return;
+
+    (*env)->SetFloatField(env, item, fieldId, value);
+}
+
 void setString(JNIEnv *env, jobject item, const char* field, const char* text)
 {
     jclass cls;
@@ -537,11 +553,14 @@ jobjectArray Java_org_videolan_vlc_LibVLC_readTracksInfo(JNIEnv *env, jobject th
             setInt(env, item, "Id", p_tracks[i].i_id);
             setInt(env, item, "Type", p_tracks[i].i_type);
             setString(env, item, "Codec", (const char*)vlc_fourcc_GetDescription(0,p_tracks[i].i_codec));
+            setString(env, item, "Language", p_tracks[i].psz_language);
+            free(p_tracks[i].psz_language);
 
             if (p_tracks[i].i_type == libvlc_track_video)
             {
                 setInt(env, item, "Height", p_tracks[i].u.video.i_height);
                 setInt(env, item, "Width", p_tracks[i].u.video.i_width);
+                SetFloat(env, item, "Framerate", p_tracks[i].u.video.f_frame_rate);
             }
             if (p_tracks[i].i_type == libvlc_track_audio)
             {
diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index ce532f6..6ae35a1 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -69,11 +69,12 @@
     <string name="refresh">Rafraîchir</string>
     <string name="track_audio">Piste audio</string>
     <plurals name="track_audio_info">
-        <item quantity="one">Codec: %1$s\n%2$d canal\nFréquence d\'échantillonage: %3$d Hz</item>
-        <item quantity="other">Codec: %1$s\n%2$d canaux\nFréquence d\'échantillonage: %3$d Hz</item>
+        <item quantity="one">Codec: %1$s\nLangue: %2$s\n%3$d canal\nFréquence d\'échantillonage: %4$d Hz</item>
+        <item quantity="other">Codec: %1$s\nLangue: %2$s\n%3$d canaux\nFréquence d\'échantillonage: %4$d Hz</item>
     </plurals>
     <string name="track_video">Piste vidéo</string>
-    <string name="track_video_info">Codec: %1$s\nRésolution: %2$dx%3$d</string>
+    <string name="track_video_info">Codec: %1$s\nLangue: %2$s\nRésolution: %3$dx%4$d\nDébit d\'images: %5$.3f</string>
     <string name="track_text">Piste sous-titres</string>
+    <string name="track_text_info">Codec: %1$s\nLangue: %2$s</string>
     <string name="track_unknown">Piste inconnue</string>
 </resources>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 541132b..74efb52 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -71,11 +71,12 @@
     <string name="refresh">Refresh</string>
     <string name="track_audio">Audio track</string>
     <plurals name="track_audio_info">
-        <item quantity="one">Codec: %1$s\n%2$d channel\nSample rate: %3$d Hz</item>
-        <item quantity="other">Codec: %1$s\n%2$d channels\nSample rate: %3$d Hz</item>
+        <item quantity="one">Codec: %1$s\nLanguage: %2$s\n%3$d channel\nSample rate: %4$d Hz</item>
+        <item quantity="other">Codec: %1$s\nLanguage: %2$s\n%3$d channels\nSample rate: %4$d Hz</item>
     </plurals>
     <string name="track_video">Video track</string>
-    <string name="track_video_info">Codec: %1$s\nResolution: %2$dx%3$d</string>
+    <string name="track_video_info">Codec: %1$s\nLanguage: %2$s\nResolution: %3$dx%4$d\nFrame rate: %5$.3f</string>
     <string name="track_text">Subtitles track</string>
+    <string name="track_text_info">Codec: %1$s\nLanguage: %2$s</string>
     <string name="track_unknown">Unknown track</string>
 </resources>
diff --git a/vlc-android/src/org/videolan/vlc/TrackInfo.java b/vlc-android/src/org/videolan/vlc/TrackInfo.java
index 9c8697e..d5268f0 100644
--- a/vlc-android/src/org/videolan/vlc/TrackInfo.java
+++ b/vlc-android/src/org/videolan/vlc/TrackInfo.java
@@ -10,10 +10,12 @@ public class TrackInfo {
     public int Type;
     public int Id;
     public String Codec;
+    public String Language;
 
     /* Video */
     public int Height;
     public int Width;
+    public float Framerate;
 
     /* Audio */
     public int Channels;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
index c2a7d92..6f60105 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
@@ -52,6 +52,7 @@ public class MediaInfoAdapter extends ArrayAdapter<TrackInfo> {
             holder = (ViewHolder) v.getTag();
 
         TrackInfo track = getItem(position);
+        String language = track.Language != null ? track.Language : "und";
         String title;
         String text;
         Resources res = getContext().getResources();
@@ -59,15 +60,15 @@ public class MediaInfoAdapter extends ArrayAdapter<TrackInfo> {
         {
             case TrackInfo.TYPE_AUDIO:
                 title = res.getString(R.string.track_audio);
-                text = res.getQuantityString(R.plurals.track_audio_info, track.Channels, track.Codec, track.Channels, track.Samplerate);
+                text = res.getQuantityString(R.plurals.track_audio_info, track.Channels, track.Codec, language, track.Channels, track.Samplerate);
                 break;
             case TrackInfo.TYPE_VIDEO:
                 title = res.getString(R.string.track_video);
-                text = res.getString(R.string.track_video_info, track.Codec, track.Width, track.Height);
+                text = res.getString(R.string.track_video_info, track.Codec, language, track.Width, track.Height, track.Framerate);
                 break;
             case TrackInfo.TYPE_TEXT:
                 title = res.getString(R.string.track_text);
-                text = track.Codec;
+                text = res.getString(R.string.track_text_info, track.Codec, language);
                 break;
             default:
                 title = res.getString(R.string.track_unknown);



More information about the Android mailing list