[Freeswitch-users] More codec playback issues

Brian Wood bwood-lists at jacosoft.com
Thu Nov 6 11:06:40 PST 2008


I'm doing some more testing with various codecs. I'm seeing some more 
weirdness with the selection of a codec by file extension. I'm testing 
this on FreeSWITCH trunk 10270.

The following script works with the .wav and .gsm extension, but 
everything else seems to fail.

Using lowercase names (such as .g722) fail when recording with a "[ERR] 
switch_core_file.c:66 switch_core_perform_file_open() Invalid file 
format [g722] for [/tmp/recording.g722]!". Which is fine, I can use 
uppercase, but then that plays back garbled audio.

This script should beep, record until you stop speaking, beep again, 
pause, beep, playback, beep, hang up.


   var allDigits = "";
   function on_dtmf(session, type, obj, arg)
   {
      try {
         if (type == "dtmf") {
            allDigits += obj.digit;
            console_log("info", "DTMF digit: " + session.name + " [" + 
obj.digit + "] len [" + obj.duration + "]\n\n");
         }
      } catch (e) {
         console_log("err", e + "\n");
      }
      return true;
   }


// .gsm works, .wav works
//filename = "/tmp/recording.gsm"
//filename = "/tmp/recording.wav"

// These all result in garbled playback
//filename = "/tmp/recording.GSM"
filename = "/tmp/recording.G722"
/filename = "/tmp/recording.SPEEX"
//filename = "/tmp/recording.LPC"
//filename = "/tmp/recording.PCMU"
//filename = "/tmp/recording.PCMA"
//filename = "/tmp/recording.AMR"



session.waitForAnswer(10000);
session.execute("sleep", "2000");

console_log("info", "*****BEGIN*****");
session.execute("gentones", "%(500,0,800)");
rtn = session.recordFile(filename, on_dtmf, "", 240, 500, 3);
session.execute("gentones", "%(500,0,800)");
console_log("info", "*****END*****");


session.execute("sleep", "2000");
session.execute("gentones", "%(500,0,800)");
session.streamFile(filename);
session.execute("gentones", "%(500,0,800)");

session.execute("sleep", "1000");
session.hangup();





More information about the FreeSWITCH-users mailing list