int main(int argc, char **argv)
{
    struct uprobe *uprobe1 =
        uprobe_stdio_color_alloc(NULL, stdout, UPROBE_LOG_DEBUG);
    assert(uprobe1 != NULL);

    uprobe_err(uprobe1, NULL, "This is an error");
    uprobe_warn_va(uprobe1, NULL, "This is a %s warning with %d", "composite",
                   0x42);
    uprobe_notice(uprobe1, NULL, "This is a notice");
    uprobe_dbg(uprobe1, NULL, "This is a debug");
    uprobe_release(uprobe1);

    struct uprobe *uprobe2 =
        uprobe_stdio_color_alloc(NULL, stdout, UPROBE_LOG_ERROR);
    assert(uprobe2 != NULL);
    uprobe_err_va(uprobe2, NULL, "This is another error with %d", 0x43);
    uprobe_warn(uprobe2, NULL, "This is a warning that you shouldn't see");
    uprobe_release(uprobe2);
    return 0;
}
示例#2
0
/** @This frees a glxplayer resource.
 *
 * @param glxplayer glxplayer context
 */
static void upipe_glxplayer_free(struct upipe_glxplayer *glxplayer)
{
    uprobe_clean(&glxplayer->uprobe_dec_qsrc_s);
    uprobe_clean(&glxplayer->uprobe_avcdec_s);
    uprobe_clean(&glxplayer->uprobe_glx_qsrc_s);
    uprobe_clean(&glxplayer->uprobe_glx_s);
    uprobe_release(glxplayer->uprobe_selprog);
    uprobe_release(glxplayer->uprobe_selflow);
    uprobe_clean(&glxplayer->uprobe_demux_output_s);
    uprobe_release(glxplayer->uprobe_dejitter);
    uprobe_clean(&glxplayer->uprobe_source_s);
    upipe_mgr_release(glxplayer->upipe_filter_blend_mgr);
    upipe_mgr_release(glxplayer->upipe_sws_mgr);
    upipe_mgr_release(glxplayer->upipe_qsink_mgr);
    upipe_mgr_release(glxplayer->upipe_qsrc_mgr);
    upipe_mgr_release(glxplayer->upipe_glx_mgr);
    upipe_mgr_release(glxplayer->upipe_trickp_mgr);
    upipe_mgr_release(glxplayer->upipe_avcdec_mgr);
    upipe_mgr_release(glxplayer->upipe_null_mgr);
    upipe_av_clean();
    uprobe_release(glxplayer->uprobe_logger);
    free(glxplayer);
}
int main(int argc, char **argv)
{
    uprobe = uprobe_pthread_upump_mgr_alloc(NULL);
    assert(uprobe != NULL);

    int i;
    pthread_t ids[NB_THREADS];
    for (i = 0; i < NB_THREADS; i++)
        assert(pthread_create(&ids[i], NULL, thread, NULL) == 0);
    for (i = 0; i < NB_THREADS; i++)
        assert(pthread_join(ids[i], NULL) == 0);

    uprobe_release(uprobe);
    return 0;
}
示例#4
0
/** @internal @This allocates a wsrc pipe.
 *
 * @param mgr common management structure
 * @param uprobe structure used to raise events
 * @param signature signature of the pipe allocator
 * @param args optional arguments
 * @return pointer to upipe or NULL in case of allocation error
 */
