static void tone_detected(void *user_data, int tone, int level, int delay) { t30_state_t *s; s = (t30_state_t *) user_data; span_log(&s->logging, SPAN_LOG_FLOW, "%s detected (%ddBm0)\n", modem_connect_tone_to_str(tone), level); }
static void handler(void *user_data, v8_parms_t *result) { const char *s; s = (const char *) user_data; printf("%s ", s); switch (result->status) { case V8_STATUS_IN_PROGRESS: printf("V.8 negotiation in progress\n"); return; case V8_STATUS_V8_OFFERED: printf("V.8 offered by the other party\n"); break; case V8_STATUS_V8_CALL: printf("V.8 call negotiation successful\n"); break; case V8_STATUS_NON_V8_CALL: printf("Non-V.8 call negotiation successful\n"); break; case V8_STATUS_FAILED: printf("V.8 call negotiation failed\n"); return; default: printf("Unexpected V.8 status %d\n", result->status); break; } /*endswitch*/ printf(" Modem connect tone '%s' (%d)\n", modem_connect_tone_to_str(result->modem_connect_tone), result->modem_connect_tone); printf(" Call function '%s' (%d)\n", v8_call_function_to_str(result->call_function), result->call_function); printf(" Far end modulations 0x%X\n", result->modulations); printf(" Protocol '%s' (%d)\n", v8_protocol_to_str(result->protocol), result->protocol); printf(" PSTN access '%s' (%d)\n", v8_pstn_access_to_str(result->pstn_access), result->pstn_access); printf(" PCM modem availability '%s' (%d)\n", v8_pcm_modem_availability_to_str(result->pcm_modem_availability), result->pcm_modem_availability); if (result->t66 >= 0) printf(" T.66 '%s' (%d)\n", v8_t66_to_str(result->t66), result->t66); /*endif*/ if (result->nsf >= 0) printf(" NSF %d\n", result->nsf); /*endif*/ switch (result->status) { case V8_STATUS_V8_OFFERED: /* Edit the result information appropriately */ //result->call_function = V8_CALL_T30_TX; result->modulations &= (V8_MOD_V17 | V8_MOD_V21 //| V8_MOD_V22 //| V8_MOD_V23HDX //| V8_MOD_V23 //| V8_MOD_V26BIS //| V8_MOD_V26TER | V8_MOD_V27TER | V8_MOD_V29 //| V8_MOD_V32 | V8_MOD_V34HDX //| V8_MOD_V34 //| V8_MOD_V90 | V8_MOD_V92); break; case V8_STATUS_V8_CALL: if (result->call_function == V8_CALL_V_SERIES && result->protocol == V8_PROTOCOL_LAPM_V42) { negotiations_ok++; } /*endif*/ break; case V8_STATUS_NON_V8_CALL: negotiations_ok = 42; break; } /*endswitch*/ }
static int non_v8_calls_v8_tests(SNDFILE *outhandle) { silence_gen_state_t *non_v8_caller_tx; modem_connect_tones_rx_state_t *non_v8_caller_rx; v8_state_t *v8_answerer; logging_state_t *answerer_logging; int answerer_available_modulations; int i; int samples; int remnant; int outframes; int tone; int16_t amp[SAMPLES_PER_CHUNK]; int16_t out_amp[2*SAMPLES_PER_CHUNK]; v8_parms_t v8_answer_parms; answerer_available_modulations = V8_MOD_V17 | V8_MOD_V21 | V8_MOD_V22 | V8_MOD_V23HDX | V8_MOD_V23 | V8_MOD_V26BIS | V8_MOD_V26TER | V8_MOD_V27TER | V8_MOD_V29 | V8_MOD_V32 | V8_MOD_V34HDX | V8_MOD_V34 | V8_MOD_V90 | V8_MOD_V92; negotiations_ok = 0; non_v8_caller_tx = silence_gen_init(NULL, 10*SAMPLE_RATE); non_v8_caller_rx = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL); v8_answer_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; v8_answer_parms.send_ci = true; v8_answer_parms.v92 = -1; v8_answer_parms.call_function = V8_CALL_V_SERIES; v8_answer_parms.modulations = answerer_available_modulations; v8_answer_parms.protocol = V8_PROTOCOL_LAPM_V42; v8_answer_parms.pcm_modem_availability = 0; v8_answer_parms.pstn_access = 0; v8_answer_parms.nsf = -1; v8_answer_parms.t66 = -1; v8_answerer = v8_init(NULL, false, &v8_answer_parms, handler, (void *) "answerer"); answerer_logging = v8_get_logging_state(v8_answerer); span_log_set_level(answerer_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME); span_log_set_tag(answerer_logging, "answerer"); for (i = 0; i < 1000; i++) { samples = silence_gen(non_v8_caller_tx, amp, SAMPLES_PER_CHUNK); if (samples < SAMPLES_PER_CHUNK) { vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples); samples = SAMPLES_PER_CHUNK; } /*endif*/ remnant = v8_rx(v8_answerer, amp, samples); if (remnant) break; /*endif*/ for (i = 0; i < samples; i++) out_amp[2*i] = amp[i]; /*endfor*/ samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK); if (samples < SAMPLES_PER_CHUNK) { vec_zeroi16(amp + samples, SAMPLES_PER_CHUNK - samples); samples = SAMPLES_PER_CHUNK; } /*endif*/ span_log_bump_samples(answerer_logging, samples); modem_connect_tones_rx(non_v8_caller_rx, amp, samples); if ((tone = modem_connect_tones_rx_get(non_v8_caller_rx)) != MODEM_CONNECT_TONES_NONE) { printf("Detected %s (%d)\n", modem_connect_tone_to_str(tone), tone); if (tone == MODEM_CONNECT_TONES_ANSAM_PR) negotiations_ok++; /*endif*/ } /*endif*/ for (i = 0; i < samples; i++) out_amp[2*i + 1] = amp[i]; /*endfor*/ if (outhandle) { outframes = sf_writef_short(outhandle, out_amp, samples); if (outframes != samples) { fprintf(stderr, " Error writing audio file\n"); exit(2); } /*endif*/ } /*endif*/ } /*endfor*/ silence_gen_free(non_v8_caller_tx); modem_connect_tones_rx_free(non_v8_caller_rx); v8_free(v8_answerer); if (negotiations_ok != 1) { printf("Tests failed.\n"); exit(2); } /*endif*/ return 0; }