summaryrefslogtreecommitdiff
path: root/libxo/xo_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'libxo/xo_encoder.c')
-rw-r--r--libxo/xo_encoder.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/libxo/xo_encoder.c b/libxo/xo_encoder.c
index a073e698b403..7e6cc1643374 100644
--- a/libxo/xo_encoder.c
+++ b/libxo/xo_encoder.c
@@ -199,7 +199,7 @@ xo_encoder_find (const char *name)
xo_encoder_list_init(&xo_encoders);
XO_ENCODER_LIST_FOREACH(xep, &xo_encoders) {
- if (strcmp(xep->xe_name, name) == 0)
+ if (xo_streq(xep->xe_name, name))
return xep;
}
@@ -290,9 +290,26 @@ xo_encoder_init (xo_handle_t *xop, const char *name)
{
xo_encoder_setup();
+ const char *opts = strchr(name, ':');
+ if (opts) {
+ /* Make a writable copy of the name */
+ size_t len = strlen(name);
+ char *copy = alloca(len + 1);
+ memcpy(copy, name, len);
+ copy[len] = '\0';
+
+ char *opts_copy = copy + (opts - name); /* Move to ':' */
+ *opts_copy++ = '\0'; /* Trim it off */
+
+ opts = opts_copy; /* Use copy as options */
+ name = copy; /* Use trimmed copy as name */
+ }
+
/* Can't have names containing '/' or ':' */
- if (strchr(name, '/') != NULL || strchr(name, ':') != NULL)
+ if (strchr(name, '/') != NULL || strchr(name, ':') != NULL) {
+ xo_failure(xop, "invalid encoder name: %s", name);
return -1;
+ }
/*
* First we look on the list of known (registered) encoders.
@@ -302,13 +319,20 @@ xo_encoder_init (xo_handle_t *xop, const char *name)
xo_encoder_node_t *xep = xo_encoder_find(name);
if (xep == NULL) {
xep = xo_encoder_discover(name);
- if (xep == NULL)
+ if (xep == NULL) {
+ xo_failure(xop, "encoder not founde: %s", name);
return -1;
+ }
}
xo_set_encoder(xop, xep->xe_handler);
- return xo_encoder_handle(xop, XO_OP_CREATE, NULL, NULL, 0);
+ int rc = xo_encoder_handle(xop, XO_OP_CREATE, name, NULL, 0);
+ if (rc == 0 && opts != NULL) {
+ rc = xo_encoder_handle(xop, XO_OP_OPTIONS, name, opts, 0);
+ }
+
+ return rc;
}
/*
@@ -334,7 +358,7 @@ xo_encoder_create (const char *name, xo_xof_flags_t flags)
int
xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op,
- const char *name, const char *value, xo_xof_flags_t flags)
+ const char *name, const char *value, xo_xff_flags_t flags)
{
void *private = xo_get_private(xop);
xo_encoder_func_t func = xo_get_encoder(xop);
@@ -366,6 +390,7 @@ xo_encoder_op_name (xo_encoder_op_t op)
/* 14 */ "destroy",
/* 15 */ "attr",
/* 16 */ "version",
+ /* 17 */ "options",
};
if (op > sizeof(names) / sizeof(names[0]))