static struct upipe *_upipe_wsrc_alloc(struct upipe_mgr *mgr,
                                       struct uprobe *uprobe,
                                       uint32_t signature, va_list args)
{
    struct upipe_wsrc_mgr *wsrc_mgr = upipe_wsrc_mgr_from_upipe_mgr(mgr);
    if (unlikely(signature != UPIPE_WSRC_SIGNATURE ||
                 wsrc_mgr->xfer_mgr == NULL))
        goto upipe_wsrc_alloc_err;
    struct upipe *remote = va_arg(args, struct upipe *);
    struct uprobe *uprobe_remote = va_arg(args, struct uprobe *);
    unsigned int queue_length = va_arg(args, unsigned int);
    assert(queue_length);
    if (unlikely(remote == NULL))
        goto upipe_wsrc_alloc_err2;

    struct upipe_wsrc *upipe_wsrc = malloc(sizeof(struct upipe_wsrc));
    if (unlikely(upipe_wsrc == NULL))
        goto upipe_wsrc_alloc_err2;

    struct upipe *upipe = upipe_wsrc_to_upipe(upipe_wsrc);
    upipe_init(upipe, mgr, uprobe);
    upipe_wsrc_init_urefcount(upipe);
    urefcount_init(upipe_wsrc_to_urefcount_real(upipe_wsrc), upipe_wsrc_free);
    upipe_wsrc_init_last_inner_probe(upipe);
    upipe_wsrc_init_bin_output(upipe);
    upipe_wsrc->source = NULL;

    uprobe_init(&upipe_wsrc->proxy_probe, upipe_wsrc_proxy_probe, NULL);
    upipe_wsrc->proxy_probe.refcount = upipe_wsrc_to_urefcount_real(upipe_wsrc);
    uprobe_init(&upipe_wsrc->qsrc_probe, upipe_wsrc_qsrc_probe,
                &upipe_wsrc->last_inner_probe);
    upipe_wsrc->qsrc_probe.refcount = upipe_wsrc_to_urefcount_real(upipe_wsrc);
    upipe_throw_ready(upipe);

    /* output queue */
    struct upipe *out_qsrc = upipe_qsrc_alloc(wsrc_mgr->qsrc_mgr,
            uprobe_pfx_alloc(uprobe_use(&upipe_wsrc->qsrc_probe),
                             UPROBE_LOG_VERBOSE, "out_qsrc"),
            queue_length > UINT8_MAX ? UINT8_MAX : queue_length);
    if (unlikely(out_qsrc == NULL))
        goto upipe_wsrc_alloc_err3;

    struct upipe *out_qsink = upipe_qsink_alloc(wsrc_mgr->qsink_mgr,
            uprobe_pfx_alloc(uprobe_remote, UPROBE_LOG_VERBOSE,
                             "out_qsink"),
            out_qsrc);
    if (unlikely(out_qsink == NULL)) {
        upipe_release(out_qsrc);
        goto upipe_wsrc_alloc_err3;
    }
    if (queue_length > UINT8_MAX)
        upipe_set_max_length(out_qsink, queue_length - UINT8_MAX);

    upipe_attach_upump_mgr(out_qsrc);
    upipe_wsrc_store_bin_output(upipe, out_qsrc);

    /* last remote */
    struct upipe *last_remote = upipe_use(remote);
    struct upipe *tmp;

    /* upipe_get_output is a control command and may trigger a need_upump_mgr
     * event */
    uprobe_throw(upipe->uprobe, NULL, UPROBE_FREEZE_UPUMP_MGR);
    while (ubase_check(upipe_get_output(last_remote, &tmp)) && tmp != NULL) {
        upipe_use(tmp);
        upipe_release(last_remote);
        last_remote = tmp;
    }
    uprobe_throw(upipe->uprobe, NULL, UPROBE_THAW_UPUMP_MGR);

    struct upipe *last_remote_xfer = upipe_xfer_alloc(wsrc_mgr->xfer_mgr,
            uprobe_pfx_alloc(uprobe_use(&upipe_wsrc->proxy_probe),
                             UPROBE_LOG_VERBOSE, "src_last_xfer"), last_remote);
    if (unlikely(last_remote_xfer == NULL)) {
        upipe_release(out_qsink);
        goto upipe_wsrc_alloc_err3;
    }
    upipe_attach_upump_mgr(last_remote_xfer);
    upipe_set_output(last_remote_xfer, out_qsink);
    upipe_release(out_qsink);

    /* remote */
    if (last_remote != remote) {
        upipe_wsrc->source = upipe_xfer_alloc(wsrc_mgr->xfer_mgr,
                uprobe_pfx_alloc(uprobe_use(&upipe_wsrc->proxy_probe),
                                 UPROBE_LOG_VERBOSE, "src_xfer"), remote);
        if (unlikely(upipe_wsrc->source == NULL)) {
            upipe_release(out_qsink);
            upipe_release(upipe);
            return NULL;
        }
        upipe_attach_upump_mgr(upipe_wsrc->source);
        upipe_release(last_remote_xfer);
    } else {
        upipe_wsrc->source = last_remote_xfer;
        upipe_release(remote);
    }
    return upipe;

upipe_wsrc_alloc_err3:
    upipe_release(remote);
    upipe_release(upipe);
    return NULL;

upipe_wsrc_alloc_err2:
    uprobe_release(uprobe_remote);
    upipe_release(remote);
upipe_wsrc_alloc_err:
    uprobe_release(uprobe);
    return NULL;
}
示例#5
0
int main(int argc, char **argv)
{
    int opt;

    /* parse options */
    while ((opt = getopt(argc, argv, "dqD:")) != -1) {
        switch (opt) {
            case 'd':
                if (loglevel > 0) loglevel--;
                break;
            case 'q':
                if (loglevel < UPROBE_LOG_ERROR) loglevel++;
                break;
            case 'D':
                dump = optarg;
                break;
            default:
                usage(argv[0]);
        }
    }
    if (optind >= argc - 1) {
        usage(argv[0]);
    }
    srcpath = argv[optind++];
    dstpath = argv[optind++];

    /* choose log fd */
    logstream = stderr;

    /* setup environnement */
    struct umem_mgr *umem_mgr = umem_alloc_mgr_alloc();
    struct udict_mgr *udict_mgr = udict_inline_mgr_alloc(UDICT_POOL_DEPTH,
                                                         umem_mgr, -1, -1);
    uref_mgr = uref_std_mgr_alloc(UREF_POOL_DEPTH, udict_mgr,
                                                   0);

    struct upump_mgr *upump_mgr = upump_ev_mgr_alloc_default(UPUMP_POOL,
            UPUMP_BLOCKER_POOL);

    /* default probe */
    logger = uprobe_stdio_alloc(NULL, logstream, loglevel);
    assert(logger != NULL);
    logger = uprobe_uref_mgr_alloc(logger, uref_mgr);
    assert(logger != NULL);
    logger = uprobe_upump_mgr_alloc(logger, upump_mgr);
    assert(logger != NULL);
    logger = uprobe_ubuf_mem_alloc(logger, umem_mgr, UBUF_POOL_DEPTH,
                                   UBUF_POOL_DEPTH);
    assert(logger != NULL);
    uref_mgr_release(uref_mgr);
    upump_mgr_release(upump_mgr);

    /* split probe */
    struct uprobe uprobe_catch;
    uprobe_init(&uprobe_catch, split_catch, uprobe_use(logger));

    /* other probes */
    uprobe_init(&uprobe_avcdec, avcdec_catch, uprobe_use(logger));
    uprobe_init(&uprobe_uref, uref_catch, uprobe_use(logger));

    /* upipe-av */
    upipe_av_init(true, uprobe_use(logger));

    /* global pipe managers */
    upipe_avcdec_mgr = upipe_avcdec_mgr_alloc();
    upipe_avcenc_mgr = upipe_avcenc_mgr_alloc();
    upipe_sws_mgr = upipe_sws_mgr_alloc();
    upipe_filter_blend_mgr = upipe_filter_blend_mgr_alloc();
    upipe_fsink_mgr = upipe_fsink_mgr_alloc();
    upipe_probe_uref_mgr = upipe_probe_uref_mgr_alloc();

    /* null */
    struct upipe_mgr *upipe_null_mgr = upipe_null_mgr_alloc();
    upipe_null = upipe_void_alloc(upipe_null_mgr,
            uprobe_pfx_alloc(uprobe_use(logger), loglevel, "null"));
    assert(upipe_null != NULL);
    upipe_mgr_release(upipe_null_mgr);

    /* file source */
    struct upipe_mgr *upipe_fsrc_mgr = upipe_fsrc_mgr_alloc();
    upipe_source = upipe_void_alloc(upipe_fsrc_mgr,
            uprobe_pfx_alloc(uprobe_use(logger), loglevel, "fsrc"));
    assert(upipe_source != NULL);
    upipe_mgr_release(upipe_fsrc_mgr);
    if (!ubase_check(upipe_set_uri(upipe_source, srcpath)))
        exit(EXIT_FAILURE);

    /* upipe-ts */
    struct upipe_mgr *upipe_ts_demux_mgr = upipe_ts_demux_mgr_alloc();
    struct upipe_mgr *upipe_autof_mgr = upipe_autof_mgr_alloc();
    upipe_ts_demux_mgr_set_autof_mgr(upipe_ts_demux_mgr, upipe_autof_mgr);
    upipe_mgr_release(upipe_autof_mgr);
    struct upipe *ts_demux = upipe_void_alloc_output(upipe_source,
            upipe_ts_demux_mgr,
            uprobe_pfx_alloc(
                uprobe_selflow_alloc(uprobe_use(logger),
                    uprobe_selflow_alloc(uprobe_use(logger), &uprobe_catch,
                        UPROBE_SELFLOW_PIC, "auto"),
                    UPROBE_SELFLOW_VOID, "auto"),
                 loglevel, "tsdemux"));
    assert(ts_demux != NULL);
    upipe_mgr_release(upipe_ts_demux_mgr);
    upipe_release(ts_demux);

    /* fire loop ! */
    upump_mgr_run(upump_mgr, NULL);

    /* release everyhing */
    upipe_release(upipe_source);
    upipe_release(upipe_split_output);
    upipe_release(upipe_null);
    uprobe_release(logger);
    uprobe_clean(&uprobe_catch);
    uprobe_clean(&uprobe_avcdec);
    uprobe_clean(&uprobe_uref);

    upipe_mgr_release(upipe_avcdec_mgr);
    upipe_mgr_release(upipe_avcenc_mgr);
    upipe_mgr_release(upipe_sws_mgr);
    upipe_mgr_release(upipe_filter_blend_mgr);
    upipe_mgr_release(upipe_fsink_mgr);
    upipe_mgr_release(upipe_probe_uref_mgr);

    udict_mgr_release(udict_mgr);
    umem_mgr_release(umem_mgr);

    upipe_av_clean();

    return 0;
}
示例#6
0
/** @This allocates and initializes a glxplayer context.
 *
 * @param loglevel minimum log level to print
 * @return pointer to glxplayer context, or NULL in case of error
 */
