Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Trying to implement a callback function of libvlc problem with the types variables to pass
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aurquiel
    wrote on last edited by
    #1

    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
    
    jsulmJ 1 Reply Last reply
    0
    • A aurquiel

      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
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • A Offline
        A Offline
        aurquiel
        wrote on last edited by
        #3
        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

        jsulmJ 1 Reply Last reply
        0
        • A aurquiel
          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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved