Trying to implement a callback function of libvlc problem with the types variables to pass



  • Hello

    I am trying to do a callback function of libvlc

    Function of libvlc

    Callback function open

    Callback function read

    const int tamanio_buffer=1024;                                                              
    unsigned char MPEG2_TS[tamanio_buffer]; 
    libvlc_instance_t       *instancia_vlc_hilo;
    
    int media_open_cb(void *opaque, void **datap, uint64_t *sizep) {
        *sizep = 1024;
        *datap = opaque;
        return 0;
    }
    
    ss media_read_cb(void *opaque, unsigned char *buf, int len) {
    
        return len;
    }
    
    void media_close_cb(void *opaque) {
    
    }
    
    
    libvlc_media_t *media_hilo = libvlc_media_new_callbacks(
                                        instancia_vlc_hilo,
                                             media_open_cb,
                                             media_read_cb,
                                                      NULL,
                                                      NULL,
                                                  MPEG2_TS);
    

    But i can't compile it

    Error

    ||=== Build: Debug in gtk3cpp (compiler: GNU GCC Compiler) ===|
    /home/pasante/Escritorio/espaniol/gtk3cpp_archivo/include/thread.h|50|error: invalid conversion from ‘long int (*)(void*, unsigned char*, int)’ to ‘libvlc_media_read_cb {aka long int (*)(void*, unsigned char*, long unsigned int)}’ [-fpermissive]|
    /usr/include/vlc/libvlc_media.h|438|note:   initializing argument 3 of ‘libvlc_media_t* libvlc_media_new_callbacks(libvlc_instance_t*, libvlc_media_open_cb, libvlc_media_read_cb, libvlc_media_seek_cb, libvlc_media_close_cb, void*)’|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
    
    I don't know why it can't convert the variables if there are the same type
    

  • Moderators

    @aurquiel Please read the error message again: both function pointer types are not same:

    invalid conversion from ‘long int (*)(void*, unsigned char*, int)’ to ‘libvlc_media_read_cb {aka long int (*)(void*, unsigned char*, long unsigned int)
    

    int != long unsigned int



  • int media_open_cb(void *opaque, void **datap, long unsigned int *sizep) {
        *sizep = 1024;
        *datap = opaque;
        return 0;
    }
    
    int media_read_cb(void *opaque, unsigned char *buf, long unsigned int len) {
    
        return len;
    }
    
    void media_close_cb(void *opaque) {
    
    }
    
    
    libvlc_media_t *media_hilo = libvlc_media_new_callbacks(
                                        instancia_vlc_hilo,
                                             media_open_cb,
                                             media_read_cb,
                                                      NULL,
                                                      NULL,
                                                  MPEG2_TS);
    

    i tray changing the parameters to long unsigned int

    ||=== Build: Debug in gtk3cpp (compiler: GNU GCC Compiler) ===|
    /home/pasante/Escritorio/espaniol/gtk3cpp_archivo/include/thread.h|50|error: invalid conversion from ‘int ()(void, unsigned char*, long unsigned int)’ to ‘libvlc_media_read_cb {aka long int ()(void, unsigned char*, long unsigned int)}’ [-fpermissive]|
    /usr/include/vlc/libvlc_media.h|438|note: initializing argument 3 of ‘libvlc_media_t* libvlc_media_new_callbacks(libvlc_instance_t*, libvlc_media_open_cb, libvlc_media_read_cb, libvlc_media_seek_cb, libvlc_media_close_cb, void*)’|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

    I can't figure out


  • Moderators

    @aurquiel Again - read the error message.
    Return types are different: int != long


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.