static struct upipe_glxplayer *upipe_glxplayer_alloc(enum uprobe_log_level loglevel)
{
    struct upipe_glxplayer *glxplayer = malloc(sizeof(struct upipe_glxplayer));
    if (unlikely(glxplayer == NULL))
        return NULL;
    glxplayer->loglevel = loglevel;
    glxplayer->uri = NULL;
    glxplayer->upipe_ts = false;
    glxplayer->paused = false;

    struct umem_mgr *umem_mgr = umem_pool_mgr_alloc_simple(UMEM_POOL);
    if (unlikely(umem_mgr == NULL))
        goto fail_umem_mgr;

    struct udict_mgr *udict_mgr = udict_inline_mgr_alloc(UDICT_POOL_DEPTH,
                                                         umem_mgr, -1, -1);
    if (unlikely(udict_mgr == NULL))
        goto fail_udict_mgr;

    struct uref_mgr *uref_mgr = uref_std_mgr_alloc(UREF_POOL_DEPTH, udict_mgr,
                                                   0);
    if (unlikely(uref_mgr == NULL))
        goto fail_uref_mgr;

    struct uclock *uclock = uclock_std_alloc(0);
    if (unlikely(uclock == NULL))
        goto fail_probe_logger;

    /* probes common to all threads */
    glxplayer->uprobe_logger =
        uprobe_pthread_upump_mgr_alloc(
            uprobe_ubuf_mem_alloc(
                uprobe_uclock_alloc(
                    uprobe_uref_mgr_alloc(
                         uprobe_stdio_alloc(NULL, stderr, glxplayer->loglevel),
                         uref_mgr), uclock),
                umem_mgr, UBUF_POOL_DEPTH, UBUF_SHARED_POOL_DEPTH));
    uclock_release(uclock);
    if (unlikely(glxplayer->uprobe_logger == NULL))
        goto fail_probe_logger;

