mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
discoverer: retrieve audio track language from tags too
https://bugzilla.gnome.org/show_bug.cgi?id=657257
This commit is contained in:
parent
e51cbc136b
commit
921b92ce06
5 changed files with 35 additions and 2 deletions
|
@ -206,16 +206,23 @@ gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
|
|||
G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
|
||||
GST_TYPE_DISCOVERER_STREAM_INFO);
|
||||
|
||||
static void
|
||||
gst_discoverer_audio_info_finalize (GstDiscovererAudioInfo * info)
|
||||
{
|
||||
g_free (info->language);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_discoverer_audio_info_class_init (GstDiscovererAudioInfoClass * klass)
|
||||
{
|
||||
/* Nothing to initialize */
|
||||
klass->finalize =
|
||||
(GstMiniObjectFinalizeFunction) gst_discoverer_audio_info_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
|
||||
{
|
||||
/* Nothing to initialize */
|
||||
info->language = NULL;
|
||||
}
|
||||
|
||||
static GstDiscovererAudioInfo *
|
||||
|
@ -237,6 +244,7 @@ gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
|
|||
ret->depth = ptr->depth;
|
||||
ret->bitrate = ptr->bitrate;
|
||||
ret->max_bitrate = ptr->max_bitrate;
|
||||
ret->language = g_strdup (ptr->language);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -750,6 +758,17 @@ AUDIO_INFO_ACCESSOR_CODE (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 */
|
||||
|
||||
#define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
|
||||
|
|
|
@ -667,6 +667,14 @@ collect_information (GstDiscoverer * dc, const GstStructure * 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;
|
||||
|
||||
} else if (g_str_has_prefix (name, "video/") ||
|
||||
|
|
|
@ -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_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:
|
||||
|
|
|
@ -44,6 +44,8 @@ struct _GstDiscovererAudioInfo {
|
|||
|
||||
guint bitrate;
|
||||
guint max_bitrate;
|
||||
|
||||
gchar *language;
|
||||
};
|
||||
|
||||
struct _GstDiscovererVideoInfo {
|
||||
|
|
|
@ -47,6 +47,7 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
|
|||
GstDiscovererAudioInfo *audio_info;
|
||||
GString *s;
|
||||
gchar *tmp;
|
||||
const gchar *ctmp;
|
||||
int len = 400;
|
||||
const GstTagList *tags;
|
||||
GstCaps *caps;
|
||||
|
@ -72,6 +73,8 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * 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",
|
||||
gst_discoverer_audio_info_get_channels (audio_info));
|
||||
my_g_string_append_printf (s, "Sample rate: %u\n",
|
||||
|
|
Loading…
Reference in a new issue