using System; namespace AsterNET.FastAGI.Command { /// /// Record to a file until a given dtmf digit in the sequence is received.
/// Returns -1 on hangup or error.
/// The format will specify what kind of file will be recorded. The timeout is /// the maximum record time in milliseconds, or -1 for no timeout. Offset samples /// is optional, and if provided will seek to the offset without exceeding the /// end of the file. "maxSilence" is the number of seconds of maxSilence allowed /// before the function returns despite the lack of dtmf digits or reaching /// timeout. ///
public class RecordFileCommand : AGICommand { #region Variables /// The name of the file to record. private string file; /// The format of the file to be recorded, for example "wav". private string format; /// The these digits a user can press to end the recording. private string escapeDigits; /// The maximum record time in milliseconds, or -1 for no timeout. private int timeout; /// The offset samples to skip. private int offset; /// Wheather a beep should be played before recording. private bool beep; /// The amount of silence (in seconds) to allow before returning despite the lack of dtmf digits or reaching timeout. private int maxSilence; #endregion #region File /// /// Get/Set the name of the file to stream. /// public string File { get { return file; } set { this.file = value; } } #endregion #region Format /// /// Get/Set the format of the file to be recorded, for example "wav". /// public string Format { get { return format; } set { this.format = value; } } #endregion #region EscapeDigits /// /// Get/Set the digits that allow the user to end recording. /// public string EscapeDigits { get { return escapeDigits; } set { this.escapeDigits = value; } } #endregion #region Timeout /// /// Get/Set the maximum record time in milliseconds, or -1 for no timeout. /// public int Timeout { get { return timeout; } set { this.timeout = value; } } #endregion #region Offset /// /// Get/Set the offset samples to skip. /// public int Offset { get { return offset; } set { this.offset = value; } } #endregion #region Beep /// /// Get/Set true if a beep should be played before recording. false if not. /// public bool Beep { get { return beep; } set { this.beep = value; } } #endregion #region Constructor - RecordFileCommand(string file, string format, string escapeDigits, int timeout) /// /// Creates a new RecordFileCommand. /// /// the name of the file to stream, must not include extension. /// the format of the file to be recorded, for example "wav". /// contains the digits that allow the user to end recording. /// the maximum record time in milliseconds, or -1 for no timeout. public RecordFileCommand(string file, string format, string escapeDigits, int timeout) { this.file = file; this.format = format; this.escapeDigits = escapeDigits; this.timeout = timeout; this.offset = 0; this.beep = false; this.maxSilence = 0; } #endregion #region Constructor - RecordFileCommand(string file, string format, string escapeDigits, int timeout) /// /// Creates a new RecordFileCommand. /// /// the name of the file to stream, must not include extension. /// the format of the file to be recorded, for example "wav". /// contains the digits that allow the user to end recording. /// the maximum record time in milliseconds, or -1 for no timeout. /// the offset samples to skip. /// true if a beep should be played before recording. /// The amount of silence (in seconds) to allow before returning despite the lack of dtmf digits or reaching timeout. public RecordFileCommand(string file, string format, string escapeDigits, int timeout, int offset, bool beep, int maxSilence) { this.file = file; this.format = format; this.escapeDigits = escapeDigits; this.timeout = timeout; this.offset = offset; this.beep = beep; this.maxSilence = maxSilence; } #endregion #region BuildCommand() public override string BuildCommand() { return "RECORD FILE " + EscapeAndQuote(file) + " " + EscapeAndQuote(format) + " " + EscapeAndQuote(escapeDigits) + " " + timeout + " " + offset + (beep == true?" BEEP":"") + " s=" + maxSilence; } #endregion } }