123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #include "asterisk.h"
- ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
- #include "asterisk/module.h"
- #include "asterisk/pbx.h"
- #include "asterisk/channel.h"
- #include "asterisk/indications.h"
- static const char playtones_app[] = "PlayTones";
- static const char stopplaytones_app[] = "StopPlayTones";
- static int handle_playtones(struct ast_channel *chan, const char *data)
- {
- struct ast_tone_zone_sound *ts;
- int res;
- const char *str = data;
- if (ast_strlen_zero(str)) {
- ast_log(LOG_NOTICE,"Nothing to play\n");
- return -1;
- }
- ts = ast_get_indication_tone(ast_channel_zone(chan), str);
- if (ts) {
- res = ast_playtones_start(chan, 0, ts->data, 0);
- ts = ast_tone_zone_sound_unref(ts);
- } else {
- res = ast_playtones_start(chan, 0, str, 0);
- }
- if (res) {
- ast_log(LOG_NOTICE, "Unable to start playtones\n");
- }
- return res;
- }
- static int handle_stopplaytones(struct ast_channel *chan, const char *data)
- {
- ast_playtones_stop(chan);
- return 0;
- }
- static int unload_module(void)
- {
- int res;
- res = ast_unregister_application(playtones_app);
- res |= ast_unregister_application(stopplaytones_app);
- return res;
- }
- static int load_module(void)
- {
- int res;
- res = ast_register_application_xml(playtones_app, handle_playtones);
- res |= ast_register_application_xml(stopplaytones_app, handle_stopplaytones);
- return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
- }
- AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Playtones Application");
|