    /* upipe-av */
    if (unlikely(!upipe_av_init(false, uprobe_use(glxplayer->uprobe_logger))))
        goto fail_av;

    /* pipes managers */
    glxplayer->upipe_filter_blend_mgr = upipe_filter_blend_mgr_alloc();
    glxplayer->upipe_sws_mgr = upipe_sws_mgr_alloc();
    glxplayer->upipe_qsink_mgr = upipe_qsink_mgr_alloc();
    glxplayer->upipe_qsrc_mgr = upipe_qsrc_mgr_alloc();
    glxplayer->upipe_glx_mgr = upipe_glx_sink_mgr_alloc();
    glxplayer->upipe_trickp_mgr = upipe_trickp_mgr_alloc();
    glxplayer->upipe_avcdec_mgr = upipe_avcdec_mgr_alloc();
    glxplayer->upipe_null_mgr = upipe_null_mgr_alloc();
    if (unlikely(glxplayer->upipe_filter_blend_mgr == NULL ||
                 glxplayer->upipe_sws_mgr == NULL ||
                 glxplayer->upipe_qsink_mgr == NULL ||
                 glxplayer->upipe_qsrc_mgr == NULL ||
                 glxplayer->upipe_glx_mgr == NULL ||
                 glxplayer->upipe_trickp_mgr == NULL ||
                 glxplayer->upipe_avcdec_mgr == NULL ||
                 glxplayer->upipe_null_mgr == NULL))
        goto fail_pipe_mgrs;

