Exemple #1
0
/** @internal @This handles input buffers.
 *
 * @param upipe description structure of the pipe
 * @param uref input buffer to handle
 * @param upump_p reference to pump that generated the buffer
 */
static void upipe_ablk_input(struct upipe *upipe,
                             struct uref *uref,
                             struct upump **upump_p)
{
    struct upipe_ablk *upipe_ablk = upipe_ablk_from_upipe(upipe);
    struct uref *input_flow_def = upipe_ablk->input_flow_def;
    struct uref *flow_def = upipe_ablk->flow_def;

    if (uref->ubuf) {
        upipe_ablk_output(upipe, uref, upump_p);
        return;
    }

    if (unlikely(!input_flow_def)) {
        upipe_warn(upipe, "no input flow definition");
        uref_free(uref);
        return;
    }

    if (unlikely(!flow_def)) {
        upipe_warn(upipe, "no output flow definition set");
        uref_free(uref);
        return;
    }

    if (unlikely(!upipe_ablk->ubuf_mgr)) {
        upipe_warn(upipe, "no ubuf manager set");
        uref_free(uref);
        return;
    }

    if (unlikely(!upipe_ablk->ubuf)) {
        upipe_verbose(upipe, "allocate blank sound");

        uint64_t samples = 0;
        uint8_t sample_size = 0;
        uref_sound_flow_get_samples(flow_def, &samples);
        uref_sound_flow_get_sample_size(flow_def, &sample_size);

        struct ubuf *ubuf = ubuf_sound_alloc(upipe_ablk->ubuf_mgr, samples);
        if (unlikely(!ubuf)) {
            upipe_throw_fatal(upipe, UBASE_ERR_ALLOC);
            uref_free(uref);
            return;
        }

        const char *channel;
        uint8_t *buf = NULL;
        ubuf_sound_foreach_plane(ubuf, channel) {
            ubuf_sound_plane_write_uint8_t(ubuf, channel, 0, -1, &buf);
            memset(buf, 0, sample_size * samples);
            ubuf_sound_plane_unmap(ubuf, channel, 0, -1);
        }
Exemple #2
0
/** @internal @This checks a "#EXT-X-ENDLIST" tag.
 *
 * @param upipe description structure of the pipe
 * @param flow_def the current flow definition
 * @param line the trailing characters of the line
 * @return an error code
 */
static int upipe_m3u_reader_ext_x_endlist(struct upipe *upipe,
                                          struct uref *flow_def,
                                          const char *line)
{
    const char *def;
    UBASE_RETURN(uref_flow_get_def(flow_def, &def));
    if (strcmp(def, M3U_FLOW_DEF) && strcmp(def, PLAYLIST_FLOW_DEF))
        return UBASE_ERR_INVALID;
    UBASE_RETURN(uref_flow_set_def(flow_def, PLAYLIST_FLOW_DEF));

    upipe_verbose(upipe, "endlist tag");
    return uref_m3u_playlist_flow_set_endlist(flow_def);
}
Exemple #3
0
/** @internal @This checks a "#EXTM3U" tag.
 *
 * @param upipe description structure of the pipe
 * @param flow_def the current flow definition
 * @param line the trailing characters of the line
 * @return an error code
 */
static int upipe_m3u_reader_process_m3u(struct upipe *upipe,
                                        struct uref *flow_def,
                                        const char *line)
{
    while (isspace(*line))
        line++;

    if (strlen(line)) {
        upipe_err(upipe, "invalid EXTM3U tag");
        return UBASE_ERR_INVALID;
    }
    upipe_verbose(upipe, "found EXTM3U tag");

    const char *def;
    UBASE_RETURN(uref_flow_get_def(flow_def, &def));
    if (strcmp(def, EXPECTED_FLOW_DEF))
        return UBASE_ERR_INVALID;
    return uref_flow_set_def(flow_def, M3U_FLOW_DEF);
}
Exemple #4
0
/** @internal @This handles the input uref.
 *
 * @param upipe description structure of the pipe
 * @param uref input uref
 * @param upump_p reference to pump that generated the buffer
 */
static void upipe_vblk_input(struct upipe *upipe,
                             struct uref *uref,
                             struct upump **upump_p)
{
    struct upipe_vblk *upipe_vblk = upipe_vblk_from_upipe(upipe);
    struct uref *flow_def = upipe_vblk->flow_def;
    struct uref *input_flow_def = upipe_vblk->input_flow_def;

    if (uref->ubuf) {
        upipe_vblk_output(upipe, uref, upump_p);
        return;
    }

    if (unlikely(!input_flow_def)) {
        upipe_warn(upipe, "no input flow definition");
        uref_free(uref);
        return;
    }

    if (unlikely(!flow_def)) {
        upipe_warn(upipe, "no output flow definition");
        uref_free(uref);
        return;
    }

    if (unlikely(!upipe_vblk->ubuf_mgr)) {
        upipe_warn(upipe, "no ubuf manager set");
        uref_free(uref);
        return;
    }

    if (unlikely(!upipe_vblk->ubuf)) {
        upipe_verbose(upipe, "allocate blank picture");

        uint64_t hsize, vsize;
        ubase_assert(uref_pic_flow_get_hsize(upipe_vblk->flow_def, &hsize));
        ubase_assert(uref_pic_flow_get_vsize(upipe_vblk->flow_def, &vsize));

        upipe_vblk->ubuf = ubuf_pic_alloc(upipe_vblk->ubuf_mgr, hsize, vsize);
        if (unlikely(!upipe_vblk->ubuf)) {
            upipe_err(upipe, "fail to allocate picture");
            uref_free(uref);
            upipe_throw_fatal(upipe, UBASE_ERR_ALLOC);
            return;
        }
        ubuf_pic_clear(upipe_vblk->ubuf, 0, 0, -1, -1, 1);
    }

    struct ubuf *ubuf = ubuf_dup(upipe_vblk->ubuf);
    if (unlikely(!ubuf)) {
        upipe_err(upipe, "fail to duplicate blank picture");
        uref_free(uref);
        upipe_throw_fatal(upipe, UBASE_ERR_ALLOC);
        return;
    }

    uref_attach_ubuf(uref, ubuf);
    if (ubase_check(uref_pic_get_progressive(flow_def)))
        uref_pic_set_progressive(uref);

    upipe_vblk_output(upipe, uref, upump_p);
}