[asterisk-commits] mjordan: branch mjordan/longcat r378188 - in /team/mjordan/longcat: ./ funcs/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 21 09:01:52 CST 2012
Author: mjordan
Date: Fri Dec 21 09:01:45 2012
New Revision: 378188
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378188
Log:
Creating... something.
I'm not entirely sure what this is yet. It might be useful.
Added:
team/mjordan/longcat/
- copied from r378118, trunk/
Modified:
team/mjordan/longcat/funcs/func_frame_trace.c
team/mjordan/longcat/include/asterisk/frame.h
team/mjordan/longcat/main/app.c
team/mjordan/longcat/main/channel.c
team/mjordan/longcat/main/file.c
team/mjordan/longcat/res/res_agi.c
Modified: team/mjordan/longcat/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/funcs/func_frame_trace.c?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/funcs/func_frame_trace.c (original)
+++ team/mjordan/longcat/funcs/func_frame_trace.c Fri Dec 21 09:01:45 2012
@@ -327,8 +327,23 @@
case AST_CONTROL_PVT_CAUSE_CODE:
ast_verbose("SubClass: PVT_CAUSE_CODE\n");
break;
- }
-
+ case AST_CONTROL_STREAM_STOP:
+ ast_verbose("SubClass: AST_CONTROL_STREAM_STOP\n");
+ break;
+ case AST_CONTROL_STREAM_SUSPEND:
+ ast_verbose("SubClass: AST_CONTROL_STREAM_SUSPEND\n");
+ break;
+ case AST_CONTROL_STREAM_RESTART:
+ ast_verbose("SubClass: AST_CONTROL_STREAM_RESTART\n");
+ break;
+ case AST_CONTROL_STREAM_REVERSE:
+ ast_verbose("SubClass: AST_CONTROL_STREAM_REVERSE\n");
+ break;
+ case AST_CONTROL_STREAM_FORWARD:
+ ast_verbose("SubClass: AST_CONTROL_STREAM_FORWARD\n");
+ break;
+ }
+
if (frame->subclass.integer == -1) {
ast_verbose("SubClass: %d\n", frame->subclass.integer);
}
Modified: team/mjordan/longcat/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/include/asterisk/frame.h?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/include/asterisk/frame.h (original)
+++ team/mjordan/longcat/include/asterisk/frame.h Fri Dec 21 09:01:45 2012
@@ -267,6 +267,13 @@
AST_CONTROL_MCID = 31, /*!< Indicate that the caller is being malicious. */
AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */
AST_CONTROL_PVT_CAUSE_CODE = 33, /*!< Contains an update to the protocol-specific cause-code stored for branching dials */
+ /* Control frames used to manipulate a stream on a channel */
+ AST_CONTROL_STREAM_STOP = 1000,
+ AST_CONTROL_STREAM_SUSPEND = 1001,
+ AST_CONTROL_STREAM_RESTART = 1002,
+ AST_CONTROL_STREAM_REVERSE = 1003,
+ AST_CONTROL_STREAM_FORWARD = 1004,
+
};
enum ast_frame_read_action {
Modified: team/mjordan/longcat/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/app.c?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/main/app.c (original)
+++ team/mjordan/longcat/main/app.c Fri Dec 21 09:01:45 2012
@@ -1004,23 +1004,24 @@
}
/* We go at next loop if we got the restart char */
- if (restart && strchr(restart, res)) {
+ if ((restart && strchr(restart, res)) || res == AST_CONTROL_STREAM_RESTART) {
ast_debug(1, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
continue;
}
- if (suspend && strchr(suspend, res)) {
+ if ((suspend && strchr(suspend, res)) || res == AST_CONTROL_STREAM_SUSPEND) {
pause_restart_point = ast_tellstream(ast_channel_stream(chan));
for (;;) {
ast_stopstream(chan);
if (!(res = ast_waitfordigit(chan, 1000))) {
continue;
- } else if (res == -1 || strchr(suspend, res) || (stop && strchr(stop, res))) {
+ } else if (res == -1 || strchr(suspend, res) || (stop && strchr(stop, res))
+ || res == AST_CONTROL_STREAM_SUSPEND || res == AST_CONTROL_STREAM_STOP) {
break;
}
}
- if (res == *suspend) {
+ if (res == *suspend || res == AST_CONTROL_STREAM_SUSPEND) {
res = 0;
continue;
}
@@ -1031,7 +1032,7 @@
}
/* if we get one of our stop chars, return it to the calling function */
- if (stop && strchr(stop, res)) {
+ if ((stop && strchr(stop, res)) || res == AST_CONTROL_STREAM_STOP) {
break;
}
}
Modified: team/mjordan/longcat/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/channel.c?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/main/channel.c (original)
+++ team/mjordan/longcat/main/channel.c Fri Dec 21 09:01:45 2012
@@ -3694,6 +3694,19 @@
ast_frfree(f);
ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
return -1;
+ case AST_CONTROL_STREAM_STOP:
+ case AST_CONTROL_STREAM_SUSPEND:
+ case AST_CONTROL_STREAM_RESTART:
+ case AST_CONTROL_STREAM_REVERSE:
+ case AST_CONTROL_STREAM_FORWARD:
+ /* Fall-through and treat as if it were a DTMF signal
+ * if we have a stream. Items that perform stream control
+ * will handle this. */
+ if (ast_channel_stream(c)) {
+ ast_frfree(f);
+ return f->subclass.integer;
+ }
+ /* Otherwise, ignore */
case AST_CONTROL_PVT_CAUSE_CODE:
case AST_CONTROL_RINGING:
case AST_CONTROL_ANSWER:
@@ -4448,6 +4461,11 @@
case AST_CONTROL_MCID:
case AST_CONTROL_UPDATE_RTP_PEER:
case AST_CONTROL_PVT_CAUSE_CODE:
+ case AST_CONTROL_STREAM_STOP:
+ case AST_CONTROL_STREAM_SUSPEND:
+ case AST_CONTROL_STREAM_REVERSE:
+ case AST_CONTROL_STREAM_FORWARD:
+ case AST_CONTROL_STREAM_RESTART:
break;
case AST_CONTROL_INCOMPLETE:
@@ -4655,6 +4673,11 @@
case AST_CONTROL_END_OF_Q:
case AST_CONTROL_MCID:
case AST_CONTROL_UPDATE_RTP_PEER:
+ case AST_CONTROL_STREAM_STOP:
+ case AST_CONTROL_STREAM_SUSPEND:
+ case AST_CONTROL_STREAM_REVERSE:
+ case AST_CONTROL_STREAM_FORWARD:
+ case AST_CONTROL_STREAM_RESTART:
/* Nothing left to do for these. */
res = 0;
break;
Modified: team/mjordan/longcat/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/file.c?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/main/file.c (original)
+++ team/mjordan/longcat/main/file.c Fri Dec 21 09:01:45 2012
@@ -1240,6 +1240,38 @@
return fs;
}
+static void waitstream_control(struct ast_channel *c,
+ enum ast_waitstream_fr_cb_values type,
+ ast_waitstream_fr_cb cb,
+ int skip_ms)
+{
+ switch (type)
+ {
+ case AST_WAITSTREAM_CB_FASTFORWARD:
+ {
+ int eoftest;
+ ast_stream_fastforward(ast_channel_stream(c), skip_ms);
+ eoftest = fgetc(ast_channel_stream(c)->f);
+ if (feof(ast_channel_stream(c)->f)) {
+ ast_stream_rewind(ast_channel_stream(c), skip_ms);
+ } else {
+ ungetc(eoftest, ast_channel_stream(c)->f);
+ }
+ }
+ break;
+ case AST_WAITSTREAM_CB_REWIND:
+ ast_stream_rewind(ast_channel_stream(c), skip_ms);
+ break;
+ default:
+ break;
+ }
+
+ if (cb) {
+ long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_rate(&ast_channel_stream(c)->fmt->format) / 1000);
+ cb(c, ms_len, type);
+ }
+}
+
/*!
* \brief the core of all waitstream() functions
*/
@@ -1336,34 +1368,38 @@
return res;
}
} else {
- enum ast_waitstream_fr_cb_values cb_val = 0;
res = fr->subclass.integer;
if (strchr(forward, res)) {
- int eoftest;
- ast_stream_fastforward(ast_channel_stream(c), skip_ms);
- eoftest = fgetc(ast_channel_stream(c)->f);
- if (feof(ast_channel_stream(c)->f)) {
- ast_stream_rewind(ast_channel_stream(c), skip_ms);
- } else {
- ungetc(eoftest, ast_channel_stream(c)->f);
- }
- cb_val = AST_WAITSTREAM_CB_FASTFORWARD;
+ waitstream_control(c, AST_WAITSTREAM_CB_FASTFORWARD, cb, skip_ms);
} else if (strchr(reverse, res)) {
- ast_stream_rewind(ast_channel_stream(c), skip_ms);
- cb_val = AST_WAITSTREAM_CB_REWIND;
+ waitstream_control(c, AST_WAITSTREAM_CB_REWIND, cb, skip_ms);
} else if (strchr(breakon, res)) {
ast_frfree(fr);
ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
return res;
}
- if (cb_val && cb) {
- long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_rate(&ast_channel_stream(c)->fmt->format) / 1000);
- cb(c, ms_len, cb_val);
- }
}
break;
case AST_FRAME_CONTROL:
switch (fr->subclass.integer) {
+ case AST_CONTROL_STREAM_STOP:
+ case AST_CONTROL_STREAM_SUSPEND:
+ case AST_CONTROL_STREAM_RESTART:
+ /* Fall-through and break out */
+ ast_frfree(fr);
+ return fr->subclass.integer;
+ case AST_CONTROL_STREAM_REVERSE:
+ if (!skip_ms) {
+ skip_ms = 3000;
+ }
+ waitstream_control(c, AST_WAITSTREAM_CB_REWIND, cb, skip_ms);
+ break;
+ case AST_CONTROL_STREAM_FORWARD:
+ if (!skip_ms) {
+ skip_ms = 3000;
+ }
+ waitstream_control(c, AST_WAITSTREAM_CB_FASTFORWARD, cb, skip_ms);
+ break;
case AST_CONTROL_HANGUP:
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
Modified: team/mjordan/longcat/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/res/res_agi.c?view=diff&rev=378188&r1=378118&r2=378188
==============================================================================
--- team/mjordan/longcat/res/res_agi.c (original)
+++ team/mjordan/longcat/res/res_agi.c Fri Dec 21 09:01:45 2012
@@ -96,6 +96,33 @@
<see-also>
<ref type="agi">hangup</ref>
</see-also>
+ </agi>
+ <agi name="asyncagi control stream" language="en_US">
+ <synopsis>
+ Controls a currently streaming file being played to a channel in Async AGI
+ </synopsis>
+ <syntax>
+ <parameter name="operation">
+ <para>The operation to perform on the stream.</para>
+ <enumlist>
+ <enum name="stop">
+ <para></para>
+ </enum>
+ <enum name="forward">
+ <para></para>
+ </enum>
+ <enum name="reverse">
+ <para></para>
+ </enum>
+ <enum name="pause">
+ <para></para>
+ </enum>
+ <enum name="restart">
+ <para></para>
+ </enum>
+ </enumlist>
+ </parameter>
+ </syntax>
</agi>
<agi name="channel status" language="en_US">
<synopsis>
@@ -1865,6 +1892,35 @@
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return ASYNC_AGI_BREAK;
+}
+
+static int handle_asyncagi_control_stream(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
+{
+ if (argc != 4) {
+ return RESULT_SHOWUSAGE;
+ }
+
+ if (!ast_channel_stream(chan)) {
+ ast_agi_send(agi->fd, chan, "200 result=0\n");
+ return RESULT_FAILURE;
+ }
+
+ if (!strcmp(argv[3], "stop")) {
+ ast_indicate(chan, AST_CONTROL_STREAM_STOP);
+ } else if (!strcmp(argv[3], "forward")) {
+ ast_indicate(chan, AST_CONTROL_STREAM_FORWARD);
+ } else if (!strcmp(argv[3], "reverse")) {
+ ast_indicate(chan, AST_CONTROL_STREAM_REVERSE);
+ } else if (!strcmp(argv[3], "pause")) {
+ ast_indicate(chan, AST_CONTROL_STREAM_SUSPEND);
+ } else if (!strcmp(argv[3], "restart")) {
+ ast_indicate(chan, AST_CONTROL_STREAM_RESTART);
+ } else {
+ return RESULT_SHOWUSAGE;
+ }
+
+ ast_agi_send(agi->fd, chan, "200 result=1\n");
+ return RESULT_SUCCESS;
}
static int handle_waitfordigit(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
@@ -3150,6 +3206,7 @@
static struct agi_command commands[] = {
{ { "answer", NULL }, handle_answer, NULL, NULL, 0 },
{ { "asyncagi", "break", NULL }, handle_asyncagi_break, NULL, NULL, 1 },
+ { { "asyncagi", "control", "stream", NULL }, handle_asyncagi_control_stream, NULL, NULL, 0 },
{ { "channel", "status", NULL }, handle_channelstatus, NULL, NULL, 0 },
{ { "database", "del", NULL }, handle_dbdel, NULL, NULL, 1 },
{ { "database", "deltree", NULL }, handle_dbdeltree, NULL, NULL, 1 },
More information about the asterisk-commits
mailing list