mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
API: Add function to get subtitle track title
This commit is contained in:
@@ -45,6 +45,7 @@ struct _GstClapperSubtitleInfo
|
||||
{
|
||||
GstClapperStreamInfo parent;
|
||||
|
||||
gchar *title;
|
||||
gchar *language;
|
||||
};
|
||||
|
||||
|
17
lib/gst/clapper/gstclapper-media-info.c
vendored
17
lib/gst/clapper/gstclapper-media-info.c
vendored
@@ -379,6 +379,7 @@ gst_clapper_subtitle_info_finalize (GObject * object)
|
||||
{
|
||||
GstClapperSubtitleInfo *info = GST_CLAPPER_SUBTITLE_INFO (object);
|
||||
|
||||
g_free (info->title);
|
||||
g_free (info->language);
|
||||
|
||||
G_OBJECT_CLASS (gst_clapper_subtitle_info_parent_class)->finalize (object);
|
||||
@@ -392,6 +393,20 @@ gst_clapper_subtitle_info_class_init (GstClapperSubtitleInfoClass * klass)
|
||||
gobject_class->finalize = gst_clapper_subtitle_info_finalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clapper_subtitle_info_get_title:
|
||||
* @info: a #GstClapperSubtitleInfo
|
||||
*
|
||||
* Returns: the title of the stream, or NULL if unknown.
|
||||
*/
|
||||
const gchar *
|
||||
gst_clapper_subtitle_info_get_title (const GstClapperSubtitleInfo * info)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_CLAPPER_SUBTITLE_INFO (info), NULL);
|
||||
|
||||
return info->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clapper_subtitle_info_get_language:
|
||||
* @info: a #GstClapperSubtitleInfo
|
||||
@@ -513,6 +528,8 @@ gst_clapper_subtitle_info_copy (GstClapperSubtitleInfo * ref)
|
||||
GstClapperSubtitleInfo *ret;
|
||||
|
||||
ret = gst_clapper_subtitle_info_new ();
|
||||
if (ref->title)
|
||||
ret->title = g_strdup (ref->title);
|
||||
if (ref->language)
|
||||
ret->language = g_strdup (ref->language);
|
||||
|
||||
|
5
lib/gst/clapper/gstclapper-media-info.h
vendored
5
lib/gst/clapper/gstclapper-media-info.h
vendored
@@ -170,7 +170,10 @@ GST_CLAPPER_API
|
||||
GType gst_clapper_subtitle_info_get_type (void);
|
||||
|
||||
GST_CLAPPER_API
|
||||
const gchar * gst_clapper_subtitle_info_get_language (const GstClapperSubtitleInfo* info);
|
||||
const gchar * gst_clapper_subtitle_info_get_title (const GstClapperSubtitleInfo *info);
|
||||
|
||||
GST_CLAPPER_API
|
||||
const gchar * gst_clapper_subtitle_info_get_language (const GstClapperSubtitleInfo *info);
|
||||
|
||||
#define GST_TYPE_CLAPPER_MEDIA_INFO \
|
||||
(gst_clapper_media_info_get_type())
|
||||
|
18
lib/gst/clapper/gstclapper.c
vendored
18
lib/gst/clapper/gstclapper.c
vendored
@@ -2125,11 +2125,14 @@ gst_clapper_subtitle_info_update (GstClapper * self,
|
||||
{
|
||||
GstClapperSubtitleInfo *info = (GstClapperSubtitleInfo *) stream_info;
|
||||
|
||||
if (stream_info->tags) {
|
||||
/* Free the old info */
|
||||
g_free (info->title);
|
||||
info->title = NULL;
|
||||
g_free (info->language);
|
||||
info->language = NULL;
|
||||
|
||||
/* free the old language info */
|
||||
g_free (info->language);
|
||||
info->language = NULL;
|
||||
if (stream_info->tags) {
|
||||
gst_tag_list_get_string (stream_info->tags, GST_TAG_TITLE, &info->title);
|
||||
|
||||
/* First try to get the language full name from tag, if name is not
|
||||
* available then try language code. If we find the language code
|
||||
@@ -2171,13 +2174,10 @@ gst_clapper_subtitle_info_update (GstClapper * self,
|
||||
g_free (suburi);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
g_free (info->language);
|
||||
info->language = NULL;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (self, "language=%s", info->language);
|
||||
GST_DEBUG_OBJECT (self, "Subtitle title: %s", info->title);
|
||||
GST_DEBUG_OBJECT (self, "Subtitle language: %s", info->language);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user