How to record in async mode in freeswitch

喜夏-厌秋 提交于 2019-12-11 09:11:05

问题


I am trying to execute record command in async mode from Java esl, the reason is I have to play music on hold when ever request is processing, and play the wave file to theuser, stopping the moh, I have tried in sync mode but it did not work, I have tried the same in async mode using event lock for play and record, play and moh works fine but the problem is while recording,record command is called but not being executed, the same record command executed properly in sync mode, Please help I guess I am missing out something.

This is record command

    private void record(Channel channel, String path, int maxsilence, int i) {
    SendMsg recordMsg = new SendMsg();
    recordMsg.addCallCommand("execute");
    recordMsg.addExecuteAppName("record");
    StringBuffer sb = new StringBuffer();
    sb.append(path + i+ ".wav").append(" ").append(filelength).append(" ")
    .append(silenceThreshold).append(" ");
    if (maxsilence == 0) {
        sb.append(10000);
    }
    recordMsg.addExecuteAppArg(sb.toString());
    System.out.println(System.currentTimeMillis());
    recordMsg.addEventLock();
    EslMessage response = sendSyncMultiLineCommand(channel,
            recordMsg.getMsgLines());
    System.out.println(System.currentTimeMillis());
    if (response.getHeaderValue(Name.REPLY_TEXT).startsWith("+OK")) {
        System.out.println(this.getClass().getName()
                + " >> recordMsg successful");
        log.info(this.getClass().getName() + " >> recordMsg successful");
    } else {
        log.error(this.getClass().getName() + " >> recordMsg failed: [{}}"
                + response.getHeaderValue(Name.REPLY_TEXT));
        System.out.println(this.getClass().getName()
                + " >> recordMsg failed: [{}}"
                + response.getHeaderValue(Name.REPLY_TEXT));
    }
}

This is music on hold

public void playMusicOnHold() {
    SendMsg holdMusic = new SendMsg();
    holdMusic.addCallCommand( "execute" );
    holdMusic.addExecuteAppName( "playback" );
    holdMusic.addExecuteAppArg("$${hold_music}");
    EslMessage response = sendSyncMultiLineCommand(ctx.getChannel(), holdMusic.getMsgLines() );
    if ( response.getHeaderValue( Name.REPLY_TEXT ).startsWith( "+OK" ) ) {
        System.out.println(this.getClass().getName()+" >> playMsg successful");
    } else {
        log.error( this.getClass().getName() + " >> playMsg failed :" + response.getHeaderValue( Name.REPLY_TEXT ) );
        System.out.println( this.getClass().getName() + " >> playMsg failed :" + response.getHeaderValue( Name.REPLY_TEXT ) );
    }
}

Please help me either to execute music on hold in sync mode or recording in async mode

来源:https://stackoverflow.com/questions/20047623/how-to-record-in-async-mode-in-freeswitch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!