Skip to content

Commit fc1ff02

Browse files
committed
app_frame: Allow sending non-control frames.
WaitForFrame could receive control and non-control frames but SendFrame originally could only send control frames. It now also supports sending non-control frames (useful for testing purposes).
1 parent ef8b531 commit fc1ff02

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

apps/app_frame.c

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,26 @@
129129
</application>
130130
<application name="SendFrame" language="en_US">
131131
<synopsis>
132-
Sends an arbitrary control frame on a channel.
132+
Sends an arbitrary frame on a channel.
133133
</synopsis>
134134
<syntax>
135135
<parameter name="frame" required="true">
136-
<para>The type of frame for which to wait.</para>
136+
<para>The type of frame to send.</para>
137+
<para>The following frame types may be sent:</para>
138+
<enumlist>
139+
<enum name = "DTMF_BEGIN" />
140+
<enum name = "DTMF_END" />
141+
<enum name = "VOICE" />
142+
<enum name = "VIDEO" />
143+
<enum name = "NULL" />
144+
<enum name = "IAX" />
145+
<enum name = "TEXT" />
146+
<enum name = "TEXT_DATA" />
147+
<enum name = "IMAGE" />
148+
<enum name = "HTML" />
149+
<enum name = "CNG" />
150+
<enum name = "MODEM" />
151+
</enumlist>
137152
<para>The following CONTROL frames may be sent:</para>
138153
<enumlist>
139154
<enum name = "TAKEOFFHOOK" />
@@ -146,7 +161,7 @@
146161
</parameter>
147162
</syntax>
148163
<description>
149-
<para>Sends an arbitrary control frame on a channel.</para>
164+
<para>Sends an arbitrary frame on a channel.</para>
150165
<example title="Send Wink">
151166
same => n,SendFrame(WINK)
152167
</example>
@@ -216,9 +231,25 @@ static int sendframe_exec(struct ast_channel *chan, const char *data)
216231
argcopy = ast_strdupa(data);
217232
AST_STANDARD_APP_ARGS(args, argcopy);
218233
if (ast_strlen_zero(args.frametype)) {
219-
ast_log(LOG_WARNING, "Invalid! Usage: SendFrame(frametype[,timeout])\n");
234+
ast_log(LOG_WARNING, "Invalid! Usage: SendFrame(frametype)\n");
220235
return -1;
221236
}
237+
for (i = 0; i < ARRAY_LEN(frametype2str); i++) {
238+
if (strcasestr(args.frametype, frametype2str[i].str)) {
239+
/* Send a non-control frame */
240+
int res;
241+
struct ast_frame f = { frametype2str[i].type, };
242+
f.subclass.integer = '0';
243+
ast_channel_lock(chan);
244+
res = ast_write(chan, &f);
245+
ast_channel_unlock(chan);
246+
if (res) {
247+
ast_log(LOG_WARNING, "Failed to write %s frame on %s\n", frametype2str[i].str, ast_channel_name(chan));
248+
}
249+
return 0;
250+
}
251+
}
252+
/* Send a control frame */
222253
for (i = 0; i < ARRAY_LEN(controlframetype2str); i++) {
223254
if (strcasestr(args.frametype, controlframetype2str[i].str)) {
224255
subtype = controlframetype2str[i].type;

0 commit comments

Comments
 (0)