Esempio n. 1
0
int main(void)
{
    ssize_t val;
    char buf[16];
    bool b;

    test_init();

    vlc = libvlc_new(0, NULL);
    assert(vlc != NULL);
    parent = VLC_OBJECT(vlc->p_libvlc_int);

    s = vlc_stream_fifo_New(parent);
    assert(s != NULL);
    val = stream_Control(s, STREAM_CAN_SEEK, &b);
    assert(val == VLC_SUCCESS && !b);
    val = stream_GetSize(s, &(uint64_t){ 0 });
    assert(val < 0);
    val = stream_Control(s, STREAM_GET_PTS_DELAY, &(int64_t){ 0 });
    assert(val == VLC_SUCCESS);
    stream_Delete(s);
    vlc_stream_fifo_Close(s);

    s = vlc_stream_fifo_New(parent);
    assert(s != NULL);
    val = vlc_stream_fifo_Write(s, "123", 3);
    vlc_stream_fifo_Close(s);
    val = stream_Read(s, buf, sizeof (buf));
    assert(val == 3);
    assert(memcmp(buf, "123", 3) == 0);
    val = stream_Read(s, buf, sizeof (buf));
    assert(val == 0);
    stream_Delete(s);

    s = vlc_stream_fifo_New(parent);
    assert(s != NULL);
    val = vlc_stream_fifo_Write(s, "Hello ", 6);
    assert(val == 6);
    val = vlc_stream_fifo_Write(s, "world!\n", 7);
    assert(val == 7);
    val = vlc_stream_fifo_Write(s, "blahblah", 8);
    assert(val == 8);

    val = stream_Read(s, buf, 13);
    assert(val == 13);
    assert(memcmp(buf, "Hello world!\n", 13) == 0);
    stream_Delete(s);

    val = vlc_stream_fifo_Write(s, "cough cough", 11);
    assert(val == -1 && errno == EPIPE);
    vlc_stream_fifo_Close(s);

    libvlc_release(vlc);

    return 0;
}
Esempio n. 2
0
vlc_demux_chained_t *vlc_demux_chained_New(vlc_object_t *parent,
                                           const char *name, es_out_t *out)
{
    vlc_demux_chained_t *dc = malloc(sizeof (*dc) + strlen(name) + 1);
    if (unlikely(dc == NULL))
        return NULL;

    dc->writer = vlc_stream_fifo_New(parent, &dc->reader);
    if (dc->writer == NULL)
    {
        free(dc);
        return NULL;
    }

    dc->stats.position = 0.;
    dc->stats.length = 0;
    dc->stats.time = 0;
    dc->out = out;
    strcpy(dc->name, name);

    vlc_mutex_init(&dc->lock);

    if (vlc_clone(&dc->thread, vlc_demux_chained_Thread, dc,
                  VLC_THREAD_PRIORITY_INPUT))
    {
        vlc_stream_Delete(dc->reader);
        vlc_stream_fifo_Close(dc->writer);
        vlc_mutex_destroy(&dc->lock);
        free(dc);
        dc = NULL;
    }
    return dc;
}
Esempio n. 3
0
void vlc_demux_chained_Delete(vlc_demux_chained_t *dc)
{
    vlc_stream_fifo_Close(dc->writer);
    vlc_join(dc->thread, NULL);
    vlc_mutex_destroy(&dc->lock);
    free(dc);
}