mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
TrackTitleSource: Move private variables to instance private
Add getter methods to get those variables Add/Fixup documentation
This commit is contained in:
parent
fec797f298
commit
7c255ff247
4 changed files with 128 additions and 68 deletions
|
@ -560,11 +560,15 @@ GES_IS_TRACK_AUDIO_TEST_SOURCE_CLASS
|
||||||
<FILE>ges-track-title-source</FILE>
|
<FILE>ges-track-title-source</FILE>
|
||||||
<TITLE>GESTrackTitleSource</TITLE>
|
<TITLE>GESTrackTitleSource</TITLE>
|
||||||
GESTrackTitleSource
|
GESTrackTitleSource
|
||||||
|
ges_track_title_source_new
|
||||||
ges_track_title_source_set_text
|
ges_track_title_source_set_text
|
||||||
ges_track_title_source_set_font_desc
|
ges_track_title_source_set_font_desc
|
||||||
ges_track_title_source_set_halignment
|
ges_track_title_source_set_halignment
|
||||||
ges_track_title_source_set_valignment
|
ges_track_title_source_set_valignment
|
||||||
ges_track_title_source_new
|
ges_track_title_source_get_font_desc
|
||||||
|
ges_track_title_source_get_halignment
|
||||||
|
ges_track_title_source_get_text
|
||||||
|
ges_track_title_source_get_valignment
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GESTrackTitleSourceClass
|
GESTrackTitleSourceClass
|
||||||
GESTrackTitleSourcePrivate
|
GESTrackTitleSourcePrivate
|
||||||
|
|
|
@ -34,8 +34,12 @@ G_DEFINE_TYPE (GESTrackTitleSource, ges_track_title_source,
|
||||||
|
|
||||||
struct _GESTrackTitleSourcePrivate
|
struct _GESTrackTitleSourcePrivate
|
||||||
{
|
{
|
||||||
/* Dummy variable */
|
gchar *text;
|
||||||
void *nothing;
|
gchar *font_desc;
|
||||||
|
GESTextHAlign halign;
|
||||||
|
GESTextVAlign valign;
|
||||||
|
GstElement *text_el;
|
||||||
|
GstElement *background_el;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -75,34 +79,34 @@ ges_track_title_source_init (GESTrackTitleSource * self)
|
||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||||
GES_TYPE_TRACK_TITLE_SOURCE, GESTrackTitleSourcePrivate);
|
GES_TYPE_TRACK_TITLE_SOURCE, GESTrackTitleSourcePrivate);
|
||||||
|
|
||||||
self->text = NULL;
|
self->priv->text = NULL;
|
||||||
self->font_desc = NULL;
|
self->priv->font_desc = NULL;
|
||||||
self->text_el = NULL;
|
self->priv->text_el = NULL;
|
||||||
self->halign = DEFAULT_HALIGNMENT;
|
self->priv->halign = DEFAULT_HALIGNMENT;
|
||||||
self->valign = DEFAULT_VALIGNMENT;
|
self->priv->valign = DEFAULT_VALIGNMENT;
|
||||||
self->background_el = NULL;
|
self->priv->background_el = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ges_track_title_source_dispose (GObject * object)
|
ges_track_title_source_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GESTrackTitleSource *self = GES_TRACK_TITLE_SOURCE (object);
|
GESTrackTitleSource *self = GES_TRACK_TITLE_SOURCE (object);
|
||||||
if (self->text) {
|
if (self->priv->text) {
|
||||||
g_free (self->text);
|
g_free (self->priv->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->font_desc) {
|
if (self->priv->font_desc) {
|
||||||
g_free (self->font_desc);
|
g_free (self->priv->font_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->text_el) {
|
if (self->priv->text_el) {
|
||||||
g_object_unref (self->text_el);
|
g_object_unref (self->priv->text_el);
|
||||||
self->text_el = NULL;
|
self->priv->text_el = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->background_el) {
|
if (self->priv->background_el) {
|
||||||
g_object_unref (self->background_el);
|
g_object_unref (self->priv->background_el);
|
||||||
self->background_el = NULL;
|
self->priv->background_el = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (ges_track_title_source_parent_class)->dispose (object);
|
G_OBJECT_CLASS (ges_track_title_source_parent_class)->dispose (object);
|
||||||
|
@ -132,6 +136,7 @@ static GstElement *
|
||||||
ges_track_title_source_create_element (GESTrackObject * object)
|
ges_track_title_source_create_element (GESTrackObject * object)
|
||||||
{
|
{
|
||||||
GESTrackTitleSource *self = GES_TRACK_TITLE_SOURCE (object);
|
GESTrackTitleSource *self = GES_TRACK_TITLE_SOURCE (object);
|
||||||
|
GESTrackTitleSourcePrivate *priv = self->priv;
|
||||||
GstElement *topbin, *background, *text;
|
GstElement *topbin, *background, *text;
|
||||||
GstPad *src;
|
GstPad *src;
|
||||||
|
|
||||||
|
@ -139,14 +144,14 @@ ges_track_title_source_create_element (GESTrackObject * object)
|
||||||
background = gst_element_factory_make ("videotestsrc", "titlesrc-bg");
|
background = gst_element_factory_make ("videotestsrc", "titlesrc-bg");
|
||||||
|
|
||||||
text = gst_element_factory_make ("textoverlay", "titlsrc-text");
|
text = gst_element_factory_make ("textoverlay", "titlsrc-text");
|
||||||
if (self->text) {
|
if (priv->text) {
|
||||||
g_object_set (text, "text", self->text, NULL);
|
g_object_set (text, "text", priv->text, NULL);
|
||||||
}
|
}
|
||||||
if (self->font_desc) {
|
if (priv->font_desc) {
|
||||||
g_object_set (text, "font-desc", self->font_desc, NULL);
|
g_object_set (text, "font-desc", priv->font_desc, NULL);
|
||||||
}
|
}
|
||||||
g_object_set (text, "valignment", (gint) self->valign, "halignment",
|
g_object_set (text, "valignment", (gint) priv->valign, "halignment",
|
||||||
(gint) self->halign, NULL);
|
(gint) priv->halign, NULL);
|
||||||
|
|
||||||
g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_BLACK,
|
g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_BLACK,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -162,8 +167,8 @@ ges_track_title_source_create_element (GESTrackObject * object)
|
||||||
g_object_ref (text);
|
g_object_ref (text);
|
||||||
g_object_ref (background);
|
g_object_ref (background);
|
||||||
|
|
||||||
self->text_el = text;
|
priv->text_el = text;
|
||||||
self->background_el = background;
|
priv->background_el = background;
|
||||||
|
|
||||||
return topbin;
|
return topbin;
|
||||||
}
|
}
|
||||||
|
@ -175,18 +180,17 @@ ges_track_title_source_create_element (GESTrackObject * object)
|
||||||
* made.
|
* made.
|
||||||
*
|
*
|
||||||
* Sets the text this track object will render.
|
* Sets the text this track object will render.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
ges_track_title_source_set_text (GESTrackTitleSource * self, const gchar * text)
|
ges_track_title_source_set_text (GESTrackTitleSource * self, const gchar * text)
|
||||||
{
|
{
|
||||||
if (self->text)
|
if (self->priv->text)
|
||||||
g_free (self->text);
|
g_free (self->priv->text);
|
||||||
|
|
||||||
self->text = g_strdup (text);
|
self->priv->text = g_strdup (text);
|
||||||
if (self->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->text_el, "text", text, NULL);
|
g_object_set (self->priv->text_el, "text", text, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,25 +198,25 @@ ges_track_title_source_set_text (GESTrackTitleSource * self, const gchar * text)
|
||||||
* @self: the #GESTrackTitleSource
|
* @self: the #GESTrackTitleSource
|
||||||
* @font_desc: the pango font description
|
* @font_desc: the pango font description
|
||||||
*
|
*
|
||||||
* Sets the text this track object will render.
|
* Set the pango font description this source will use to render
|
||||||
*
|
* the text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
ges_track_title_source_set_font_desc (GESTrackTitleSource * self,
|
ges_track_title_source_set_font_desc (GESTrackTitleSource * self,
|
||||||
const gchar * font_desc)
|
const gchar * font_desc)
|
||||||
{
|
{
|
||||||
if (self->font_desc)
|
if (self->priv->font_desc)
|
||||||
g_free (self->font_desc);
|
g_free (self->priv->font_desc);
|
||||||
|
|
||||||
self->font_desc = g_strdup (font_desc);
|
self->priv->font_desc = g_strdup (font_desc);
|
||||||
GST_LOG ("setting font-desc to '%s'", font_desc);
|
GST_LOG ("setting font-desc to '%s'", font_desc);
|
||||||
if (self->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->text_el, "font-desc", font_desc, NULL);
|
g_object_set (self->priv->text_el, "font-desc", font_desc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_title_source_valignment:
|
* ges_track_title_source_set_valignment:
|
||||||
* @self: the #GESTrackTitleSource* to set text on
|
* @self: the #GESTrackTitleSource* to set text on
|
||||||
* @valign: #GESTextVAlign
|
* @valign: #GESTextVAlign
|
||||||
*
|
*
|
||||||
|
@ -222,14 +226,14 @@ void
|
||||||
ges_track_title_source_set_valignment (GESTrackTitleSource * self,
|
ges_track_title_source_set_valignment (GESTrackTitleSource * self,
|
||||||
GESTextVAlign valign)
|
GESTextVAlign valign)
|
||||||
{
|
{
|
||||||
self->valign = valign;
|
self->priv->valign = valign;
|
||||||
GST_LOG ("set valignment to: %d", valign);
|
GST_LOG ("set valignment to: %d", valign);
|
||||||
if (self->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->text_el, "valignment", valign, NULL);
|
g_object_set (self->priv->text_el, "valignment", valign, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_title_source_halignment:
|
* ges_track_title_source_set_halignment:
|
||||||
* @self: the #GESTrackTitleSource* to set text on
|
* @self: the #GESTrackTitleSource* to set text on
|
||||||
* @halign: #GESTextHAlign
|
* @halign: #GESTextHAlign
|
||||||
*
|
*
|
||||||
|
@ -239,12 +243,62 @@ void
|
||||||
ges_track_title_source_set_halignment (GESTrackTitleSource * self,
|
ges_track_title_source_set_halignment (GESTrackTitleSource * self,
|
||||||
GESTextHAlign halign)
|
GESTextHAlign halign)
|
||||||
{
|
{
|
||||||
self->halign = halign;
|
self->priv->halign = halign;
|
||||||
GST_LOG ("set halignment to: %d", halign);
|
GST_LOG ("set halignment to: %d", halign);
|
||||||
if (self->text_el)
|
if (self->priv->text_el)
|
||||||
g_object_set (self->text_el, "halignment", halign, NULL);
|
g_object_set (self->priv->text_el, "halignment", halign, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_get_text:
|
||||||
|
* @source: a #GESTrackTitleSource
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The text currently set on the @source.
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
ges_track_title_source_get_text (GESTrackTitleSource * source)
|
||||||
|
{
|
||||||
|
return source->priv->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_get_font_desc:
|
||||||
|
* @source: a #GESTrackTitleSource
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The pango font description used by this
|
||||||
|
* @source.
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
ges_track_title_source_get_font_desc (GESTrackTitleSource * source)
|
||||||
|
{
|
||||||
|
return source->priv->font_desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_get_halignment:
|
||||||
|
* @source: a #GESTrackTitleSource
|
||||||
|
*
|
||||||
|
* Returns: The horizontal aligment used by this source.
|
||||||
|
*/
|
||||||
|
GESTextHAlign
|
||||||
|
ges_track_title_source_get_halignment (GESTrackTitleSource * source)
|
||||||
|
{
|
||||||
|
return source->priv->halign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_title_source_get_valignment:
|
||||||
|
* @source: a #GESTrackTitleSource
|
||||||
|
*
|
||||||
|
* Returns: The vertical aligment used by this source.
|
||||||
|
*/
|
||||||
|
GESTextVAlign
|
||||||
|
ges_track_title_source_get_valignment (GESTrackTitleSource * source)
|
||||||
|
{
|
||||||
|
return source->priv->valign;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GESTrackTitleSource *
|
GESTrackTitleSource *
|
||||||
ges_track_title_source_new (void)
|
ges_track_title_source_new (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,13 +54,6 @@ struct _GESTrackTitleSource {
|
||||||
GESTrackSource parent;
|
GESTrackSource parent;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gchar *text;
|
|
||||||
gchar *font_desc;
|
|
||||||
GESTextHAlign halign;
|
|
||||||
GESTextVAlign valign;
|
|
||||||
GstElement *text_el;
|
|
||||||
GstElement *background_el;
|
|
||||||
|
|
||||||
GESTrackTitleSourcePrivate *priv;
|
GESTrackTitleSourcePrivate *priv;
|
||||||
|
|
||||||
/* Padding for API extension */
|
/* Padding for API extension */
|
||||||
|
@ -83,17 +76,22 @@ struct _GESTrackTitleSourceClass {
|
||||||
|
|
||||||
GType ges_track_title_source_get_type (void);
|
GType ges_track_title_source_get_type (void);
|
||||||
|
|
||||||
void ges_track_title_source_set_text(GESTrackTitleSource *self, const
|
void ges_track_title_source_set_text(GESTrackTitleSource *self,
|
||||||
gchar *text);
|
const gchar *text);
|
||||||
|
|
||||||
void ges_track_title_source_set_font_desc(GESTrackTitleSource *self,
|
void ges_track_title_source_set_font_desc(GESTrackTitleSource *self,
|
||||||
const gchar *font_desc);
|
const gchar *font_desc);
|
||||||
|
|
||||||
void ges_track_title_source_set_halignment(GESTrackTitleSource
|
void ges_track_title_source_set_halignment(GESTrackTitleSource *self,
|
||||||
*self, GESTextHAlign halgn);
|
GESTextHAlign halign);
|
||||||
|
|
||||||
void ges_track_title_source_set_valignment(GESTrackTitleSource
|
void ges_track_title_source_set_valignment(GESTrackTitleSource *self,
|
||||||
*self, GESTextVAlign valign);
|
GESTextVAlign valign);
|
||||||
|
|
||||||
|
const gchar *ges_track_title_source_get_text (GESTrackTitleSource *source);
|
||||||
|
const gchar *ges_track_title_source_get_font_desc (GESTrackTitleSource *source);
|
||||||
|
GESTextHAlign ges_track_title_source_get_halignment (GESTrackTitleSource *source);
|
||||||
|
GESTextVAlign ges_track_title_source_get_valignment (GESTrackTitleSource *source);
|
||||||
|
|
||||||
GESTrackTitleSource* ges_track_title_source_new (void);
|
GESTrackTitleSource* ges_track_title_source_new (void);
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,18 @@ GST_START_TEST (test_title_source_in_layer)
|
||||||
ges_timeline_object_find_track_object (GES_TIMELINE_OBJECT (source), v,
|
ges_timeline_object_find_track_object (GES_TIMELINE_OBJECT (source), v,
|
||||||
GES_TYPE_TRACK_TITLE_SOURCE);
|
GES_TYPE_TRACK_TITLE_SOURCE);
|
||||||
|
|
||||||
|
/* Check the text is still the same */
|
||||||
|
assert_equals_string (ges_track_title_source_get_text (GES_TRACK_TITLE_SOURCE
|
||||||
|
(trobj)), "some text");
|
||||||
|
|
||||||
/* test the font-desc property */
|
/* test the font-desc property */
|
||||||
g_object_set (source, "font-desc", (gchar *) "sans 72", NULL);
|
g_object_set (source, "font-desc", (gchar *) "sans 72", NULL);
|
||||||
g_object_get (source, "font-desc", &text, NULL);
|
g_object_get (source, "font-desc", &text, NULL);
|
||||||
assert_equals_string ("sans 72", text);
|
assert_equals_string ("sans 72", text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
|
|
||||||
text = ((GESTrackTitleSource *) trobj)->font_desc;
|
assert_equals_string ("sans 72",
|
||||||
assert_equals_string ("sans 72", text);
|
ges_track_title_source_get_font_desc (GES_TRACK_TITLE_SOURCE (trobj)));
|
||||||
|
|
||||||
/* test halign and valign */
|
/* test halign and valign */
|
||||||
g_object_set (source, "halignment", (gint)
|
g_object_set (source, "halignment", (gint)
|
||||||
|
@ -166,10 +170,10 @@ GST_START_TEST (test_title_source_in_layer)
|
||||||
assert_equals_int (halign, GES_TEXT_HALIGN_LEFT);
|
assert_equals_int (halign, GES_TEXT_HALIGN_LEFT);
|
||||||
assert_equals_int (valign, GES_TEXT_VALIGN_TOP);
|
assert_equals_int (valign, GES_TEXT_VALIGN_TOP);
|
||||||
|
|
||||||
halign = ((GESTrackTitleSource *) trobj)->halign;
|
assert_equals_int (ges_track_title_source_get_halignment
|
||||||
valign = ((GESTrackTitleSource *) trobj)->valign;
|
(GES_TRACK_TITLE_SOURCE (trobj)), GES_TEXT_HALIGN_LEFT);
|
||||||
assert_equals_int (halign, GES_TEXT_HALIGN_LEFT);
|
assert_equals_int (ges_track_title_source_get_valignment
|
||||||
assert_equals_int (valign, GES_TEXT_VALIGN_TOP);
|
(GES_TRACK_TITLE_SOURCE (trobj)), GES_TEXT_VALIGN_TOP);
|
||||||
|
|
||||||
GST_DEBUG ("removing the source");
|
GST_DEBUG ("removing the source");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue