MOS or Mean Opinion Score is the measure by which a VOIP call is categorized as good, bad, or all Greek to me, local pun intended. There are many good companies offering devices to measure this score and once upon a time they used to publish their algorithms too. I was budget strapped as always in this wonderful historic gutter I currently inhabit, so I went prowling the wires for an API or two.
I came across probably the most promising VOIP API ever , project pjsip. PJsip is extremely well documented and provides samples of working code too, and compatible with asterisk to boot. So I spent a fortnight toying with the sample apps and test coding and this and that and following diff booted itself to life.
So now one can make a test call against an Asterisk server, have the server playback some or any recorded message and at the end of this conversation you get various metrics and the MOS score. The exact mechanics of this approach I leave to the interested students. A nice way to see if the application calculates meaningful scores is to freeze it ( on unix via ctrl-Z). This will effectively create an artificial UDP packet loss in the conversation between the two end points. Restart the application again and watch what happens to the MOS score !
To give credit where credit is due, the following code is an adaptation of Telchemy’s algorithm which they used to have publicly available on their site.