Beispiel #1
0
 /// <summary>
 /// Constructs an action that plays the sound file the specified call legs
 /// with the specified delay to a specific call.
 /// </summary>
 /// <param name="callID">The target call ID.</param>
 /// <param name="legs">Specifies the call legs to hear the sound.</param>
 /// <param name="filePath">Path to the sound file.</param>
 /// <param name="delay">The time to wait before playing the file.</param>
 public BroadcastAction(Guid callID, CallLeg legs, string filePath, TimeSpan delay)
 {
     this.CallID   = callID;
     this.legs     = legs;
     this.filePath = Switch.ExpandFilePath(filePath);
     this.delay    = delay;
 }
Beispiel #2
0
 /// <summary>
 /// Constructs a action that plays the sound file immediately to
 /// the specified legs of the given call.
 /// </summary>
 /// <param name="callID">The target call ID.</param>
 /// <param name="legs">Specifies the call legs to hear the sound.</param>
 /// <param name="filePath">Path to the sound file.</param>
 public BroadcastAction(Guid callID, CallLeg legs, string filePath)
     : this(legs, filePath)
 {
     this.CallID   = callID;
     this.legs     = legs;
     this.filePath = Switch.ExpandFilePath(filePath);
 }
Beispiel #3
0
        //---------------------------------------------------------------------
        // Static members

        /// <summary>
        /// Returns an audio source that plays a local file.
        /// </summary>
        /// <param name="path">Path to the file.</param>
        /// <returns>The audio source reference.</returns>
        /// <exception cref="ArgumentException">Thrown if the expanded file path includes a single quote.</exception>
        /// <remarks>
        /// <note>
        /// The file path may include global variables.  These will be expanded before the method
        /// returns.  The path may also include references to call variables.  These will be expanded
        /// when the audio is played.
        /// </note>
        /// </remarks>
        public static AudioSource File(string path)
        {
            path = Switch.ExpandFilePath(path);

            if (path.Contains('\''))
            {
                throw new ArgumentException(string.Format("[AudioSource] cannot generate a reference to file [{0}] because it contains a single quote.", path), "path");
            }

            return(new AudioSource(string.Format("{0}", path)));
        }
Beispiel #4
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <exception cref="NotSupportedException">Thrown if the action is being rendered outside of a dialplan.</exception>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            var expandedPath = Switch.ExpandFilePath(path);
            var limitString  = string.Empty;

            if (start && limit.HasValue)
            {
                limitString = " " + SwitchHelper.GetScheduleSeconds(limit.Value).ToString();
            }

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("uuid_record", "${{Unique-ID}} {0} '{1}'{2}", start ? "start" : "stop", limitString));
            }
            else
            {
                CheckCallID();
                context.Actions.Add(new SwitchExecuteAction("uuid_record", "{0} {1} '{2}'{3}", start ? "start" : "stop", limitString));
            }
        }
Beispiel #5
0
 /// <summary>
 /// Constructs a dialplan action that plays the sound file immediately to
 /// the specified call legs.
 /// </summary>
 /// <param name="legs">Specifies the call legs to hear the sound.</param>
 /// <param name="filePath">Path to the sound file.</param>
 public BroadcastAction(CallLeg legs, string filePath)
     : base("sched_broadcast")
 {
     this.legs     = legs;
     this.filePath = Switch.ExpandFilePath(filePath);
 }
Beispiel #6
0
        /// <summary>
        /// Renders the high-level switch action instance into zero or more <see cref="SwitchExecuteAction" />
        /// instances and then adds these to the <see cref="ActionRenderingContext" />.<see cref="ActionRenderingContext.Actions" />
        /// collection.
        /// </summary>
        /// <param name="context">The action rendering context.</param>
        /// <remarks>
        /// <note>
        /// It is perfectly reasonable for an action to render no actions to the
        /// context or to render multiple actions based on its properties.
        /// </note>
        /// </remarks>
        public override void Render(ActionRenderingContext context)
        {
            int    delaySeconds = SwitchHelper.GetScheduleSeconds(delay);
            string legString;

            switch (legs)
            {
            case CallLeg.A:

                legString = "aleg";
                break;

            case CallLeg.B:

                legString = "bleg";
                break;

            default:
            case CallLeg.Both:

                legString = "both";
                break;
            }

            if (context.IsDialplan)
            {
                context.Actions.Add(new SwitchExecuteAction("sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString));
            }
            else
            {
                context.Actions.Add(new SwitchExecuteAction(CallID, "sched_broadcast", "+{0} '{1}' {2}", delaySeconds, Switch.ExpandFilePath(filePath), legString));
            }
        }