wav file end does not stop playback from port (w/ patch)

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

 



Hello,

I've been working on a little script. I'm trying to get pjsip to make a
call to a VOIP system (Cisco UC500) and play a short wav file (an
announcement). Since I'm a big python fan I'm trying to get this work
using the python pjsua.py module. I've run across a couple of problems.
Ultimately, I want to get a callback when the wav finishes playing so I
can end the call. In order to do this, I need to know when the wav file
playback is done. I could of course hack this by figuring out how many
seconds it is in advance, and then just ending the call based on a
timer. But since pjlib already has a hook to get a callback, why not use
it! Of course the first hurdle is that pjsua doesn't directly export
this functionality. I've got a small hack working that let's me stash a
void* associated with the playback id to help me do this (I need this
not for the C-level code, but for the python callback object). However,
things are still not quite right. I get the callback, but then I keep
getting the callback repeatedly! The documentation says that if the
callback returns something other than PJ_SUCCESS or if
PJMEDIA_FILE_NO_LOOP is not set then playback will finish. Well, I've
been doing both of those things and what I see happening is I keep
getting the callback and on the handset where I'm receiving the call I
here weird noises (probably just a repeating clip from the last chunk of
audio data read?). I've arranged for the build to include debug symbols
an run it in the debugger. And what do I find:

        if (status != PJ_SUCCESS) {
        /* bennylp: why do we need this????
         * Also see comments on similar issue with write_port().
        PJ_LOG(4,(THIS_FILE, "Port %.*s get_frame() returned %d. "
                     "Port is now disabled",
                     (int)conf_port->name.slen,
                     conf_port->name.ptr,
                     status));
        conf_port->rx_setting = PJMEDIA_PORT_DISABLE;
         */
        continue;
        }

Well, whoever commented this code out, I think you have your answer. :-)

I still get some funny sound at the end, but at least my callback when
the file end is reached is called once and only once. I work on
debugging that problem next.

May I propose the attached change?

-- 
Jens B. Jorgensen
jbj1 at ultraemail.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090917/93ecc6d4/attachment-0001.diff>


[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