ges-launcher: Add support for titles

This commit is contained in:
Thibault Saunier 2018-03-30 18:17:13 -03:00
parent 0f486de0d9
commit 6d67debc10
4 changed files with 64 additions and 2 deletions

View file

@ -44,6 +44,9 @@ _ges_command_line_formatter_add_effect (GESTimeline * timeline,
static gboolean
_ges_command_line_formatter_add_test_clip (GESTimeline * timeline,
GstStructure * structure, GError ** error);
static gboolean
_ges_command_line_formatter_add_title_clip (GESTimeline * timeline,
GstStructure * structure, GError ** error);
typedef struct
{
@ -152,6 +155,40 @@ static GESCommandLineOption options[] = {
{NULL, 0, 0, NULL, FALSE},
},
},
{"title", 'c', (ActionFromStructureFunc) _ges_command_line_formatter_add_title_clip,
"<title text> - Adds a clip in the timeline.",
{
{
"text", "n", 0, NULL,
"The text to be used as title."
},
{
"name", "n", 0, NULL,
"The name of the clip, can be used as an ID later."
},
{
"start", "s",GST_TYPE_CLOCK_TIME, NULL,
"The starting position of the clip in the timeline."
},
{
"duration", "d", GST_TYPE_CLOCK_TIME, NULL,
"The duration of the clip."
},
{
"inpoint", "i", GST_TYPE_CLOCK_TIME, NULL,
"The inpoint of the clip (time in the input file to start playing from)."
},
{
"track-types", "tt", 0, NULL,
"The type of the tracks where the clip should be used (audio or video or audio+video)."
},
{
"layer", "l", 0, NULL,
"The priority of the layer into which the clip should be added."
},
{NULL, 0, 0, NULL, FALSE},
},
},
{
"set-", 0, NULL,
"<property name> <value> - Set a property on the last added element.\n"
@ -170,6 +207,7 @@ typedef enum
CLIP,
EFFECT,
TEST_CLIP,
TITLE,
SET,
} GESCommandLineOptionType;
@ -293,6 +331,21 @@ _ges_command_line_formatter_add_test_clip (GESTimeline * timeline,
return _ges_add_clip_from_struct (timeline, structure, error);
}
static gboolean
_ges_command_line_formatter_add_title_clip (GESTimeline * timeline,
GstStructure * structure, GError ** error)
{
if (!_cleanup_fields (options[TEST_CLIP].properties, structure, error))
return FALSE;
gst_structure_set (structure, "type", G_TYPE_STRING, "GESTitleClip", NULL);
gst_structure_set (structure, "asset-id", G_TYPE_STRING, "GESTitleClip",
NULL);
GST_ERROR ("Structure: %" GST_PTR_FORMAT, structure);
return _ges_add_clip_from_struct (timeline, structure, error);
}
static gboolean
_ges_command_line_formatter_add_effect (GESTimeline * timeline,
GstStructure * structure, GError ** error)

View file

@ -128,6 +128,8 @@ ges_structure_parser_parse_symbol (GESStructureParser * self,
ges_structure_parser_parse_string (self, "effect, bin-description=", TRUE);
else if (!g_ascii_strncasecmp (symbol, "transition", 10))
ges_structure_parser_parse_string (self, "transition, type=", TRUE);
else if (!g_ascii_strncasecmp (symbol, "title", 5))
ges_structure_parser_parse_string (self, "title, text=(string)", TRUE);
}
void

View file

@ -328,6 +328,7 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure,
GESClip *clip;
gint layer_priority;
const gchar *name;
const gchar *text;
const gchar *pattern;
gchar *asset_id = NULL;
gchar *check_asset_id = NULL;
@ -340,7 +341,7 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure,
const gchar *valid_fields[] =
{ "asset-id", "pattern", "name", "layer-priority", "layer", "type",
"start", "inpoint", "duration", NULL
"start", "inpoint", "duration", "text", NULL
};
FieldsError fields_error = { valid_fields, NULL };
@ -351,6 +352,7 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure,
GET_AND_CHECK ("asset-id", G_TYPE_STRING, &check_asset_id, beach);
TRY_GET_STRING ("pattern", &pattern, NULL);
TRY_GET_STRING ("text", &text, NULL);
TRY_GET_STRING ("name", &name, NULL);
TRY_GET ("layer-priority", G_TYPE_INT, &layer_priority, -1);
if (layer_priority == -1)
@ -423,6 +425,10 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure,
}
}
if (GES_IS_TITLE_CLIP (clip) && text)
ges_timeline_element_set_child_properties (GES_TIMELINE_ELEMENT (clip),
"text", text, NULL);
if (name
&& !ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip), name)) {
res = FALSE;

View file

@ -15,6 +15,7 @@ CLIP [ ]+\+clip[ ]+
TEST_CLIP [ ]+\+test-clip[ ]+
TRANSITION [ ]+\+transition[ ]+
EFFECT [ ]+\+effect[ ]+
TITLE [ ]+\+title[ ]+
SETTER [ ]+set-[^ ]+[ ]+
@ -24,7 +25,7 @@ SETTER [ ]+set-[^ ]+[ ]+
ges_structure_parser_parse_string (yyextra, yytext, FALSE);
}
{CLIP}|{TRANSITION}|{EFFECT}|{TEST_CLIP} {
{CLIP}|{TRANSITION}|{EFFECT}|{TEST_CLIP}|{TITLE} {
ges_structure_parser_parse_symbol (yyextra, yytext);
}