Early Media not coming via Plivo <Dial>

385 views
Skip to first unread message

Tony Miller

unread,
May 1, 2013, 11:00:17 PM5/1/13
to plivo...@googlegroups.com
Michael, Venky: First off, I would like to thank you guys for creating and open-sourcing such a great FreeSWITCH API. Cheers!

I have been playing on and off with Plivo for a few months now. Initially, it was just to try a cool new alternative to Asterisk. Then I set it up for my home telephony needs. I am currently using Plivo in a personal project and would love to recommend it to my bosses at work once I gain a little more understanding about how it works.

Although I am not a Python developer, I have worked hard to troubleshoot an early media issue. Here's a brief overview of how my web app uses Plivo:
  • User X comes to my web app, provides their mobile number and hits call.
  • I get a call on my softphone (a freeswitch extension). If I answer, the app proceeds to call the number given by X via a gsmopen channel and bridges the call. Code snippet:
<Dial callerId="9000" callerName="Tony" hangupOnStar="true" dialMusic="none" callbackUrl="<?php echo $dial_callback_url; ?>">
<Number gateways="gsmopen/gsm01/"><?php echo "+1".$number_to_call; ?></Number>
</Dial>
  • If X answers, we can talk without any issues.
  • The problem is that I am not able to get "early media" to work, i.e. I can not hear the ringtone, busy tone, or any other network message while the call is being tried. I know the default dialMusic plays a ring tone but I don't want that in case the number is wrong, busy, or has other network issues. I want to hear the actual network early media.
This happens only when placing a call via the Plivo API. When I dial an external number via my softphone connected directly to freeswitch, I can hear the "early media" just fine. I can see that Plivo Cloud does have a dialMusic="real" attribute to probably address this particular issue. Unfortunately, that change hasn't been made available in the open source version. So after some debugging, I discovered that ignore_early_media was explicitly being set to true in /src/plivo/src/plivo/rest/freeswitch/inboundsocket.py and /src/plivo/src/plivo/core/freeswitch/commands.py. Also, bridge_early_media was being explicitly set to false in /src/plivo/src/plivo/rest/freeswitch/elements.py. Realizing changing these things could do the job, I made the changes in the Python files and made sure it was recompiled after a restart of Plivo. I also looked at the Plivo and Freeswitch logs to make sure the early media attributes were set correctly.

Unfortunately, the above changes did not do the job. I am at my wit's end. Please help and point me in the right direction. Thanks!

Tony
Message has been deleted

Tony Miller

unread,
May 3, 2013, 7:20:21 AM5/3/13
to plivo...@googlegroups.com
No suggestions, huh?

Fellow Plivo users, please spare a couple of minutes and help me if you have any idea about how to resolve this issue. I am in a bind.

Tony

David | StyleFlare

unread,
May 3, 2013, 7:21:31 AM5/3/13
to plivo...@googlegroups.com
Tony,

while I am sure this is not a very helpful response at the moment, but keep hacking you will figure it out. I think your on the right track, but I have not looked deeply into your specific issue.

You are probably not aware but this forum is not that big or active, so expecting a swift response might be a little bit of a high expectation.

Please dont take this response out of context, I just wanted to reply so that you know people do see your question.

Thanks.

David.
Tony
--
You received this message because you are subscribed to the Google Groups "Plivo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plivo-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tony Miller

unread,
May 3, 2013, 10:26:14 AM5/3/13
to plivo...@googlegroups.com
David, thanks for trying to help :)

Plivo team (Venky/Michael), would it be too much to ask to just point me in the right direction? I know you must be busy with Plivo Cloud, but please help somebody who is stuck on an issue with a framework that you created. Thanks!

Tony

Mike

unread,
May 3, 2013, 11:22:10 AM5/3/13
to plivo...@googlegroups.com
Hi Tony,

from FS dialplan can you try a bridge with :

<action application="set" data="instant_ringback=false"/>
<action application="set" data="bridge_early_media=true"/>
<action application="set" data="ignore_early_media=false"/>
<action application="bridge"
data="{instant_ringback=false,bridge_early_media=true,ignore_early_media=false}gsmopen/gsm01/XXXXX"/>

where XXXX is the number to call .
> --
> You received this message because you are subscribed to the Google Groups
> "Plivo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to plivo-users...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
--

Michael Ricordeau
Co-Founder Plivo

mi...@plivo.com
http://www.plivo.com
twitter @mricordeau
linkedin http://fr.linkedin.com/in/michaelricordeau

Tony Miller

unread,
May 3, 2013, 4:11:42 PM5/3/13
to plivo...@googlegroups.com
Hi Mike, thank you so much for responding.

As I have already said, I can hear the early media just fine via my Freeswitch dialplan, i.e. when I dial directly from a softphone connected to my FS. The early media does not get transmitted only when placing a call via Plivo. And since I am using Plivo to place a call from my web app, this is an issue. Here is my FS dialplan: http://pastebin.com/5triZNmU

It seems like you guys fixed this issue in Plivo Cloud. I can see a custom dialMusic="real" attribute in Plivo Cloud's <Dial>. The Plivo framework, however, does not have this attribute value. If you could please find out what other code changes were made in relation to this custom attribute value, I think I will be all set :)

By the way, in the freeswitch log file, I see a warning when placing a call via Plivo but am not sure if it's relevant or meaningful as the call gets connected regardless:

2013-05-03 15:13:53.455137 [DEBUG] switch_ivr_originate.c:2022 Parsing global variables
2013-05-03 15:13:53.455137 [WARNING] switch_ivr_originate.c:2041 No origination URL specified!
2013-05-03 15:13:53.455137 [DEBUG] switch_ivr_originate.c:3533 Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]

Thanks!

Tony

Mike

unread,
May 3, 2013, 4:18:25 PM5/3/13
to plivo...@googlegroups.com
Don't worry about the Originate Warning log : enterprise originate in
Freeswitch is just crying a bit when we set only one destination .

If I understand the ringtone is not passed back to the caller when you
are using Plivo but when you are using :
<action application="bridge" data="gsmopen/gsm01/+1$1"/>

it is working ?

In this case, can you try the dialplan I have mentioned in my previous email :
<action application="set" data="instant_ringback=false"/>
<action application="set" data="bridge_early_media=true"/>
<action application="set" data="ignore_early_media=false"/>
<action application="bridge"
data="{instant_ringback=false,bridge_early_media=true,ignore_early_media=false}gsmopen/gsm01/+1$1"/>

So if it's working from the dialplan, I will add the changes to Plivo
too (dialMusic="real") .

Tony Miller

unread,
May 3, 2013, 5:06:32 PM5/3/13
to plivo...@googlegroups.com
If I understand the ringtone is not passed back to the caller when you
are using Plivo but when you are using :
 <action application="bridge" data="gsmopen/gsm01/+1$1"/>

it is working ?


Yes, exactly.



In this case, can you try the dialplan I have mentioned in my previous email

Tried your dialplan settings and, yes, I could hear the early media from a softphone dial like before. Here is the updated dialplan: http://pastebin.com/PUM5hXQH

The extra attributes did not make any difference. I suppose you already know that freeswitch defaults "ignore_early_media" to "false" and, as per the FS Wiki, "bridge_early_media" only sets the buffering for better audio quality, so I am not sure why you thought setting these variables would make any difference (?).

I really appreciate your prompt responses and assistance :)

Tony

Mike

unread,
May 3, 2013, 5:41:24 PM5/3/13
to plivo...@googlegroups.com
These variables are set to prevent a previous Dial/bridge with same
variables set with other values (like for example dialMusic playing a
custom ringtone in a previous Dial) .
I will update dialMusic attribute .

Mike

unread,
May 3, 2013, 5:50:32 PM5/3/13
to plivo...@googlegroups.com

Tony Miller

unread,
May 3, 2013, 7:59:40 PM5/3/13
to plivo...@googlegroups.com
Mike, I did a code pull and made sure the Python files were "recompiled" on a Plivo restart. Unfortunately, the problem remains :(

As I tried to explain in my first post, I'd already discovered that "ignore_early_media" was hardcoded to "true" (regardless of what "dialMusic" value was being sent) in src/plivo/rest/freeswitch/inboundsocket.py (lines 649 and 702) and in /src/plivo/core/freeswitch/commands.py (line 185) so I changed the values to "false". After your inputs, I even added the other variables you suggested but I still don't hear early media via Plivo.

My present inboundsocket.py (see lines 649-651 and 704-706): http://pastebin.com/sQXx7UaC
My present commands.py (see line 185): http://pastebin.com/7AmBFAXz

Can you please find out what other code changes were made in conjunction with the addition of dialMusic="real" in elements.py to get "early media" to work in Plivo Cloud (I am presuming it works there)?

My webapp is really simple and I have attached the Plivo part in case you want to take a look. If you want to test this out yourself, please extract the files to your webserver, change index.php (highlighted with "// Mike") and bridge_outgoing.php where needed.

WebApp (POSTs number_to_call) tony-plivo/index.php (calls extension user/1000 and on answer) tony-plivo/bridge_outgoing.php (<Speak> message and <Dial> number_to_call)

Thanks!
Tony


You received this message because you are subscribed to a topic in the Google Groups "Plivo Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/plivo-users/20-MdPKikOI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to plivo-users...@googlegroups.com.
AFA.gif
tony-plivo.tar.gz

Stefan Gersmann

unread,
Jul 1, 2013, 3:19:27 PM7/1/13
to plivo...@googlegroups.com
Same problem here :( Did you ever find a solution?

Stefan Gersmann

unread,
Jul 1, 2013, 3:28:52 PM7/1/13
to plivo...@googlegroups.com
Hi Tony,

I just found a workaround for my setup. If I add a 'wait' of 1 sec to the dial plan I can hear the dial music. Maybe its a timing issue?

My plan: 
r = Plivo::Response.new
   r.addWait length: 1
    g = Plivo::Dial.new(timeout: '30',
                        dialMusic: 'http://' + AppConfig.general.base_url + '/callback/call/sound?type=connecting',
                        confirmKey: '*',
                        confirmSound: 'http://' + AppConfig.general.base_url + '/callback/call/sound?type=dial_star_accept',
                        callbackUrl: 'http://' + AppConfig.general.base_url + '/callback/call/on_bridge'
                        )

Cheers,
Stefan

Silviu Caragea

unread,
Nov 11, 2015, 9:26:48 AM11/11/15
to Plivo Users
Hello,

Here the problem is that it's used the enterprise originate. This one it's used to call multiple destination and it doesn't support early media bridging. Using this you can only play a custom ringtone from FS.
If you switch to the originate it's working pretty well.

Just comment the following lines and you will see that calling only one destination and using "real" for dialMusic will bridge the early media:

# Ugly hack to force use of enterprise originate because simple originate lacks speak support in ringback
if len(numbers) < 2:
self.dial_str += ':_:'

Of course you need to do a better patch and when calling only one destination and real is used as dialMusic to use the normal originate. if no to work like now.

Silviu
Reply all
Reply to author
Forward
0 new messages