[vlc-devel] A little coding advice needed for creating stream_t objects.

Bill C. Riemers briemers at redhat.com
Mon Jul 7 18:51:35 CEST 2008


I have a some code I've written as a standalone application that needs
to create vlc stream_t objects.  I have written a kludge, but the
biggest problem with this kludge is it requires I include files directly
from the vlc source tree.   I am looking for a way to accomplish the
same thing, without depending on vlc source tree. 

The following is my kludge for create a vlm object for use with
stream_UrlNew calls.


static vlc_object_t p_vlm = NULL;

static int libvlc_vlm_init( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_exception )
{
#ifdef ENABLE_VLM
    if( !p_instance->p_vlm )
        p_instance->p_vlm = vlm_New( p_instance->p_libvlc_int );
#else
    libvlc_exception_raise( p_exception, "VLM has been disabled in this
libvlc." );
    return VLC_EGENERIC;
#endif

    if( !p_instance->p_vlm )
    {
        libvlc_exception_raise( p_exception,
                                "Unable to create VLM." );
        return VLC_EGENERIC;
    }
    return VLC_SUCCESS;
}

void foo_init() {
    vlcmodule_t *p_vlcmodule = (vlcmodule_t *)calloc(1,sizeof(vlcmodule_t));
    if(p_vlcmodule == NULL ) {
        goto outofmemory;
    }
    p_vlcmodule->destroy = vlcmodule_destroy;
    libvlc_exception_t *p_ex = &p_vlcmodule->ex;
    libvlc_exception_t *p_dummy = &p_vlcmodule->dummy;
    libvlc_exception_init (p_ex);
    libvlc_exception_init (p_dummy);

    static const char *args[] = {"cvlc","-I","dummy",NULL};
    p_vlcmodule->vlc = libvlc_new(3,args,p_ex);
    if (p_vlcmodule->vlc == NULL)
    {
        goto error;
    }

    libvlc_add_intf (p_vlcmodule->vlc, "signals", p_dummy);
    libvlc_add_intf (p_vlcmodule->vlc, NULL, p_ex);
    libvlc_vlm_init (p_vlcmodule->vlc, p_ex);
    p_vlm = (vlc_object_t *)p_vlcmodule->vlc->p_vlm;
error:
    VLC_Destroy((vlc_object_t *)p_vlcmodule);
    return NULL;

outofmemory:
    {
        libvlc_exception_t ex;
        libvlc_exception_init ( &ex );
        libvlc_exception_raise( &ex, "Out of memory.");
    }
    return NULL;
}





More information about the vlc-devel mailing list