コード例 #1
0
ファイル: transcode.c プロジェクト: cmassiot/upipe
/* allocate es configuration */
static struct es_conf *es_conf_alloc(struct udict_mgr *mgr,
                                     uint64_t id, struct uchain *list)
{
    struct es_conf *conf = malloc(sizeof(struct es_conf));
    if (unlikely(conf == NULL))
        return NULL;
    memset(conf, 0, sizeof(struct es_conf));
    uchain_init(&conf->uchain);
    if (list) {
        ulist_add(list, &conf->uchain);
    }

    conf->options = udict_alloc(mgr, 0);
    conf->id = id;
    return conf;
}
コード例 #2
0
ファイル: upipe_setflowdef.c プロジェクト: digideskio/upipe
/** @internal @This builds the output flow definition.
 *
 * @param upipe description structure of the pipe
 * @param flow_def flow definition packet
 * @return an error code
 */
static int upipe_setflowdef_build_flow_def(struct upipe *upipe)
{
    struct upipe_setflowdef *upipe_setflowdef =
        upipe_setflowdef_from_upipe(upipe);
    struct uref *flow_def_dup;
    if(upipe_setflowdef->flow_def_input == NULL)
        return UBASE_ERR_UNHANDLED;
    if ((flow_def_dup = uref_dup(upipe_setflowdef->flow_def_input)) == NULL)
        return UBASE_ERR_ALLOC;

    if (unlikely(upipe_setflowdef->dict == NULL)) {
        upipe_setflowdef_store_flow_def(upipe, flow_def_dup);
        return UBASE_ERR_NONE;
    }

    if (upipe_setflowdef->dict->udict != NULL) {
        if (flow_def_dup->udict == NULL) {
            flow_def_dup->udict = udict_alloc(flow_def_dup->mgr->udict_mgr, 0);
            if (unlikely(flow_def_dup->udict == NULL)) {
                uref_free(flow_def_dup);
                return UBASE_ERR_ALLOC;
            }
        }
        const char *name = NULL;
        enum udict_type type = UDICT_TYPE_END;
        while (ubase_check(udict_iterate(upipe_setflowdef->dict->udict,
                                         &name, &type)) &&
               type != UDICT_TYPE_END) {
            size_t size;
            const uint8_t *v1 = NULL;
            udict_get(upipe_setflowdef->dict->udict, name, type, &size, &v1);
            uint8_t *v2 = NULL;
            udict_set(flow_def_dup->udict, name, type, size, &v2);
            if (unlikely(v1 == NULL || v2 == NULL)) {
                uref_free(flow_def_dup);
                return UBASE_ERR_ALLOC;
            }
            memcpy(v2, v1, size);
        }
    }

    upipe_setflowdef_store_flow_def(upipe, flow_def_dup);
    return UBASE_ERR_NONE;
}