Example #1
0
static int process_packet(void *user_data, const uint8_t *pkt, int len)
{
    static udptl_state_t *state = NULL;

    if (state == NULL)
        state = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, ifp_handler, NULL);

    udptl_rx_packet(state, pkt, len);
    return 0;
}
Example #2
0
static int fax_initGW(fax_params_t *f_params)
{
    t38_gateway_state_t *t38_gw;
    t38_core_state_t *t38_core;
    logging_state_t *logging;
    session_t *session;
    int log_level;
    int ret_val = 0;
    int fec_entries = DEFAULT_FEC_ENTRIES;
    int fec_span = DEFAULT_FEC_SPAN;
    int supported_modems;

    if(!f_params)
    {
        ret_val = -1; goto _exit;
    }

    session = f_params->session;

    app_trace(TRACE_INFO, "Fax %04x. Init T.38-fax gateway", session->ses_id);

    memset(f_params->pvt.t38_gw_state, 0, sizeof(t38_gateway_state_t));

    if(t38_gateway_init(f_params->pvt.t38_gw_state, t38_tx_packet_handler,
                         f_params) == NULL)
    {
        app_trace(TRACE_ERR, "Fax %04x. Cannot initialize T.38 structs",
                  session->ses_id);
        ret_val = -2; goto _exit;
    }

    t38_gw = f_params->pvt.t38_gw_state;

    t38_core = f_params->pvt.t38_core = t38_gateway_get_t38_core_state(t38_gw);

    t38_gateway_set_transmit_on_idle(t38_gw, TRANSMIT_ON_IDLE);
    t38_gateway_set_tep_mode(t38_gw, TEP_MODE);

    if(udptl_init(f_params->pvt.udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY,
                  fec_span, fec_entries,
                  (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet,
                  (void *) f_params->pvt.t38_core) == NULL)
    {
        app_trace(TRACE_ERR, "Fax %04x. Cannot initialize UDPTL structs",
                  session->ses_id);
        ret_val = -3; goto _exit;
    }

    if(f_params->pvt.verbose)
    {
        log_level = SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG |
                SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL |
                SPAN_LOG_FLOW;

        logging = t38_gateway_get_logging_state(t38_gw);
        span_log_set_message_handler(logging, fax_spandspLog);
        span_log_set_level(logging, log_level);
        span_log_set_tag(logging, f_params->log_tag);

        logging = t38_core_get_logging_state(t38_core);
        span_log_set_message_handler(logging, fax_spandspLog);
        span_log_set_level(logging, log_level);
        span_log_set_tag(logging, f_params->log_tag);
    }

	supported_modems = T30_SUPPORT_V29 | T30_SUPPORT_V27TER;
	if(!f_params->pvt.disable_v17) supported_modems |= T30_SUPPORT_V17;

	t38_gateway_set_supported_modems(t38_gw, supported_modems);
	t38_gateway_set_ecm_capability(t38_gw, f_params->pvt.use_ecm);

_exit:
	return ret_val;
}
Example #3
0
/*
 *  Init appropriate spandsp objects to receive fax
 */
static int spanfax_init(fax_session_t *f_session, fax_transport_mod_e trans_mode)
{
    t38_terminal_state_t *t38;
    t38_core_state_t *t38_core;
    t30_state_t *t30;
    logging_state_t *logging;
    int log_level;

    int fec_entries = DEFAULT_FEC_ENTRIES;
    int fec_span = DEFAULT_FEC_SPAN;

    printf("fax: %s: start!\n", __func__);

    switch(trans_mode) {
        case FAX_TRANSPORT_T38_MOD:

            memset(f_session->pvt.t38_state, 0, sizeof(t38_terminal_state_t));

			if (t38_terminal_init(f_session->pvt.t38_state, f_session->pvt.caller,
								  t38_tx_packet_handler, f_session) == NULL) {
				printf("fax: Cannot initialize T.38 structs\n");
				return 0;
			}

			t38 = f_session->pvt.t38_state;
			t30 = t38_terminal_get_t30_state(t38);

			t38_core = f_session->pvt.t38_core = t38_terminal_get_t38_core_state(t38);
			t38_terminal_set_config(t38, 0);
			t38_terminal_set_tep_mode(t38, 0);

			if (udptl_init(f_session->pvt.udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY,
						   fec_span, fec_entries, (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet,
						   (void *) f_session->pvt.t38_core) == NULL) {
				printf("fax: Cannot initialize UDPTL structs\n");
				return 0;
			}

			if (f_session->pvt.verbose) {
				log_level = SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG |
						SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL |
						SPAN_LOG_FLOW;

				logging = t38_terminal_get_logging_state(t38);
				span_log_set_message_handler(logging, spanfax_log_message);
				span_log_set_level(logging, log_level);
				span_log_set_tag(logging, f_session->log_tag);

				logging = t38_core_get_logging_state(t38_core);
				span_log_set_message_handler(logging, spanfax_log_message);
				span_log_set_level(logging, log_level);
				span_log_set_tag(logging, f_session->log_tag);

				logging = t30_get_logging_state(t30);
				span_log_set_message_handler(logging, spanfax_log_message);
				span_log_set_level(logging, log_level);
				span_log_set_tag(logging, f_session->log_tag);
			}

            break;
        case FAX_TRANSPORT_AUDIO_MOD:
        default:
            return 0;
            break;
    }

	/* All the things which are common to audio and T.38 FAX setup */

	t30_set_tx_ident(t30, f_session->pvt.ident);
	t30_set_tx_page_header_info(t30, f_session->pvt.header);

	t30_set_phase_e_handler(t30, phase_e_handler, f_session);
	t30_set_phase_d_handler(t30, phase_d_handler, f_session);
	t30_set_phase_b_handler(t30, phase_b_handler, f_session);

	t30_set_supported_image_sizes(t30, T30_SUPPORT_US_LETTER_LENGTH
								  | T30_SUPPORT_US_LEGAL_LENGTH
								  | T30_SUPPORT_UNLIMITED_LENGTH
								  | T30_SUPPORT_215MM_WIDTH
								  | T30_SUPPORT_255MM_WIDTH
								  | T30_SUPPORT_303MM_WIDTH
								  );
	t30_set_supported_resolutions(t30, T30_SUPPORT_STANDARD_RESOLUTION
								  | T30_SUPPORT_FINE_RESOLUTION
								  | T30_SUPPORT_SUPERFINE_RESOLUTION
								  | T30_SUPPORT_R16_RESOLUTION
								  |	T30_SUPPORT_R8_RESOLUTION
								  | T30_SUPPORT_300_300_RESOLUTION
								  | T30_SUPPORT_400_400_RESOLUTION
								  | T30_SUPPORT_600_600_RESOLUTION
								  |	T30_SUPPORT_1200_1200_RESOLUTION
								  |	T30_SUPPORT_300_600_RESOLUTION
								  | T30_SUPPORT_400_800_RESOLUTION
								  | T30_SUPPORT_600_1200_RESOLUTION
								  );
#if 0
	t30_set_supported_colour_resolutions(t30, 0);
#endif

	if (f_session->pvt.disable_v17) {
		t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER);
	} else {
		t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER
								 | T30_SUPPORT_V17);
	}

	if (f_session->pvt.use_ecm) {
		t30_set_ecm_capability(t30, TRUE);
		t30_set_supported_compressions(t30,
									   T30_SUPPORT_T4_1D_COMPRESSION
									   | T30_SUPPORT_T4_2D_COMPRESSION
									   | T30_SUPPORT_T6_COMPRESSION
									   | T30_SUPPORT_T85_COMPRESSION
									   | T30_SUPPORT_T85_L0_COMPRESSION);
	} else {
		t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION
									   | T30_SUPPORT_T4_2D_COMPRESSION);
	}

	if (f_session->pvt.caller) {
		t30_set_tx_file(t30, f_session->pvt.filename, -1, -1);
	} else {
		t30_set_rx_file(t30, f_session->pvt.filename, -1);
	}

	return 0;
}