    /* probe specific to the source pipe */
    uprobe_init(&glxplayer->uprobe_source_s, upipe_glxplayer_catch_source,
                uprobe_use(glxplayer->uprobe_logger));

    /* probes specific to the demux pipe */
    glxplayer->uprobe_dejitter =
        uprobe_dejitter_alloc(uprobe_use(glxplayer->uprobe_logger), false, 0);
    if (unlikely(glxplayer->uprobe_dejitter == NULL))
        goto fail_dejitter;

    uprobe_init(&glxplayer->uprobe_demux_output_s,
                upipe_glxplayer_catch_demux_output,
                uprobe_use(glxplayer->uprobe_dejitter));

    glxplayer->uprobe_selflow =
        uprobe_selflow_alloc(uprobe_use(glxplayer->uprobe_dejitter),
                             uprobe_use(&glxplayer->uprobe_demux_output_s),
                             UPROBE_SELFLOW_PIC, "auto");
    if (unlikely(glxplayer->uprobe_selflow == NULL))
        goto fail_selflow;
    glxplayer->uprobe_selprog =
        uprobe_selflow_alloc(uprobe_use(glxplayer->uprobe_logger),
                             uprobe_use(glxplayer->uprobe_selflow),
                             UPROBE_SELFLOW_VOID, "auto");
    if (unlikely(glxplayer->uprobe_selprog == NULL))
        goto fail_selprog;

