[asterisk-commits] mjordan: branch mjordan/longcat r378650 - in /team/mjordan/longcat: ./ apps/ ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 7 11:24:14 CST 2013
Author: mjordan
Date: Mon Jan 7 11:24:09 2013
New Revision: 378650
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378650
Log:
Make it actually work.
A few things:
* Needed to queue the control frames, not indicate
* Fix some crashes, bad returns, and other malarkey
* Pause would never work. Now it does.
Modified:
team/mjordan/longcat/apps/app_controlplayback.c
team/mjordan/longcat/main/app.c
team/mjordan/longcat/main/channel.c
team/mjordan/longcat/main/file.c
team/mjordan/longcat/test_script.py
Modified: team/mjordan/longcat/apps/app_controlplayback.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/apps/app_controlplayback.c?view=diff&rev=378650&r1=378649&r2=378650
==============================================================================
--- team/mjordan/longcat/apps/app_controlplayback.c (original)
+++ team/mjordan/longcat/apps/app_controlplayback.c Mon Jan 7 11:24:09 2013
@@ -132,10 +132,12 @@
</note>
</enum>
<enum name="pause">
- <para>Pause/unpause the playback operation.</para>
+ <para>Pause/unpause the playback operation, if supported.
+ If not supported, stop the playback.</para>
</enum>
<enum name="restart">
- <para>Restart the playback operation.</para>
+ <para>Restart the playback operation, if supported.
+ If not supported, stop the playback.</para>
</enum>
</enumlist>
</parameter>
@@ -145,6 +147,13 @@
Note that this AMI action does not initiate playback of media to channel, but
rather controls the operation of a media operation that was already initiated
on the channel.</para>
+ <note>
+ <para>The <literal>pause</literal> and <literal>restart</literal>
+ <replaceable>Control</replaceable> options will stop a playback
+ operation if that operation was not initiated from the
+ <replaceable>ControlPlayback</replaceable> application or the
+ <replaceable>control stream file</replaceable> AGI command.</para>
+ </note>
</description>
<see-also>
<ref type="application">Playback</ref>
@@ -298,29 +307,16 @@
return 0;
}
- /* At least make sure that before we send the control signal there is
- * something streamed to the channel. The playback could still end before
- * the frame is serviced, but it's something.
- */
- ast_channel_lock(chan);
- if (!ast_channel_stream(chan)) {
- ast_channel_unlock(chan);
- chan = ast_channel_unref(chan);
- astman_send_error(s, m, "Nothing being played back to channel");
- return 0;
- }
- ast_channel_unlock(chan);
-
if (!strcmp(control_type, "stop")) {
- ast_indicate(chan, AST_CONTROL_STREAM_STOP);
+ ast_queue_control(chan, AST_CONTROL_STREAM_STOP);
} else if (!strcmp(control_type, "forward")) {
- ast_indicate(chan, AST_CONTROL_STREAM_FORWARD);
+ ast_queue_control(chan, AST_CONTROL_STREAM_FORWARD);
} else if (!strcmp(control_type, "reverse")) {
- ast_indicate(chan, AST_CONTROL_STREAM_REVERSE);
+ ast_queue_control(chan, AST_CONTROL_STREAM_REVERSE);
} else if (!strcmp(control_type, "pause")) {
- ast_indicate(chan, AST_CONTROL_STREAM_SUSPEND);
+ ast_queue_control(chan, AST_CONTROL_STREAM_SUSPEND);
} else if (!strcmp(control_type, "restart")) {
- ast_indicate(chan, AST_CONTROL_STREAM_RESTART);
+ ast_queue_control(chan, AST_CONTROL_STREAM_RESTART);
} else {
astman_send_error(s, m, "Unknown control type");
chan = ast_channel_unref(chan);
Modified: team/mjordan/longcat/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/app.c?view=diff&rev=378650&r1=378649&r2=378650
==============================================================================
--- team/mjordan/longcat/main/app.c (original)
+++ team/mjordan/longcat/main/app.c Mon Jan 7 11:24:09 2013
@@ -1016,12 +1016,12 @@
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 || (suspend && strchr(suspend, res)) || (stop && strchr(stop, res))
|| res == AST_CONTROL_STREAM_SUSPEND || res == AST_CONTROL_STREAM_STOP) {
break;
}
}
- if (res == *suspend || res == AST_CONTROL_STREAM_SUSPEND) {
+ if ((suspend && (res == *suspend)) || res == AST_CONTROL_STREAM_SUSPEND) {
res = 0;
continue;
}
@@ -1049,11 +1049,6 @@
if (offsetms) {
*offsetms = offset / 8; /* samples --> ms ... XXX Assumes 8 kHz */
- }
-
- /* If we are returning a digit cast it as char */
- if (res > 0 || ast_channel_stream(chan)) {
- res = (char)res;
}
ast_stopstream(chan);
Modified: team/mjordan/longcat/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/channel.c?view=diff&rev=378650&r1=378649&r2=378650
==============================================================================
--- team/mjordan/longcat/main/channel.c (original)
+++ team/mjordan/longcat/main/channel.c Mon Jan 7 11:24:09 2013
@@ -3705,14 +3705,12 @@
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 */
+ /* Fall-through and treat as if it were a DTMF signal. Items
+ * that perform stream control will handle this. */
+ res = f->subclass.integer;
+ ast_frfree(f);
+ ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ return res;
case AST_CONTROL_PVT_CAUSE_CODE:
case AST_CONTROL_RINGING:
case AST_CONTROL_ANSWER:
Modified: team/mjordan/longcat/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/main/file.c?view=diff&rev=378650&r1=378649&r2=378650
==============================================================================
--- team/mjordan/longcat/main/file.c (original)
+++ team/mjordan/longcat/main/file.c Mon Jan 7 11:24:09 2013
@@ -1386,8 +1386,10 @@
case AST_CONTROL_STREAM_SUSPEND:
case AST_CONTROL_STREAM_RESTART:
/* Fall-through and break out */
+ res = fr->subclass.integer;
ast_frfree(fr);
- return fr->subclass.integer;
+ ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY);
+ return res;
case AST_CONTROL_STREAM_REVERSE:
if (!skip_ms) {
skip_ms = 3000;
Modified: team/mjordan/longcat/test_script.py
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/longcat/test_script.py?view=diff&rev=378650&r1=378649&r2=378650
==============================================================================
--- team/mjordan/longcat/test_script.py (original)
+++ team/mjordan/longcat/test_script.py Mon Jan 7 11:24:09 2013
@@ -78,35 +78,42 @@
message['channel'] = CHANNEL
message['command'] = 'STREAM FILE %s ""' % file
AMI.sendMessage(message)
+
+ elif (command == 'control'):
+ message['action'] = 'AGI'
+ message['channel'] = CHANNEL
+ message['command'] = 'CONTROL STREAM FILE %s ""' % tokens[1].lower()
+ AMI.sendMessage(message)
elif (command == 'reverse'):
- message['action'] = 'AGI'
- message['channel'] = CHANNEL
- message['command'] = 'ASYNCAGI CONTROL STREAM REVERSE'
+ message['action'] = 'ControlPlayback'
+ message['channel'] = CHANNEL
+ message['control'] = 'reverse'
AMI.sendMessage(message)
elif (command == 'restart'):
- message['action'] = 'AGI'
- message['channel'] = CHANNEL
- message['command'] = 'ASYNCAGI CONTROL STREAM RESTART'
+ message['action'] = 'ControlPlayback'
+ message['channel'] = CHANNEL
+ message['control'] = 'restart'
AMI.sendMessage(message)
elif (command == 'forward'):
- message['action'] = 'AGI'
- message['channel'] = CHANNEL
- message['command'] = 'ASYNCAGI CONTROL STREAM FORWARD'
+ message['action'] = 'ControlPlayback'
+ message['channel'] = CHANNEL
+ message['control'] = 'forward'
AMI.sendMessage(message)
elif (command == 'stop'):
- message['action'] = 'AGI'
- message['channel'] = CHANNEL
- message['command'] = 'ASYNCAGI CONTROL STREAM STOP'
+ message['action'] = 'ControlPlayback'
+ message['channel'] = CHANNEL
+ message['control'] = 'stop'
AMI.sendMessage(message)
elif (command == 'pause'):
- message['action'] = 'AGI'
- message['channel'] = CHANNEL
- message['command'] = 'ASYNCAGI CONTROL STREAM PAUSE'
- AMI.sendMessage(message)
+ message['action'] = 'ControlPlayback'
+ message['channel'] = CHANNEL
+ message['control'] = 'pause'
+ AMI.sendMessage(message)
+
else:
SERVER.send_message('I do not know that one.')
return
More information about the asterisk-commits
mailing list