Search code examples
freeswitch

RECORD_START|STOP event in Freeswitch ESL


I have setup a NodeJS application (with node_esl) and connected it with event socket layer (ESL) of a Freeswitch server deployed on Amazon AWS. See code below:

var esl = require('modesl'),
conn = new esl.Connection('SERVER_IP', PORT, 'PASSWORD', function() {
        conn.api('status', function(res) {
            //res is an esl.Event instance
            console.log(res.getBody());
        });


    conn.subscribe([
        'RECORD_START',
        'RECORD_STOP'
    ], function(evt) {
        console.log(evt)    
    });

    conn.on('esl::event::RECORD_START::*', function(evt) {
        console.log(evt);
    });

    conn.on('esl::event::RECORD_STOP::*', function(evt) {
        console.log(evt);
    });
});

I am recording a video conference in Freeswitch using following commands and I expect the above interface to receive the RECORD_START|STOP events. However the said events are never received.

# To start recording
conference <conf_id> recording start
# To stop recording
conference <conf_id> recording stop

Below is Freeswitch profile for the conference I am recording:

<profile name="cp">
  <param name="domain" value="$${domain}"/>
  <param name="rate" value="8000"/>
  <param name="video-mode" value="transcode"/>
  <param name="interval" value="20"/>
  <param name="caller-controls" value="default"/>
  <param name="energy-level" value="0"/>
  <param name="conference-flags" value="wait-mod|audio-always|livearray-sync|livearray-json-status"/>
  <param name="max-members" value="25"/>
  <param name="sound-prefix" value="/usr/local/freeswitch/conf/sounds/"/>
  <param name="enter-sound" value="tone_stream://%(200,0,500,600,700)"/>
  <param name="exit-sound" value="tone_stream://%(500,0,300,200,100,50,25)"/>
</profile>

I receive majority of ESL events through this interface but not the RECORD_START|STOP. Any ideas?


Solution

  • I tested this out and it looks like the RECORD_START|STOP events only emit for the record application (and probably the record_session application. I did not test this), but not for conference recording.

    For troubleshooting, I ran fs_cli> /event plain all from the freeswitch command line, and these events did show up when I ran conference <conf_id> recording start and conference <conf_id> recording stop.

    Here is the start event:

    RECV EVENT
    Event-Subclass: conference::maintenance
    Event-Name: CUSTOM
    Core-UUID: fe0ebcc0-0c43-44ed-adb3-ce4e7ee8f48b
    FreeSWITCH-Hostname: freeswitch
    FreeSWITCH-Switchname: freeswitch
    FreeSWITCH-IPv4: 192.168.1.114
    FreeSWITCH-IPv6: ::1
    Event-Date-Local: 2017-09-14 17:38:22
    Event-Date-GMT: Thu, 14 Sep 2017 17:38:22 GMT
    Event-Date-Timestamp: 1505410702748201
    Event-Calling-File: conference_record.c
    Event-Calling-Function: conference_record_thread_run
    Event-Calling-Line-Number: 278
    Event-Sequence: 990
    Conference-Name: conference
    Conference-Size: 1
    Conference-Ghosts: 0
    Conference-Profile-Name: cp
    Conference-Unique-ID: a431361f-a59b-4319-bec1-fa76f8630197
    Action: start-recording
    Path:{channels=1,samplerate=8000,vw=0,vh=0,fps=0.00}/usr/local/freeswitch/log/conference_recording_1.mp3
    Error: File could not be opened for recording
    

    Here is the stop event:

    RECV EVENT
    Event-Subclass: conference::maintenance
    Event-Name: CUSTOM
    Core-UUID: fe0ebcc0-0c43-44ed-adb3-ce4e7ee8f48b
    FreeSWITCH-Hostname: freeswitch
    FreeSWITCH-Switchname: freeswitch
    FreeSWITCH-IPv4: 192.168.1.114
    FreeSWITCH-IPv6: ::1
    Event-Date-Local: 2017-09-14 17:38:22
    Event-Date-GMT: Thu, 14 Sep 2017 17:38:22 GMT
    Event-Date-Timestamp: 1505410702748201
    Event-Calling-File: conference_record.c
    Event-Calling-Function: conference_record_thread_run
    Event-Calling-Line-Number: 418
    Event-Sequence: 991
    Conference-Name: conference
    Conference-Size: 1
    Conference-Ghosts: 0
    Conference-Profile-Name: cp
    Conference-Unique-ID: a431361f-a59b-4319-bec1-fa76f8630197
    Action: stop-recording
    Path: {channels=1,samplerate=8000,vw=0,vh=0,fps=0.00}/usr/local/freeswitch/log/conference_recording_1.mp3
    Other-Recordings: true
    Samples-Out: 0
    Samplerate: 8000
    Milliseconds-Elapsed: 0
    

    For your node app, you could try something like this to get what you need:

    var esl = require('modesl'),
    
    conn = new esl.Connection('127.0.0.1', 8021, 'ClueCon', function() {
      conn.api('status', function(res) {
        //res is an esl.Event instance
        console.log(res.getBody());
      });
    
      conn.subscribe('CUSTOM conference::maintenance', function() {
        conn.on('esl::event::CUSTOM::**', function(evt) {
           console.log(evt);
           // now do something
        });
      });
    });