Пример #1
0
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;
}
Пример #2
0
static void playtone(struct ast_channel *chan, int tone, int len)
{
	char dtmf[20];
	snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len);
	ast_playtones_start(chan, 0, dtmf, 0);
	ast_safe_sleep(chan, len);
	ast_playtones_stop(chan);
}
Пример #3
0
/*
 * Playtones command stuff
 */
static int handle_playtones(struct ast_channel *chan, void *data)
{
	struct ind_tone_zone_sound *ts;
	int res;

	if (!data || !((char*)data)[0]) {
		ast_log(LOG_NOTICE,"Nothing to play\n");
		return -1;
	}
	ts = ast_get_indication_tone(chan->zone, (const char*)data);
	if (ts && ts->data[0])
		res = ast_playtones_start(chan, 0, ts->data, 0);
	else
		res = ast_playtones_start(chan, 0, (const char*)data, 0);
	if (res)
		ast_log(LOG_NOTICE,"Unable to start playtones\n");
	return res;
}
Пример #4
0
static void play_dialtone(struct ast_channel *chan, char *mailbox)
{
	const struct tone_zone_sound *ts = NULL;
	if(ast_app_has_voicemail(mailbox, NULL))
		ts = ast_get_indication_tone(chan->zone, "dialrecall");
	else
		ts = ast_get_indication_tone(chan->zone, "dial");
	if (ts)
		ast_playtones_start(chan, 0, ts->data, 0);
	else
		ast_tonepair_start(chan, 350, 440, 0, 0);
}
Пример #5
0
/*!
 * \brief Send a single tone burst for a specified duration and frequency.
 * \since 11.0
 *
 * \param chan Asterisk Channel
 * \param tone_freq Frequency of the tone to send
 * \param tone_duration Tone duration in ms
 * \param delay Delay before sending the tone
 *
 * \retval 0 success
 * \retval -1 failure
 */
static int send_tone_burst(struct ast_channel *chan, const char *tone_freq, int tone_duration, int delay)
{
	if (delay && ast_safe_sleep(chan, delay)) {
		return -1;
	}

	if (ast_playtones_start(chan, toneloudness, tone_freq, 0)) {
		return -1;
	}

	if (ast_safe_sleep(chan, tone_duration)) {
		return -1;
	}

	ast_playtones_stop(chan);
	return 0;
}
Пример #6
0
static void play_dialtone(struct ast_channel *chan, char *mailbox)
{
	struct ast_tone_zone_sound *ts = NULL;

	if (ast_app_has_voicemail(mailbox, NULL)) {
		ts = ast_get_indication_tone(ast_channel_zone(chan), "dialrecall");
	} else {
		ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
	}

	if (ts) {
		ast_playtones_start(chan, 0, ts->data, 0);
		ts = ast_tone_zone_sound_unref(ts);
	} else {
		ast_tonepair_start(chan, 350, 440, 0, 0);
	}
}
Пример #7
0
static int milliwatt_exec(struct ast_channel *chan, const char *data)
{
	const char *options = data;
	int res = -1;

	if (!ast_strlen_zero(options) && strchr(options, 'o')) {
		return old_milliwatt_exec(chan);
	}

	res = ast_playtones_start(chan, 23255, "1004/1000", 0);

	while (!res) {
		res = ast_safe_sleep(chan, 10000);
	}

	return res;
}