discoverer: retrieve audio track language from tags too

https://bugzilla.gnome.org/show_bug.cgi?id=657257
This commit is contained in:
Vincent Penquerc'h 2011-08-24 16:29:08 +01:00 committed by Sebastian Dröge
parent e51cbc136b
commit 921b92ce06
5 changed files with 35 additions and 2 deletions

View file

@ -206,16 +206,23 @@ gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info, G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
GST_TYPE_DISCOVERER_STREAM_INFO); GST_TYPE_DISCOVERER_STREAM_INFO);
static void
gst_discoverer_audio_info_finalize (GstDiscovererAudioInfo * info)
{
g_free (info->language);
}
static void static void
gst_discoverer_audio_info_class_init (GstDiscovererAudioInfoClass * klass) gst_discoverer_audio_info_class_init (GstDiscovererAudioInfoClass * klass)
{ {
/* Nothing to initialize */ klass->finalize =
(GstMiniObjectFinalizeFunction) gst_discoverer_audio_info_finalize;
} }
static void static void
gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info) gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
{ {
/* Nothing to initialize */ info->language = NULL;
} }
static GstDiscovererAudioInfo * static GstDiscovererAudioInfo *
@ -237,6 +244,7 @@ gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
ret->depth = ptr->depth; ret->depth = ptr->depth;
ret->bitrate = ptr->bitrate; ret->bitrate = ptr->bitrate;
ret->max_bitrate = ptr->max_bitrate; ret->max_bitrate = ptr->max_bitrate;
ret->language = g_strdup (ptr->language);
return ret; return ret;
} }
@ -750,6 +758,17 @@ AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0); AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
/**
* gst_discoverer_audio_info_get_language:
* @info: a #GstDiscovererAudioInfo
*
* Returns: the language of the stream, or NULL if unknown.
*
* Since: 0.10.36
*/
AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
/* GstDiscovererVideoInfo */ /* GstDiscovererVideoInfo */
#define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \ #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \

View file

@ -667,6 +667,14 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
gst_structure_free (tags_st); gst_structure_free (tags_st);
} }
if (!info->language && ((GstDiscovererStreamInfo *) info)->tags) {
gchar *language;
if (gst_tag_list_get_string (((GstDiscovererStreamInfo *) info)->tags,
GST_TAG_LANGUAGE_CODE, &language)) {
info->language = language;
}
}
return (GstDiscovererStreamInfo *) info; return (GstDiscovererStreamInfo *) info;
} else if (g_str_has_prefix (name, "video/") || } else if (g_str_has_prefix (name, "video/") ||

View file

@ -110,6 +110,7 @@ guint gst_discoverer_audio_info_get_sample_rate(const GstDiscovererAudioInfo* in
guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info); guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info);
guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info); guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info);
guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info); guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info);
const gchar * gst_discoverer_audio_info_get_language(const GstDiscovererAudioInfo* info);
/** /**
* GstDiscovererVideoInfo: * GstDiscovererVideoInfo:

View file

@ -44,6 +44,8 @@ struct _GstDiscovererAudioInfo {
guint bitrate; guint bitrate;
guint max_bitrate; guint max_bitrate;
gchar *language;
}; };
struct _GstDiscovererVideoInfo { struct _GstDiscovererVideoInfo {

View file

@ -47,6 +47,7 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
GstDiscovererAudioInfo *audio_info; GstDiscovererAudioInfo *audio_info;
GString *s; GString *s;
gchar *tmp; gchar *tmp;
const gchar *ctmp;
int len = 400; int len = 400;
const GstTagList *tags; const GstTagList *tags;
GstCaps *caps; GstCaps *caps;
@ -72,6 +73,8 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
} }
audio_info = (GstDiscovererAudioInfo *) info; audio_info = (GstDiscovererAudioInfo *) info;
ctmp = gst_discoverer_audio_info_get_language (audio_info);
my_g_string_append_printf (s, "Language: %s\n", ctmp ? ctmp : "<unknown>");
my_g_string_append_printf (s, "Channels: %u\n", my_g_string_append_printf (s, "Channels: %u\n",
gst_discoverer_audio_info_get_channels (audio_info)); gst_discoverer_audio_info_get_channels (audio_info));
my_g_string_append_printf (s, "Sample rate: %u\n", my_g_string_append_printf (s, "Sample rate: %u\n",