app_playtones.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "asterisk.h"
00033
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
00035
00036 #include "asterisk/module.h"
00037 #include "asterisk/pbx.h"
00038 #include "asterisk/channel.h"
00039 #include "asterisk/indications.h"
00040
00041 static const char playtones_app[] = "PlayTones";
00042 static const char stopplaytones_app[] = "StopPlayTones";
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 static int handle_playtones(struct ast_channel *chan, const char *data)
00080 {
00081 struct ast_tone_zone_sound *ts;
00082 int res;
00083 const char *str = data;
00084
00085 if (ast_strlen_zero(str)) {
00086 ast_log(LOG_NOTICE,"Nothing to play\n");
00087 return -1;
00088 }
00089
00090 ts = ast_get_indication_tone(chan->zone, str);
00091
00092 if (ts) {
00093 res = ast_playtones_start(chan, 0, ts->data, 0);
00094 ts = ast_tone_zone_sound_unref(ts);
00095 } else {
00096 res = ast_playtones_start(chan, 0, str, 0);
00097 }
00098
00099 if (res) {
00100 ast_log(LOG_NOTICE, "Unable to start playtones\n");
00101 }
00102
00103 return res;
00104 }
00105
00106 static int handle_stopplaytones(struct ast_channel *chan, const char *data)
00107 {
00108 ast_playtones_stop(chan);
00109
00110 return 0;
00111 }
00112
00113 static int unload_module(void)
00114 {
00115 int res;
00116
00117 res = ast_unregister_application(playtones_app);
00118 res |= ast_unregister_application(stopplaytones_app);
00119
00120 return res;
00121 }
00122
00123 static int load_module(void)
00124 {
00125 int res;
00126
00127 res = ast_register_application_xml(playtones_app, handle_playtones);
00128 res |= ast_register_application_xml(stopplaytones_app, handle_stopplaytones);
00129
00130 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
00131 }
00132
00133 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Playtones Application");