Commit 57fb5cde authored by Sébastien Toque's avatar Sébastien Toque

Preview: Add language and frame rate for each track

parent 088cd004
From 283011cced8ee43f19747d14f5b257d0b00e5039 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Toque?= <xilasz@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
......@@ -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)
{
......
......@@ -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>
......@@ -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>
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment