Testing audio conferencing with Pandora online radio
We recently launched a new functionality on our VoxImplant platform, which allows you to make HD audio conferences , as well as play mp3 and ogg files into calls from the SDK or SIP to wideband (everything was previously 8KHz, now all 48KHz is possible). Conceptually, it was necessary to play audio through the platform into the conference and listen to how it all works depending on the number of participants. We wanted to come up with an interesting way to test all this farming and, after a bit of thought, we found a rather unusual way to use online radio. I hope that you are a little intrigued, so welcome under the cat.
Pandora and API
For those who do not know, Pandora.com is an American online radio available for listening only in the USA. Of course, being in the US is checked by IP, so it’s not too difficult to register using some TunnelBear. In the service, you choose your station by taste by artist name, and then it creates a playlist based on its smart algorithms. In general, the concept is the following - we connect to the radio, it gives us a mp3, we lose them in the VoxImplant conference, and all the conference participants listen to music. Fortunately, the Pandora API was also found, albeit unofficial, but quite working https://6xq.net/pandora-apidoc/json/
Integration with VoxImplant
You can connect to the API directly from the VoxImplant script, let me remind you that they are written in JavaScript and executed by our engine, from there you can easily make http requests to external web services. Our servers are all over the world, so for testing we used those that are in the US, so that Pandora does not swear. This resulted in some such script https://gist.github.com/aylarov/ee7f509ca182e8437b2abed9d415f2f1 , you can see the use of Promise and blowfish.encrypt in it, this functionality is connected using additional JS-files - es6-promise and blowfish.js in the Rule of the application before the main script. The main script plays mp3 files, the URL of which gives the Pandora API, to the conference. At the platform level, mp3 turns into a real-time stream in the Opus codec (48KHz), while the truth is mono, since there are a number of nuances associated with echo cancellation with stereo in WebRTC, and in the case of audio conference, stereo does not work very well. ')
Client for testing
Using the Web SDK, VoxImplant has assigned an application that connects and makes a call to the conference, and even has the ability to switch tracks and radio stations. Well, then we sit and listen to music :)