|
93 | 93 | </parameter>
|
94 | 94 | <parameter name="options" required="false">
|
95 | 95 | <optionlist>
|
96 |
| - <option name="A"> |
97 |
| - <argument name="x" required="true"> |
| 96 | + <option name="A" argsep=":"> |
| 97 | + <argument name="x"> |
98 | 98 | <para>The file to play to the called party</para>
|
99 | 99 | </argument>
|
100 |
| - <para>Play an announcement to the called party, where <replaceable>x</replaceable> is the prompt to be played</para> |
| 100 | + <argument name="y"> |
| 101 | + <para>The file to play to the calling party</para> |
| 102 | + </argument> |
| 103 | + <para>Play an announcement to the called and/or calling parties, where <replaceable>x</replaceable> |
| 104 | + is the prompt to be played to the called party and <replaceable>y</replaceable> is the prompt |
| 105 | + to be played to the caller. The files may be different and will be played to each party |
| 106 | + simultaneously.</para> |
101 | 107 | </option>
|
102 | 108 | <option name="a">
|
103 | 109 | <para>Immediately answer the calling channel when the called channel answers in
|
@@ -2941,33 +2947,71 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
|
2941 | 2947 | int digit = 0;
|
2942 | 2948 | struct ast_channel *chans[2];
|
2943 | 2949 | struct ast_channel *active_chan;
|
| 2950 | + char *calledfile = NULL, *callerfile = NULL; |
| 2951 | + int calledstream = 0, callerstream = 0; |
2944 | 2952 |
|
2945 | 2953 | chans[0] = chan;
|
2946 | 2954 | chans[1] = peer;
|
2947 | 2955 |
|
2948 |
| - /* we need to stream the announcement to the called party when the OPT_ARG_ANNOUNCE (-A) is setted */ |
| 2956 | + /* we need to stream the announcement(s) when the OPT_ARG_ANNOUNCE (-A) is set */ |
| 2957 | + callerfile = opt_args[OPT_ARG_ANNOUNCE]; |
| 2958 | + calledfile = strsep(&callerfile, ":"); |
2949 | 2959 |
|
2950 |
| - /* stream the file */ |
2951 |
| - res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], ast_channel_language(peer)); |
2952 |
| - if (res) { |
2953 |
| - res = 0; |
2954 |
| - ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", opt_args[OPT_ARG_ANNOUNCE]); |
| 2960 | + /* stream the file(s) */ |
| 2961 | + if (!ast_strlen_zero(calledfile)) { |
| 2962 | + res = ast_streamfile(peer, calledfile, ast_channel_language(peer)); |
| 2963 | + if (res) { |
| 2964 | + res = 0; |
| 2965 | + ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", calledfile); |
| 2966 | + } else { |
| 2967 | + calledstream = 1; |
| 2968 | + } |
| 2969 | + } |
| 2970 | + if (!ast_strlen_zero(callerfile)) { |
| 2971 | + res = ast_streamfile(chan, callerfile, ast_channel_language(chan)); |
| 2972 | + if (res) { |
| 2973 | + res = 0; |
| 2974 | + ast_log(LOG_ERROR, "error streaming file '%s' to caller\n", callerfile); |
| 2975 | + } else { |
| 2976 | + callerstream = 1; |
| 2977 | + } |
2955 | 2978 | }
|
2956 | 2979 |
|
| 2980 | + /* can't use ast_waitstream, because we're streaming two files at once, and can't block |
| 2981 | + We'll need to handle both channels at once. */ |
| 2982 | + |
2957 | 2983 | ast_channel_set_flag(peer, AST_FLAG_END_DTMF_ONLY);
|
2958 |
| - while (ast_channel_stream(peer)) { |
2959 |
| - int ms; |
| 2984 | + while (ast_channel_stream(peer) || ast_channel_stream(chan)) { |
| 2985 | + int mspeer, mschan; |
| 2986 | + |
| 2987 | + mspeer = ast_sched_wait(ast_channel_sched(peer)); |
| 2988 | + mschan = ast_sched_wait(ast_channel_sched(chan)); |
2960 | 2989 |
|
2961 |
| - ms = ast_sched_wait(ast_channel_sched(peer)); |
| 2990 | + if (calledstream) { |
| 2991 | + if (mspeer < 0 && !ast_channel_timingfunc(peer)) { |
| 2992 | + ast_stopstream(peer); |
| 2993 | + calledstream = 0; |
| 2994 | + } |
| 2995 | + } |
| 2996 | + if (callerstream) { |
| 2997 | + if (mschan < 0 && !ast_channel_timingfunc(chan)) { |
| 2998 | + ast_stopstream(chan); |
| 2999 | + callerstream = 0; |
| 3000 | + } |
| 3001 | + } |
2962 | 3002 |
|
2963 |
| - if (ms < 0 && !ast_channel_timingfunc(peer)) { |
2964 |
| - ast_stopstream(peer); |
| 3003 | + if (!calledstream && !callerstream) { |
2965 | 3004 | break;
|
2966 | 3005 | }
|
2967 |
| - if (ms < 0) |
2968 |
| - ms = 1000; |
2969 | 3006 |
|
2970 |
| - active_chan = ast_waitfor_n(chans, 2, &ms); |
| 3007 | + if (mspeer < 0) |
| 3008 | + mspeer = 1000; |
| 3009 | + |
| 3010 | + if (mschan < 0) |
| 3011 | + mschan = 1000; |
| 3012 | + |
| 3013 | + /* wait for the lowest maximum of the two */ |
| 3014 | + active_chan = ast_waitfor_n(chans, 2, (mspeer > mschan ? &mschan : &mspeer)); |
2971 | 3015 | if (active_chan) {
|
2972 | 3016 | struct ast_channel *other_chan;
|
2973 | 3017 | struct ast_frame *fr = ast_read(active_chan);
|
@@ -3017,6 +3061,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
|
3017 | 3061 | ast_frfree(fr);
|
3018 | 3062 | }
|
3019 | 3063 | ast_sched_runq(ast_channel_sched(peer));
|
| 3064 | + ast_sched_runq(ast_channel_sched(chan)); |
3020 | 3065 | }
|
3021 | 3066 | ast_channel_clear_flag(peer, AST_FLAG_END_DTMF_ONLY);
|
3022 | 3067 | }
|
|
0 commit comments