Can't create recorder using python bindings

TK
Tiago Katcipis
Wed, Aug 22, 2018 8:20 PM

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

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
TK
Tiago Katcipis
Mon, Aug 27, 2018 7:41 PM

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@gmail.com
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

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@gmail.com> 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 > > >
TK
Tiago Katcipis
Tue, Aug 28, 2018 12:56 AM

There is probably a million ways better to solve this but now I'm able to
create recorders after I added an function to create values with the type
pj_ssize_t. The function has been added using SWIG inline feature, like
this:

%inline %{
pj_ssize_t new_pj_ssize_t(int s) {
return (pj_ssize_t) s;
}
%}

I searched some time for some way to create the parameter other than that,
but failed miserably =(

Best regards,
Katcipis

On Mon, Aug 27, 2018 at 4:41 PM Tiago Katcipis tiagokatcipis@gmail.com
wrote:

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@gmail.com
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

There is probably a million ways better to solve this but now I'm able to create recorders after I added an function to create values with the type pj_ssize_t. The function has been added using SWIG inline feature, like this: %inline %{ pj_ssize_t new_pj_ssize_t(int s) { return (pj_ssize_t) s; } %} I searched some time for some way to create the parameter other than that, but failed miserably =( Best regards, Katcipis On Mon, Aug 27, 2018 at 4:41 PM Tiago Katcipis <tiagokatcipis@gmail.com> wrote: > 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@gmail.com> > 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 >> >> >>
TK
Tiago Katcipis
Tue, Aug 28, 2018 12:59 AM

I forgot to show the Python code on the previous email, sorry. After adding
the inline function to create variables with the type pj_ssize_t the Python
code looks like this:

import pjsua2 as pj

enc_type = 0
max_size = pj.new_pj_ssize_t(-1)
options = pj.PJMEDIA_FILE_WRITE_PCM

recorder = pj.AudioMediaRecorder()
print("creating recorder")
recorder.createRecorder("test.wav", enc_type, max_size, options)
print("done with success")

On Mon, Aug 27, 2018 at 9:56 PM Tiago Katcipis tiagokatcipis@gmail.com
wrote:

There is probably a million ways better to solve this but now I'm able to
create recorders after I added an function to create values with the type
pj_ssize_t. The function has been added using SWIG inline feature, like
this:

%inline %{
pj_ssize_t new_pj_ssize_t(int s) {
return (pj_ssize_t) s;
}
%}

I searched some time for some way to create the parameter other than that,
but failed miserably =(

Best regards,
Katcipis

On Mon, Aug 27, 2018 at 4:41 PM Tiago Katcipis tiagokatcipis@gmail.com
wrote:

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@gmail.com
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

I forgot to show the Python code on the previous email, sorry. After adding the inline function to create variables with the type pj_ssize_t the Python code looks like this: import pjsua2 as pj enc_type = 0 max_size = pj.new_pj_ssize_t(-1) options = pj.PJMEDIA_FILE_WRITE_PCM recorder = pj.AudioMediaRecorder() print("creating recorder") recorder.createRecorder("test.wav", enc_type, max_size, options) print("done with success") On Mon, Aug 27, 2018 at 9:56 PM Tiago Katcipis <tiagokatcipis@gmail.com> wrote: > There is probably a million ways better to solve this but now I'm able to > create recorders after I added an function to create values with the type > pj_ssize_t. The function has been added using SWIG inline feature, like > this: > > %inline %{ > pj_ssize_t new_pj_ssize_t(int s) { > return (pj_ssize_t) s; > } > %} > > I searched some time for some way to create the parameter other than that, > but failed miserably =( > > Best regards, > Katcipis > > On Mon, Aug 27, 2018 at 4:41 PM Tiago Katcipis <tiagokatcipis@gmail.com> > wrote: > >> 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@gmail.com> >> 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 >>> >>> >>>