Add new parse syntax: @preset="<preset-name>" to load presets.
Fixes #86
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);
%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
}
gst_parse_strfree ($1);
}
+ | element PRESET { gst_parse_element_preset ($2, $1, graph);
+ $$ = $1;
+ }
| element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
$$ = $1;
}
/* 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}?
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);
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;
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;
}
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.
.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 )