Audio recording in WAV format using PJSUA

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

 



Thanks Andreas for your answers.

I do have the code for checking return code from PJSUA APIs but I didn't
mentioned here for brevity. 
Every PJSUA API in this sample code was successful. When I checked the WAV
file, using file command then following is the output:

1372888804:09:2012_12:01:48.wav: RIFF (little-endian) data, WAVE audio,
Microsoft PCM, 16 bit, mono 8000 Hz

While I try to play this file using play command on linux, it gives
following output and the file is not played:
------------------------------------------->
root at ubuntu:~ # play 1372888804:09:2012_12:01:48.wav

1372888804:09:2012_12:01:48.wav:

 File Size: 995k
  Encoding: Signed PCM
  Channels: 1 @ 16-bit
Samplerate: 8000Hz
Replaygain: off
  Duration: unknown

In:0.00% 00:00:00.00 [00:00:00.00] Out:0     [      |      ]        Clip:0
----------------------------------->

The duration of the file is shown is unknown, But when I try to play a file
which is successfully being played it has the following output:
File Size: 86.6k     Bit Rate: 128k
  Encoding: Signed PCM
  Channels: 1 @ 16-bit
Samplerate: 8000Hz
Replaygain: off
  Duration: 00:00:05.41

Here duration of file is known.

I think that whenever the recording is over, I need to destroy the recoder
using pjsua_recorder_destroy but don't know when should I call this. Should
I call this just after calling pjsua_conf_connect???? 

Thanks,
Jitendra Singh Bhadoriya
Technical Leader - One97 Communications Ltd
+91.9717123309

-----Original Message-----
From: pjsip-bounces@xxxxxxxxxxxxxxx [mailto:pjsip-bounces at lists.pjsip.org]
On Behalf Of Andreas Wehrmann
Sent: 05 September 2012 05:36 PM
To: pjsip at lists.pjsip.org
Subject: Re: Audio recording in WAV format using PJSUA

Answers and questions are embedded below:

On 09/05/2012 01:33 PM, Jitendra Singh wrote:
> Hi Friends,
>
> I am trying to record Audio in WAV file format using the following 
> code, but when I don?t know how to identify in the application that 
> recording has finished. How can we set such a call-back which is 
> called when recording is over. Also when I am recording using the 
> below code, the recorded file is not playable in media player.
>

I don't understand why there should be a callback for "recording finished"
since you're the one who decides when recording is finished.

> Code for recording file:
>
>              std::string fileName =
> generateFileName(pCallData->cli,pCallData->msisdn);
>
>              VEK_LOG_DEBUG("Trying to record file with Name = %s", 
> fileName.c_str());
>
>              const pj_str_t recordFile = pj_str 
> (const_cast<char*>(fileName.c_str()));

I'd suggest to use pj_cstr() here to avoid the const_cast, but then this is
only my opinion.

>
>              pj_status_t status = pjsua_recorder_create(&recordFile, 
> 0, NULL, 0, 0, &pCallData->recorder_p_id);
>

You don't check for errors here, did the recorder creation even succeed?
Maybe that's the problem why you can't play the file.

>              pjmedia_port *mediaPort = NULL;
>
>              status = 
> pjsua_recorder_get_port(pCallData->recorder_p_id,
> &mediaPort);
>
>              status = pjsua_conf_connect(pCallData->destConfPort,
> pjsua_recorder_get_conf_port(pCallData->recorder_p_id));
>
> My question is how to set a call-back which is called when the 
> recording is over and how to get the duration and size of file in this
code.
>

I don't know whether PJ offers any facilities to determine file size and
sound duration.
However, this can easily be done manually (you just need a little bit
knowledge about file handling and the WAV file format).


Regards,

Andreas

--
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-K?ck-Stra?e 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com

Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.wehrmann at centersystems.com

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

pjsip mailing list
pjsip at lists.pjsip.org
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