Ejemplo n.º 1
0
static void super_tone_rx_fill_descriptor(super_tone_rx_descriptor_t *desc)
{
    int tone_id;

    tone_id = super_tone_rx_add_tone(desc);
    super_tone_rx_add_element(desc, tone_id, 400, 0, 700, 0);
    tone_names[tone_id] = "XXX";

    tone_id = super_tone_rx_add_tone(desc);
    super_tone_rx_add_element(desc, tone_id, 1100, 0, 400, 600);
    super_tone_rx_add_element(desc, tone_id, 0, 0, 2800, 3200);
    tone_names[tone_id] = "FAX tone";
}
Ejemplo n.º 2
0
/**
 * Add a tone element to the tone descriptor
 *
 * @param descriptor the tone descriptor
 * @param tone_id the tone ID
 * @param freq1 the first frequency (0 if none)
 * @param freq2 the second frequency (0 if none)
 * @param min the minimum tone duration in ms
 * @param max the maximum tone duration in ms
 * @return SWITCH_STATUS_SUCCESS if successful
 */
switch_status_t tone_descriptor_add_tone_element(tone_descriptor_t *descriptor, int tone_id, int freq1, int freq2, int min, int max)
{
	if (super_tone_rx_add_element(descriptor->spandsp_tone_descriptor, tone_id, freq1, freq2, min, max) == 0) {
		return SWITCH_STATUS_SUCCESS;
	}
	return SWITCH_STATUS_FALSE;
}
Ejemplo n.º 3
0
static int parse_tone(super_tone_rx_descriptor_t *desc, int tone_id, super_tone_tx_step_t **tree, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
{
    xmlChar *x;
    float f1;
    float f2;
    float f_tol;
    float l1;
    float l2;
    float length;
    float length_tol;
    float recognition_length;
    float recognition_length_tol;
    int cycles;
    super_tone_tx_step_t *treep;
    int min_duration;
    int max_duration;

    cur = cur->xmlChildrenNode;
    while (cur)
    {
        if (xmlStrcmp(cur->name, (const xmlChar *) "step") == 0)
        {
            printf("Step - ");
            /* Set some defaults */
            f1 = 0.0;
            f2 = 0.0;
            f_tol = 1.0;
            l1 = -11.0;
            l2 = -11.0;
            length = 0.0;
            length_tol = 10.0;
            recognition_length = 0.0;
            recognition_length_tol = 10.0;
            cycles = 1;
            if ((x = xmlGetProp(cur, (const xmlChar *) "freq")))
            {
                sscanf((char *) x, "%f [%f%%]", &f1, &f_tol);
                sscanf((char *) x, "%f+%f [%f%%]", &f1, &f2, &f_tol);
                printf(" Frequency=%.2f+%.2f [%.2f%%]", f1, f2, f_tol);
            }
            if ((x = xmlGetProp(cur, (const xmlChar *) "level")))
            {
                if (sscanf((char *) x, "%f+%f", &l1, &l2) < 2)
                    l2 = l1;
                printf(" Level=%.2f+%.2f", l1, l2);
            }
            if ((x = xmlGetProp(cur, (const xmlChar *) "length")))
            {
                sscanf((char *) x, "%f [%f%%]", &length, &length_tol);
                printf(" Length=%.2f [%.2f%%]", length, length_tol);
            }
            if ((x = xmlGetProp(cur, (const xmlChar *) "recognition-length")))
            {
                sscanf((char *) x, "%f [%f%%]", &recognition_length, &recognition_length_tol);
                printf(" Recognition length=%.2f [%.2f%%]", recognition_length, recognition_length_tol);
            }
            if ((x = xmlGetProp(cur, (const xmlChar *) "cycles")))
            {
                if (strcasecmp((char *) x, "endless") == 0)
                    cycles = 0;
                else
                    cycles = atoi((char *) x);
                printf(" Cycles='%d' ", cycles);
            }
            if ((x = xmlGetProp(cur, (const xmlChar *) "recorded-announcement")))
                printf(" Recorded announcement='%s'", x);
            printf("\n");
            if (f1  ||  f2  ||  length)
            {
                /* TODO: This cannot handle cycling patterns */
                if (length == 0.0)
                {
                    if (recognition_length)
                        min_duration = recognition_length*1000.0 + 0.5;
                    else
                        min_duration = 700;
                    max_duration = 0;
                }
                else
                {
                    if (recognition_length)
                        min_duration = recognition_length*1000.0 + 0.5;
                    else
                        min_duration = (length*1000.0 + 0.5)*(1.0 - length_tol/100.0) - 30;
                    max_duration = (length*1000.0 + 0.5)*(1.0 + length_tol/100.0) + 30;
                }
                printf(">>>Detector element %10d %10d %10d %10d\n", (int) (f1 + 0.5), (int) (f2 + 0.5), min_duration, max_duration);
                super_tone_rx_add_element(desc, tone_id, f1 + 0.5, f2 + 0.5, min_duration, max_duration);
            }
            treep = super_tone_tx_make_step(NULL,
                                            f1,
                                            l1,
                                            f2,
                                            l2,
                                            length*1000.0 + 0.5,
                                            cycles);
            *tree = treep;
            tree = &(treep->next);
            parse_tone(desc, tone_id, &(treep->nest), doc, ns, cur);
        }
        /*endif*/
        cur = cur->next;
    }
    /*endwhile*/
    return  0;
}