Re: Can't create recorder using python bindings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I did some debugging on the SWIG generated code, more specifically on the function:

SWIGINTERN PyObject *_wrap_AudioMediaRecorder_createRecorder(PyObject *self, PyObject *args)

And it seems that the version with 5 parameters is always called, since it has default parameters on the Python generated code, so it always enters the if (argc == 5) branch:

if (argc == 5) {
    int _v;
    void *vptr = 0;
    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_pj__AudioMediaRecorder, 0);
    _v = SWIG_CheckState(res);

    if (_v) {
      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
      _v = SWIG_CheckState(res);
      
      if (_v) {
        {
          int res = SWIG_AsVal_unsigned_SS_int(argv[2], NULL);
          _v = SWIG_CheckState(res);
        }
        if (_v) {
          int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_pj_ssize_t, 0);
          _v = SWIG_CheckState(res);
          if (_v) {
            {
              int res = SWIG_AsVal_unsigned_SS_int(argv[4], NULL);
              _v = SWIG_CheckState(res);
            }
            if (_v) {
              return _wrap_AudioMediaRecorder_createRecorder__SWIG_0(self, args);
            }
          }
        }
      }
    }
  }

The validation that is failing is this one:

int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_pj_ssize_t, 0);
_v = SWIG_CheckState(res);

Passing an integer as the max_size parameter does not work, and the default parameter passed is an integer.

I just found this out and I'm checking on how I can create a parameter of the type  SWIGTYPE_p_pj_ssize_t, but at least the python generated code seems to be wrong since it is passing an integer as the default parameter and the integer is not passing this check.

If someone can point me on the right direction it would be deeply appreciated, never worked with SWIG before =)

Best regards,
Katcipis

On Wed, Aug 22, 2018 at 5:20 PM Tiago Katcipis <tiagokatcipis@xxxxxxxxx> wrote:
Hi,

I'm working with python 3 + pjsip version 2.7.2 downloaded from here:

http://www.pjsip.org/release/2.7.2/pjproject-2.7.2.tar.bz2

And I'm currently able to establish calls with success and send audio using the AudioMediaPlayer, but when I tried to record the received audio using the AudioMediaRecorder I simply cant instantiate it, the following code:

import pjsua2 as pj

recorder = pj.AudioMediaRecorder()
recorder.createRecorder("test.wav")

Results in:

Traceback (most recent call last):
  File "error.py", line 4, in <module>
    recorder.createRecorder("test.wav")
  File "/root/.local/lib/python3.6/site-packages/pjsua2.py", line 3937, in createRecorder
    return _pjsua2.AudioMediaRecorder_createRecorder(self, file_name, enc_type, max_size, options)
NotImplementedError: Wrong number or type of arguments for overloaded function 'AudioMediaRecorder_createRecorder'.
  Possible C/C++ prototypes are:
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int,pj_ssize_t,unsigned int)
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int,pj_ssize_t)
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int)
    pj::AudioMediaRecorder::createRecorder(pj::string const &)

I can see clearly a compatible function that receives just a string. Anyway I tried passing the other arguments like this:

import pjsua2 as pj

enc_type = 0
max_size = -1
options = pj.PJMEDIA_FILE_WRITE_PCM

recorder = pj.AudioMediaRecorder()
recorder.createRecorder("test.wav", enc_type, max_size, options)

And I get a similar error:

File "error.py", line 8, in <module>
    recorder.createRecorder("test.wav", enc_type, max_size, options)
  File "/root/.local/lib/python3.6/site-packages/pjsua2.py", line 3937, in createRecorder
    return _pjsua2.AudioMediaRecorder_createRecorder(self, file_name, enc_type, max_size, options)
NotImplementedError: Wrong number or type of arguments for overloaded function 'AudioMediaRecorder_createRecorder'.
  Possible C/C++ prototypes are:
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int,pj_ssize_t,unsigned int)
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int,pj_ssize_t)
    pj::AudioMediaRecorder::createRecorder(pj::string const &,unsigned int)
    pj::AudioMediaRecorder::createRecorder(pj::string const &)

I searched the project for an example on how to use the createRecorder method but was unable to find any. Any help will be greatly appreciated.

Best regards,
Katcipis


_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux