mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
parse: add support for presets
Add new parse syntax: @preset="<preset-name>" to load presets. Fixes #86
This commit is contained in:
parent
4f9cac06e4
commit
19b28788cf
4 changed files with 78 additions and 2 deletions
|
@ -456,6 +456,40 @@ error:
|
|||
goto out;
|
||||
}
|
||||
|
||||
static void gst_parse_element_preset (gchar *value, GstElement *element, graph_t *graph)
|
||||
{
|
||||
/* do nothing if preset is for missing element or its not a preset element */
|
||||
if (element == NULL)
|
||||
goto out;
|
||||
|
||||
if (!GST_IS_PRESET(element))
|
||||
goto not_a_preset;
|
||||
|
||||
/* do nothing if no preset is given */
|
||||
if (value == NULL || *value == '\0')
|
||||
goto out;
|
||||
|
||||
gst_parse_unescape (value);
|
||||
if (!gst_preset_load_preset (GST_PRESET (element), value))
|
||||
goto error;
|
||||
|
||||
out:
|
||||
gst_parse_strfree (value);
|
||||
return;
|
||||
|
||||
not_a_preset:
|
||||
SET_ERROR (graph->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
|
||||
_("Element \"%s\" is not a GstPreset"),
|
||||
GST_ELEMENT_NAME (element));
|
||||
goto out;
|
||||
|
||||
error:
|
||||
SET_ERROR (graph->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
|
||||
_("could not set preset \"%s\" in element \"%s\""),
|
||||
value, GST_ELEMENT_NAME (element));
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void gst_parse_free_reference (reference_t *rr)
|
||||
{
|
||||
if(rr->element) gst_object_unref(rr->element);
|
||||
|
@ -763,7 +797,7 @@ static int yyerror (void *scanner, graph_t *graph, const char *s);
|
|||
%token <ss> PARSE_URL
|
||||
%token <ss> IDENTIFIER
|
||||
%left <ss> REF PADREF BINREF
|
||||
%token <ss> ASSIGNMENT
|
||||
%token <ss> ASSIGNMENT PRESET
|
||||
%token <ss> LINK
|
||||
%token <ss> LINK_ALL
|
||||
|
||||
|
@ -817,6 +851,9 @@ element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
|
|||
}
|
||||
gst_parse_strfree ($1);
|
||||
}
|
||||
| element PRESET { gst_parse_element_preset ($2, $1, graph);
|
||||
$$ = $1;
|
||||
}
|
||||
| element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
|
||||
$$ = $1;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ _url ({_protocol}"://"{_string}|["."{_identifier}]?"/"{_string})|({_protocol}":/
|
|||
/* we must do this here, because nearly everything matches a {_string} */
|
||||
_assignment {_identifier}{_assign}{_string}
|
||||
|
||||
_preset @preset{_assign}{_string}
|
||||
|
||||
/* get pad/element references and stuff with dots right */
|
||||
_padref "."{_identifier}
|
||||
_ref {_identifier}"."{_identifier}?
|
||||
|
@ -94,6 +96,16 @@ _link ([!:][[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*
|
|||
return ASSIGNMENT;
|
||||
}
|
||||
|
||||
{_preset} {
|
||||
gchar *pos = yytext;
|
||||
while (*pos && (*pos != '=')) pos++;
|
||||
while (*pos && g_ascii_isspace (*pos)) pos++;
|
||||
PRINT ("PRESET: %s", &pos[1]);
|
||||
yylval->ss = gst_parse_strdup (&pos[1]);
|
||||
BEGIN (INITIAL);
|
||||
return PRESET;
|
||||
}
|
||||
|
||||
{_padref} {
|
||||
yytext++;
|
||||
PRINT ("PADREF: %s", yytext);
|
||||
|
|
|
@ -670,6 +670,24 @@ GST_START_TEST (test_missing_elements)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_preset)
|
||||
{
|
||||
GstElement *element;
|
||||
GError *err = NULL;
|
||||
|
||||
/* missing preset */
|
||||
element =
|
||||
gst_parse_launch
|
||||
("fakesrc ! identity @preset=\"Wrong preset\" ! fakesink", &err);
|
||||
fail_unless (err != NULL, "expected error");
|
||||
fail_unless_equals_int (err->code, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY);
|
||||
fail_unless (element != NULL, "Doesn't NULL return without FATAL_ERRORS");
|
||||
gst_clear_object (&element);
|
||||
g_clear_error (&err);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_flags)
|
||||
{
|
||||
GstElement *element;
|
||||
|
@ -734,6 +752,7 @@ parse_suite (void)
|
|||
tcase_add_test (tc_chain, test_flags);
|
||||
tcase_add_test (tc_chain, test_missing_elements);
|
||||
tcase_add_test (tc_chain, test_parsing);
|
||||
tcase_add_test (tc_chain, test_preset);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ gst\-launch\-1.0 \- build and run a GStreamer pipeline
|
|||
|
||||
In simple form, a PIPELINE\-DESCRIPTION is a list of
|
||||
elements separated by exclamation marks (!). Properties may be appended to
|
||||
elements, in the form \fIproperty=value\fR.
|
||||
elements, in the form \fIproperty=value\fR. A "preset" can also be set using
|
||||
the \fI@preset=<preset name>\fR synthax.
|
||||
|
||||
For a complete description of possible PIPELINE-DESCRIPTIONS see the section
|
||||
\fIpipeline description\fR below or consult the GStreamer documentation.
|
||||
|
@ -159,6 +160,13 @@ find out about properties and allowed values of different elements.
|
|||
.br
|
||||
Enumeration properties can be set by name, nick or value.
|
||||
|
||||
.B Presets
|
||||
|
||||
@preset=<preset name> ...
|
||||
|
||||
Sets the preset on the element. you can use \fbgst\-inspect\-1.0\fr(1) to
|
||||
find out what presets are available for a specific element.
|
||||
|
||||
.B Bins
|
||||
|
||||
\fI[BINTYPE.]\fR ( \fI[PROPERTY1 ...]\fR PIPELINE-DESCRIPTION )
|
||||
|
|
Loading…
Reference in a new issue