    /* probe specific to the dec queue source */
    uprobe_init(&glxplayer->uprobe_dec_qsrc_s,
                upipe_glxplayer_catch_dec_qsrc,
                uprobe_use(glxplayer->uprobe_logger));

    /* probe specific to the avcdec */
    uprobe_init(&glxplayer->uprobe_avcdec_s,
                upipe_glxplayer_catch_avcdec,
                uprobe_use(glxplayer->uprobe_logger));

    /* probe specific to the glx queue source */
    uprobe_init(&glxplayer->uprobe_glx_qsrc_s,
                upipe_glxplayer_catch_glx_qsrc,
                uprobe_use(glxplayer->uprobe_logger));

    /* probe specific to the glx pipe */
    uprobe_init(&glxplayer->uprobe_glx_s,
                upipe_glxplayer_catch_glx,
                uprobe_use(glxplayer->uprobe_logger));

    uref_mgr_release(uref_mgr);
    umem_mgr_release(umem_mgr);
    udict_mgr_release(udict_mgr);
    return glxplayer;

fail_selprog:
    uprobe_release(glxplayer->uprobe_selflow);
fail_selflow:
    uprobe_clean(&glxplayer->uprobe_demux_output_s);
    uprobe_release(glxplayer->uprobe_dejitter);
fail_dejitter:
    uprobe_clean(&glxplayer->uprobe_source_s);
fail_pipe_mgrs:
    if (glxplayer->upipe_filter_blend_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_filter_blend_mgr);
    if (glxplayer->upipe_sws_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_sws_mgr);
    if (glxplayer->upipe_qsink_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_qsink_mgr);
    if (glxplayer->upipe_qsrc_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_qsrc_mgr);
    if (glxplayer->upipe_glx_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_glx_mgr);
    if (glxplayer->upipe_trickp_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_trickp_mgr);
    if (glxplayer->upipe_avcdec_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_avcdec_mgr);
    if (glxplayer->upipe_null_mgr != NULL)
        upipe_mgr_release(glxplayer->upipe_null_mgr);
    upipe_av_clean();
fail_av:
    uprobe_release(glxplayer->uprobe_logger);
fail_probe_logger:
    uref_mgr_release(uref_mgr);
fail_uref_mgr:
    udict_mgr_release(udict_mgr);
fail_udict_mgr:
    umem_mgr_release(umem_mgr);
fail_umem_mgr:
    free(glxplayer);
    return NULL;
}
示例#7
0
/** @internal @This allocates a wsink pipe.
 *
 * @param mgr common management structure
 * @param uprobe structure used to raise events
 * @param signature signature of the pipe allocator
 * @param args optional arguments
 * @return pointer to upipe or NULL in case of allocation error
 */
