如何在freeswitch中以异步模式录制

时间:2013-11-18 12:17:56

标签: freeswitch

我正在尝试从Java esl以异步模式执行record命令,原因是我必须在处理请求时播放音乐,并向用户播放wave文件,停止moh,我已尝试同步模式,但它没有工作,我已经尝试在异步模式下使用事件锁进行播放和记录,播放和moh工作正常但问题是在录制时,记录命令被调用但未被执行,相同的记录命令正确执行在同步模式下,请帮助我猜我错过了什么。

这是记录命令

    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));
    }
}

这是音乐暂停

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 ) );
    }
}

请帮我在同步模式下保持音乐或以异步模式录制

0 个答案:

没有答案