static struct upipe *_upipe_wsink_alloc(struct upipe_mgr *mgr,
                                       struct uprobe *uprobe,
                                       uint32_t signature, va_list args)
{
    struct upipe_wsink_mgr *wsink_mgr = upipe_wsink_mgr_from_upipe_mgr(mgr);
    if (unlikely(signature != UPIPE_WSINK_SIGNATURE ||
                 wsink_mgr->xfer_mgr == NULL))
        goto upipe_wsink_alloc_err;
    struct upipe *remote = va_arg(args, struct upipe *);
    struct uprobe *uprobe_remote = va_arg(args, struct uprobe *);
    unsigned int queue_length = va_arg(args, unsigned int);
    assert(queue_length);
    if (unlikely(remote == NULL))
        goto upipe_wsink_alloc_err2;

    struct upipe_wsink *upipe_wsink = malloc(sizeof(struct upipe_wsink));
    if (unlikely(upipe_wsink == NULL))
        goto upipe_wsink_alloc_err2;

    struct upipe *upipe = upipe_wsink_to_upipe(upipe_wsink);
    upipe_init(upipe, mgr, uprobe);
    upipe_wsink_init_urefcount(upipe);
    urefcount_init(upipe_wsink_to_urefcount_real(upipe_wsink),
                   upipe_wsink_free);
    upipe_wsink_init_bin_input(upipe);

    uprobe_init(&upipe_wsink->proxy_probe, upipe_wsink_proxy_probe, NULL);
    upipe_wsink->proxy_probe.refcount =
        upipe_wsink_to_urefcount_real(upipe_wsink);
    uprobe_init(&upipe_wsink->in_qsrc_probe, upipe_wsink_in_qsrc_probe,
                uprobe_remote);
    upipe_wsink->in_qsrc_probe.refcount =
        upipe_wsink_to_urefcount_real(upipe_wsink);
    upipe_throw_ready(upipe);

    /* remote */
    upipe_use(remote);
    struct upipe *remote_xfer = upipe_xfer_alloc(wsink_mgr->xfer_mgr,
            uprobe_pfx_alloc(uprobe_use(&upipe_wsink->proxy_probe),
                             UPROBE_LOG_VERBOSE, "sink_xfer"), remote);
    if (unlikely(remote_xfer == NULL)) {
        upipe_release(remote);
        upipe_release(upipe);
        return NULL;
    }
    upipe_attach_upump_mgr(remote_xfer);

    /* input queue */
    struct upipe *in_qsrc = upipe_qsrc_alloc(wsink_mgr->qsrc_mgr,
            uprobe_pfx_alloc(
                uprobe_use(&upipe_wsink->in_qsrc_probe),
                UPROBE_LOG_VERBOSE, "in_qsrc"),
            queue_length > UINT8_MAX ? UINT8_MAX : queue_length);
    if (unlikely(in_qsrc == NULL))
        goto upipe_wsink_alloc_err3;

    struct upipe *in_qsink = upipe_qsink_alloc(wsink_mgr->qsink_mgr,
            uprobe_pfx_alloc(uprobe_use(&upipe_wsink->proxy_probe),
                             UPROBE_LOG_VERBOSE, "in_qsink"),
            in_qsrc);
    if (unlikely(in_qsink == NULL))
        goto upipe_wsink_alloc_err3;
    upipe_wsink_store_bin_input(upipe, in_qsink);
    if (queue_length > UINT8_MAX)
        upipe_set_max_length(upipe_wsink->in_qsink, queue_length - UINT8_MAX);

    struct upipe *in_qsrc_xfer = upipe_xfer_alloc(wsink_mgr->xfer_mgr,
            uprobe_pfx_alloc(uprobe_use(&upipe_wsink->proxy_probe),
                             UPROBE_LOG_VERBOSE, "in_qsrc_xfer"),
            in_qsrc);
    if (unlikely(in_qsrc_xfer == NULL))
        goto upipe_wsink_alloc_err3;
    upipe_set_output(in_qsrc_xfer, remote);
    upipe_attach_upump_mgr(in_qsrc_xfer);
    upipe_release(remote);
    upipe_release(remote_xfer);
    upipe_release(in_qsrc_xfer);
    return upipe;

upipe_wsink_alloc_err3:
    upipe_release(remote);
    upipe_release(remote_xfer);
    upipe_release(upipe);
    return NULL;

upipe_wsink_alloc_err2:
    upipe_release(remote);
upipe_wsink_alloc_err:
    uprobe_release(uprobe);
    return NULL;
}
示例#8
0
int main(int argc, char *argv[])
{
    assert(argc >= 2);
    nb_files = argc - 1;
    files = argv + 1;

    struct upump_mgr *upump_mgr = upump_ev_mgr_alloc_default(UPUMP_POOL,
            UPUMP_BLOCKER_POOL);
    assert(upump_mgr != NULL);

    struct umem_mgr *umem_mgr = umem_alloc_mgr_alloc();
    assert(umem_mgr != NULL);
    struct udict_mgr *udict_mgr = udict_inline_mgr_alloc(UDICT_POOL_DEPTH,
                                                         umem_mgr, -1, -1);
    assert(udict_mgr != NULL);
    struct uref_mgr *uref_mgr = uref_std_mgr_alloc(UREF_POOL_DEPTH, udict_mgr,
                                                   0);
    /* main probe */
    struct uprobe *logger =
        uprobe_stdio_alloc(NULL, stderr, UPROBE_LOG_VERBOSE);
    assert(logger != NULL);
    logger = uprobe_uref_mgr_alloc(logger, uref_mgr);
    assert(logger != NULL);
    logger = uprobe_upump_mgr_alloc(logger, upump_mgr);
    assert(logger != NULL);
    logger = uprobe_ubuf_mem_alloc(logger, umem_mgr, UBUF_POOL_DEPTH,
                                   UBUF_POOL_DEPTH);
    assert(logger != NULL);

    /* file source */
    struct uprobe uprobe_fsrc;
    uprobe_init(&uprobe_fsrc, catch_fsrc, uprobe_use(logger));
    struct upipe_mgr *upipe_fsrc_mgr = upipe_fsrc_mgr_alloc();
    assert(upipe_fsrc_mgr != NULL);
    struct upipe *upipe_fsrc = upipe_void_alloc(upipe_fsrc_mgr,
            uprobe_pfx_alloc(uprobe_use(&uprobe_fsrc),
                             UPROBE_LOG_DEBUG, "file source"));
    assert(upipe_fsrc != NULL);
    upipe_mgr_release(upipe_fsrc_mgr);
    ubase_assert(upipe_set_uri(upipe_fsrc, files[current]));

    /* m3u reader */
    struct upipe_mgr *upipe_m3u_reader_mgr = upipe_m3u_reader_mgr_alloc();
    assert(upipe_m3u_reader_mgr != NULL);
    struct upipe *upipe_m3u_reader = upipe_void_alloc_output(
        upipe_fsrc, upipe_m3u_reader_mgr,
        uprobe_pfx_alloc(uprobe_use(logger),
                         UPROBE_LOG_VERBOSE, "m3u reader"));
    upipe_mgr_release(upipe_m3u_reader_mgr);
    assert(upipe_m3u_reader != NULL);

    struct uprobe uprobe_uref;
    uprobe_init(&uprobe_uref, catch_uref, uprobe_use(logger));
    struct upipe_mgr *upipe_probe_uref_mgr = upipe_probe_uref_mgr_alloc();
    assert(upipe_probe_uref_mgr != NULL);
    struct upipe *upipe_probe_uref = upipe_void_chain_output(
        upipe_m3u_reader, upipe_probe_uref_mgr,
        uprobe_pfx_alloc(uprobe_use(&uprobe_uref),
                         UPROBE_LOG_DEBUG, "probe uref"));
    upipe_mgr_release(upipe_probe_uref_mgr);
    assert(upipe_probe_uref != NULL);

    /* null output */
    struct upipe_mgr *upipe_null_mgr = upipe_null_mgr_alloc();
    assert(upipe_null_mgr != NULL);
    struct upipe *upipe_null = upipe_void_chain_output(
        upipe_probe_uref, upipe_null_mgr,
        uprobe_pfx_alloc(uprobe_use(logger),
                         UPROBE_LOG_DEBUG, "null"));
    upipe_mgr_release(upipe_null_mgr);
    assert(upipe_null != NULL);
    upipe_release(upipe_null);

    /* run main loop */
    upump_mgr_run(upump_mgr, NULL);

    /* release */
    upipe_release(upipe_fsrc);
    upump_mgr_release(upump_mgr);
    uref_mgr_release(uref_mgr);
    udict_mgr_release(udict_mgr);
    umem_mgr_release(umem_mgr);
    uprobe_clean(&uprobe_fsrc);
    uprobe_clean(&uprobe_uref);
    uprobe_release(logger);
    return 0;
}