Changeset 5221
Merged branch rel/1.2 into srtp_tls branch
Committed by:
wildzero-cw
Date:
Nov 03 2008 * 01:16 (2 months ago)
Affected files:
callweaver/branches/srtp_tls/apps/app_dtmftotext.c (diff)
callweaver/branches/srtp_tls/apps/app_rxfax.c (diff)
callweaver/branches/srtp_tls/apps/app_sms.c (diff)
callweaver/branches/srtp_tls/apps/app_t38gateway.c (diff)
callweaver/branches/srtp_tls/apps/app_txfax.c (diff)
callweaver/branches/srtp_tls/channels/chan_zap.c (diff)
callweaver/branches/srtp_tls/channels/fax/faxmodem.h (diff)
callweaver/branches/srtp_tls/codecs/codec_g722.c (diff)
callweaver/branches/srtp_tls/codecs/codec_g722_16k_8k.c (diff)
callweaver/branches/srtp_tls/codecs/codec_g726.c (diff)
callweaver/branches/srtp_tls/configure.ac (diff)
callweaver/branches/srtp_tls/corelib/callerid.c (diff)
callweaver/branches/srtp_tls/corelib/dsp.c (diff)
callweaver/branches/srtp_tls/corelib/udptl.c (diff)
callweaver/branches/srtp_tls/debian/callweaver.init (diff)
callweaver/branches/srtp_tls/res/res_adsi.c (diff)
callweaver/branches/srtp_tls/apps/app_dtmftotext.c (unified diff)
| r5007 | r5221 | |
|---|---|---|
| 38 | 38 | #include <sys/stat.h> |
| 39 | 39 | #include <spandsp.h> |
| 40 | 40 | |
| 41 | #include <spandsp/private/dtmf.h> | |
| 42 | #include <spandsp/dtmf.h> | |
| 43 | ||
| 41 | 44 | #include "callweaver/lock.h" |
| 42 | 45 | #include "callweaver/file.h" |
| 43 | 46 | #include "callweaver/logger.h" |
callweaver/branches/srtp_tls/apps/app_rxfax.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 22 | 22 | #include <pthread.h> |
| 23 | 23 | #include <errno.h> |
| 24 | 24 | #include <sys/time.h> |
| 25 | ||
| 26 | 25 | #include <spandsp.h> |
| 26 | #include <spandsp/expose.h> | |
| 27 | 27 | |
| 28 | 28 | #include "callweaver.h" |
| 29 | 29 | |
| --- | --- | |
| 40 | 40 | #include "callweaver/translate.h" |
| 41 | 41 | #include "callweaver/manager.h" |
| 42 | 42 | |
| 43 | static char *tdesc = "Trivial FAX Receive Application"; | |
| 43 | static const char *tdesc = "Trivial FAX Receive Application"; | |
| 44 | 44 | |
| 45 | 45 | static void *rxfax_app; |
| 46 | 46 | static const char *rxfax_name = "RxFAX"; |
| --- | --- | |
| 163 | 163 | alloc: faxgen_alloc, |
| 164 | 164 | release: faxgen_release, |
| 165 | 165 | generate: faxgen_generate, |
| 166 | } ; | |
| 166 | }; | |
| 167 | 167 | |
| 168 | 168 | /*- End of function --------------------------------------------------------*/ |
| 169 | 169 | |
| --- | --- | |
| 273 | 273 | res = 0; |
| 274 | 274 | uint64_t now; |
| 275 | 275 | uint64_t passage; |
| 276 | t30_state_t *t30; | |
| 277 | t38_core_state_t *t38_core; | |
| 276 | 278 | |
| 277 | 279 | memset(t38, 0, sizeof(*t38)); |
| 278 | 280 | |
| --- | --- | |
| 281 | 283 | cw_log(LOG_WARNING, "Unable to start T.38 termination.\n"); |
| 282 | 284 | return -1; |
| 283 | 285 | } |
| 284 | ||
| 286 | t30 = t38_terminal_get_t30_state(t38); | |
| 287 | t38_core = t38_terminal_get_t38_core_state(t38); | |
| 285 | 288 | span_log_set_message_handler(&t38->logging, span_message); |
| 286 | span_log_set_message_handler(&t38->t30_state.logging, span_message); | |
| 287 | span_log_set_message_handler(&t38->t38.logging, span_message); | |
| 289 | span_log_set_message_handler(&t30->logging, span_message); | |
| 290 | span_log_set_message_handler(&t38_core->logging, span_message); | |
| 288 | 291 | |
| 289 | 292 | if (verbose) |
| 290 | 293 | { |
| 291 | 294 | span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); |
| 292 | span_log_set_level(&t38->t30_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 293 | span_log_set_level(&t38->t38.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 295 | span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 296 | span_log_set_level(&t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 294 | 297 | } |
| 295 | 298 | |
| 296 | 299 | x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); |
| 297 | 300 | if (x && x[0]) |
| 298 | t30_set_tx_ident(&t38->t30_state, x); | |
| 301 | t30_set_tx_ident(t30, x); | |
| 302 | x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS"); | |
| 303 | if (x && x[0]) | |
| 304 | t30_set_tx_sub_address(t30, x); | |
| 299 | 305 | x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); |
| 300 | 306 | if (x && x[0]) |
| 301 | t30_set_tx_page_header_info(&t38->t30_state, x); | |
| 302 | t30_set_rx_file(&t38->t30_state, file, -1); | |
| 307 | t30_set_tx_page_header_info(t30, x); | |
| 308 | t30_set_rx_file(t30, file, -1); | |
| 303 | 309 | |
| 304 | //t30_set_phase_b_handler(&t38->t30_state, phase_b_handler, chan); | |
| 305 | t30_set_phase_d_handler(&t38->t30_state, phase_d_handler, chan); | |
| 306 | t30_set_phase_e_handler(&t38->t30_state, phase_e_handler, chan); | |
| 310 | //t30_set_phase_b_handler(t30, phase_b_handler, chan); | |
| 311 | t30_set_phase_d_handler(t30, phase_d_handler, chan); | |
| 312 | t30_set_phase_e_handler(t30, phase_e_handler, chan); | |
| 307 | 313 | |
| 308 | 314 | x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17"); |
| 309 | 315 | if (x && x[0]) |
| 310 | t30_set_supported_modems(&t38->t30_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 316 | t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 311 | 317 | else |
| 312 | t30_set_supported_modems(&t38->t30_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 318 | t30_set_supported_modems(t30, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 313 | 319 | |
| 314 | t30_set_supported_image_sizes(&t38->t30_state, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 315 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 316 | t30_set_supported_resolutions(&t38->t30_state, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 317 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 320 | t30_set_supported_image_sizes(t30, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 321 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 322 | t30_set_supported_resolutions(t30, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 323 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 318 | 324 | |
| 319 | 325 | if (ecm) { |
| 320 | t30_set_ecm_capability(&t38->t30_state, TRUE); | |
| 321 | t30_set_supported_compressions(&t38->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 326 | t30_set_ecm_capability(t30, TRUE); | |
| 327 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 322 | 328 | cw_log(LOG_DEBUG, "Enabling ECM mode for app_rxfax\n" ); |
| 323 | 329 | } |
| 324 | 330 | else |
| 325 | 331 | { |
| 326 | t30_set_supported_compressions(&t38->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION ); | |
| 332 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION ); | |
| 327 | 333 | } |
| 328 | 334 | |
| 329 | 335 | passage = nowis(); |
| --- | --- | |
| 331 | 337 | t38_terminal_set_tep_mode(t38, TRUE); |
| 332 | 338 | while (ready && ready_to_talk(chan)) |
| 333 | 339 | { |
| 334 | ||
| 335 | if ( chan->t38_status != T38_NEGOTIATED ) | |
| 340 | if (chan->t38_status != T38_NEGOTIATED) | |
| 336 | 341 | break; |
| 337 | 342 | |
| 338 | 343 | if ((res = cw_waitfor(chan, 20)) < 0) { |
| --- | --- | |
| 344 | 349 | t38_terminal_send_timeout(t38, (now - passage)/125); |
| 345 | 350 | passage = now; |
| 346 | 351 | /* End application when T38/T30 has finished */ |
| 347 | if ((t38->current_tx_type == T30_MODEM_DONE) || (t38->current_rx_type == T30_MODEM_DONE)) | |
| 352 | if (!t30_call_active(t30)) | |
| 348 | 353 | break; |
| 349 | 354 | |
| 350 | 355 | inf = cw_read(chan); |
| --- | --- | |
| 354 | 359 | } |
| 355 | 360 | |
| 356 | 361 | if (inf->frametype == CW_FRAME_MODEM && inf->subclass == CW_MODEM_T38) |
| 357 | t38_core_rx_ifp_packet(&t38->t38, inf->data, inf->datalen, inf->seq_no); | |
| 362 | t38_core_rx_ifp_packet(t38_core, inf->data, inf->datalen, inf->seq_no); | |
| 358 | 363 | |
| 359 | 364 | cw_fr_free(inf); |
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | return ready; |
| 363 | ||
| 364 | 368 | } |
| 365 | 369 | /*- End of function --------------------------------------------------------*/ |
| 366 | 370 | |
| --- | --- | |
| 378 | 382 | received_frames = 0; |
| 379 | 383 | |
| 380 | 384 | struct cw_dsp *dsp = NULL; |
| 385 | t30_state_t *t30; | |
| 381 | 386 | |
| 382 | 387 | uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET]; |
| 383 | 388 | uint8_t *buf = __buf + CW_FRIENDLY_OFFSET; |
| --- | --- | |
| 389 | 394 | cw_log(LOG_WARNING, "Unable to start FAX\n"); |
| 390 | 395 | return -1; |
| 391 | 396 | } |
| 397 | t30 = fax_get_t30_state(fax); | |
| 392 | 398 | fax_set_transmit_on_idle(fax, TRUE); |
| 393 | 399 | span_log_set_message_handler(&fax->logging, span_message); |
| 394 | span_log_set_message_handler(&fax->t30_state.logging, span_message); | |
| 400 | span_log_set_message_handler(&t30->logging, span_message); | |
| 395 | 401 | if (verbose) |
| 396 | 402 | { |
| 397 | 403 | span_log_set_level(&fax->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); |
| 398 | span_log_set_level(&fax->t30_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 404 | span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 399 | 405 | } |
| 400 | 406 | x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); |
| 401 | 407 | if (x && x[0]) |
| 402 | t30_set_tx_ident(&fax->t30_state, x); | |
| 408 | t30_set_tx_ident(t30, x); | |
| 409 | x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS"); | |
| 410 | if (x && x[0]) | |
| 411 | t30_set_tx_sub_address(t30, x); | |
| 403 | 412 | x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); |
| 404 | 413 | if (x && x[0]) |
| 405 | t30_set_tx_page_header_info(&fax->t30_state, x); | |
| 406 | t30_set_rx_file(&fax->t30_state, file, -1); | |
| 407 | //t30_set_phase_b_handler(&fax->t30_state, phase_b_handler, chan); | |
| 408 | t30_set_phase_d_handler(&fax->t30_state, phase_d_handler, chan); | |
| 409 | t30_set_phase_e_handler(&fax->t30_state, phase_e_handler, chan); | |
| 414 | t30_set_tx_page_header_info(t30, x); | |
| 415 | t30_set_rx_file(t30, file, -1); | |
| 416 | //t30_set_phase_b_handler(t30, phase_b_handler, chan); | |
| 417 | t30_set_phase_d_handler(t30, phase_d_handler, chan); | |
| 418 | t30_set_phase_e_handler(t30, phase_e_handler, chan); | |
| 410 | 419 | |
| 411 | 420 | x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17"); |
| 412 | 421 | if (x && x[0]) |
| 413 | t30_set_supported_modems(&fax->t30_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 422 | t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 414 | 423 | |
| 415 | 424 | /* Support for different image sizes && resolutions*/ |
| 416 | t30_set_supported_image_sizes(&fax->t30_state, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 417 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 418 | t30_set_supported_resolutions(&fax->t30_state, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 419 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 425 | t30_set_supported_image_sizes(t30, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 426 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 427 | t30_set_supported_resolutions(t30, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 428 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 420 | 429 | if (ecm) { |
| 421 | t30_set_ecm_capability(&fax->t30_state, TRUE); | |
| 422 | t30_set_supported_compressions(&fax->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 430 | t30_set_ecm_capability(t30, TRUE); | |
| 431 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 423 | 432 | cw_log(LOG_DEBUG, "Enabling ECM mode for app_rxfax\n" ); |
| 424 | 433 | } |
| 425 | 434 | |
| --- | --- | |
| 429 | 438 | cw_log(LOG_WARNING, "Unable to allocate DSP!\n"); |
| 430 | 439 | else { |
| 431 | 440 | cw_dsp_set_threshold(dsp, 256); |
| 432 | cw_dsp_set_features (dsp, DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_CNG_DETECT); | |
| 433 | cw_dsp_digitmode (dsp, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF); | |
| 441 | cw_dsp_set_features(dsp, DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_CNG_DETECT); | |
| 442 | cw_dsp_digitmode(dsp, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF); | |
| 434 | 443 | } |
| 435 | 444 | |
| 436 | ||
| 437 | 445 | /* This is the main loop */ |
| 438 | 446 | |
| 439 | 447 | begin = nowis(); |
| 440 | 448 | |
| 441 | while ( ready && ready_to_talk(chan) ) | |
| 449 | while (ready && ready_to_talk(chan)) | |
| 442 | 450 | { |
| 443 | ||
| 444 | if ( chan->t38_status == T38_NEGOTIATED ) | |
| 451 | if (chan->t38_status == T38_NEGOTIATED) | |
| 445 | 452 | break; |
| 446 | 453 | |
| 447 | 454 | if ((res = cw_waitfor(chan, 20)) < 0) { |
| --- | --- | |
| 449 | 456 | break; |
| 450 | 457 | } |
| 451 | 458 | |
| 452 | if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE)) | |
| 459 | if (!t30_call_active(t30)) | |
| 453 | 460 | break; |
| 454 | 461 | |
| 455 | 462 | inf = cw_read(chan); |
| --- | --- | |
| 539 | 546 | |
| 540 | 547 | cw_generator_activate(chan, &faxgen, fax); |
| 541 | 548 | |
| 542 | while ( ready && ready_to_talk(chan) ) { | |
| 549 | while (ready && ready_to_talk(chan)) { | |
| 543 | 550 | |
| 544 | if ( chan->t38_status == T38_NEGOTIATED ) | |
| 551 | if (chan->t38_status == T38_NEGOTIATED) | |
| 545 | 552 | break; |
| 546 | 553 | |
| 547 | 554 | if ((res = cw_waitfor(chan, 20)) < 0) { |
| --- | --- | |
| 549 | 556 | break; |
| 550 | 557 | } |
| 551 | 558 | |
| 552 | if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE)) | |
| 559 | if (!t30_call_active(t30)) | |
| 553 | 560 | break; |
| 554 | 561 | |
| 555 | 562 | inf = cw_read(chan); |
| --- | --- | |
| 577 | 584 | dspf = NULL; |
| 578 | 585 | } |
| 579 | 586 | |
| 580 | ||
| 581 | 587 | if (fax_rx(fax, inf->data, inf->samples)) { |
| 582 | 588 | ready = 0; |
| 583 | 589 | break; |
| --- | --- | |
| 594 | 600 | } |
| 595 | 601 | |
| 596 | 602 | cw_generator_deactivate(chan); |
| 597 | ||
| 598 | 603 | } |
| 599 | 604 | |
| 600 | 605 | return ready; |
| --- | --- | |
| 603 | 608 | |
| 604 | 609 | static int rxfax_exec(struct cw_channel *chan, int argc, char **argv) |
| 605 | 610 | { |
| 606 | fax_state_t fax; | |
| 611 | fax_state_t fax; | |
| 607 | 612 | t38_terminal_state_t t38; |
| 613 | t30_state_t *t30; | |
| 608 | 614 | |
| 609 | 615 | int res = 0; |
| 610 | 616 | char target_file[256]; |
| --- | --- | |
| 711 | 717 | |
| 712 | 718 | ready = TRUE; |
| 713 | 719 | |
| 714 | while ( ready && ready_to_talk(chan) ) | |
| 720 | if (chan->t38_status == T38_NEGOTIATED) | |
| 721 | t30 = t38_terminal_get_t30_state(&t38); | |
| 722 | else | |
| 723 | t30 = fax_get_t30_state(&fax); | |
| 724 | while (ready && ready_to_talk(chan)) | |
| 715 | 725 | { |
| 716 | ||
| 717 | ||
| 718 | if ( ready && chan->t38_status != T38_NEGOTIATED ) { | |
| 719 | ready = rxfax_audio( chan, &fax, target_file, calling_party, verbose, ecm); | |
| 726 | if (ready && chan->t38_status != T38_NEGOTIATED) { | |
| 727 | t30 = fax_get_t30_state(&fax); | |
| 728 | ready = rxfax_audio(chan, &fax, target_file, calling_party, verbose, ecm); | |
| 720 | 729 | } |
| 721 | 730 | |
| 722 | if ( ready && chan->t38_status == T38_NEGOTIATED ) { | |
| 723 | ready = rxfax_t38 ( chan, &t38, target_file, calling_party, verbose, ecm); | |
| 731 | if (ready && chan->t38_status == T38_NEGOTIATED) { | |
| 732 | t30 = t38_terminal_get_t30_state(&t38); | |
| 733 | ready = rxfax_t38(chan, &t38, target_file, calling_party, verbose, ecm); | |
| 724 | 734 | } |
| 725 | 735 | |
| 726 | if ( chan->t38_status != T38_NEGOTIATING ) | |
| 727 | ready = 0; // 1 loop is enough. This could be useful if we want to turn from udptl to RTP later. | |
| 728 | ||
| 736 | if (chan->t38_status != T38_NEGOTIATING) | |
| 737 | ready = FALSE; // 1 loop is enough. This could be useful if we want to turn from udptl to RTP later. | |
| 729 | 738 | } |
| 730 | 739 | |
| 731 | if (chan->t38_status == T38_NEGOTIATED) | |
| 732 | t30_terminate(&t38.t30_state); | |
| 733 | else | |
| 734 | t30_terminate(&fax.t30_state); | |
| 740 | t30_terminate(t30); | |
| 735 | 741 | |
| 736 | 742 | fax_release(&fax); |
| 737 | 743 | t38_terminal_release(&t38); |
| 738 | 744 | |
| 745 | /* Maybe we should restore gain and echo cancel settings here? */ | |
| 746 | ||
| 739 | 747 | /* Restoring initial channel formats. */ |
| 740 | 748 | |
| 741 | 749 | if (original_read_fmt != CW_FORMAT_SLINEAR) |
callweaver/branches/srtp_tls/apps/app_sms.c (unified diff)
| r4739 | r5221 | |
|---|---|---|
| 37 | 37 | #include <sys/types.h> |
| 38 | 38 | #include <sys/stat.h> |
| 39 | 39 | #include <spandsp.h> |
| 40 | #include <spandsp/expose.h> | |
| 40 | 41 | |
| 41 | 42 | #include "callweaver/lock.h" |
| 42 | 43 | #include "callweaver/file.h" |
callweaver/branches/srtp_tls/apps/app_t38gateway.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 28 | 28 | #include <unistd.h> |
| 29 | 29 | #include <tiffio.h> |
| 30 | 30 | #include <spandsp.h> |
| 31 | #include <spandsp/expose.h> | |
| 31 | 32 | |
| 32 | 33 | #include "callweaver/file.h" |
| 33 | 34 | #include "callweaver/logger.h" |
| --- | --- | |
| 151 | 152 | |
| 152 | 153 | f->tx_copies = 1; /* TODO: this is only needed because not everything sets the tx_copies field properly */ |
| 153 | 154 | |
| 154 | if ( ( chan->t38_status == T38_NEGOTIATING ) || ( peer->t38_status == T38_NEGOTIATING ) ) { | |
| 155 | if ((chan->t38_status == T38_NEGOTIATING) || (peer->t38_status == T38_NEGOTIATING)) { | |
| 155 | 156 | /* TODO |
| 156 | 157 | This is a very BASIC method to mute a channel. It should be improved |
| 157 | 158 | and we should send EMPTY frames (not just avoid sending them) |
| --- | --- | |
| 216 | 217 | |
| 217 | 218 | /* Check if we need to change to gateway operation */ |
| 218 | 219 | if ( |
| 219 | ( chan->t38_status != T38_NEGOTIATING ) | |
| 220 | && ( peer->t38_status != T38_NEGOTIATING ) | |
| 221 | && ( chan->t38_status != peer->t38_status) | |
| 220 | (chan->t38_status != T38_NEGOTIATING) | |
| 221 | && (peer->t38_status != T38_NEGOTIATING) | |
| 222 | && (chan->t38_status != peer->t38_status) | |
| 222 | 223 | ) { |
| 223 | 224 | cw_log(LOG_DEBUG, "Stop bridging frames. [ %d,%d]\n", chan->t38_status, peer->t38_status); |
| 224 | 225 | running = RUNNING; |
| --- | --- | |
| 270 | 271 | t38_gateway_state_t t38_state; |
| 271 | 272 | uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET]; |
| 272 | 273 | uint8_t *buf = __buf + CW_FRIENDLY_OFFSET; |
| 274 | t38_core_state_t *t38_core; | |
| 273 | 275 | |
| 274 | 276 | if (chan->t38_status == T38_NEGOTIATED) |
| 275 | 277 | { |
| --- | --- | |
| 284 | 286 | |
| 285 | 287 | original_read_fmt = channels[1]->readformat; |
| 286 | 288 | original_write_fmt = channels[1]->writeformat; |
| 287 | if ( channels[1]->t38_status != T38_NEGOTIATED) | |
| 289 | if (channels[1]->t38_status != T38_NEGOTIATED) | |
| 288 | 290 | { |
| 289 | 291 | if (original_read_fmt != CW_FORMAT_SLINEAR) |
| 290 | 292 | { |
| --- | --- | |
| 312 | 314 | return -1; |
| 313 | 315 | } |
| 314 | 316 | t38_gateway_set_transmit_on_idle(&t38_state, TRUE); |
| 317 | t38_core = t38_gateway_get_t38_core_state(&t38_state); | |
| 315 | 318 | x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17"); |
| 316 | 319 | if (x && x[0]) |
| 317 | 320 | t38_gateway_set_supported_modems(&t38_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); |
| --- | --- | |
| 319 | 322 | t38_gateway_set_supported_modems(&t38_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); |
| 320 | 323 | |
| 321 | 324 | span_log_set_message_handler(&t38_state.logging, span_message); |
| 322 | span_log_set_message_handler(&t38_state.t38.logging, span_message); | |
| 325 | span_log_set_message_handler(&t38_core->logging, span_message); | |
| 323 | 326 | if (verbose) |
| 324 | 327 | { |
| 325 | 328 | span_log_set_level(&t38_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); |
| 326 | span_log_set_level(&t38_state.t38.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 329 | span_log_set_level(&t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 327 | 330 | } |
| 328 | t38_set_t38_version(&t38_state.t38, 0); | |
| 331 | t38_set_t38_version(t38_core, 0); | |
| 329 | 332 | t38_gateway_set_ecm_capability(&t38_state, 1); |
| 330 | 333 | |
| 331 | ||
| 332 | 334 | while (running == RUNNING && (running = ready_to_talk(channels[0], channels[1]))) |
| 333 | 335 | { |
| 334 | 336 | //cw_log(LOG_NOTICE, "gw: t38status: [%d,%d]\n", chan->t38_status, peer->t38_status); |
| 335 | 337 | if ( |
| 336 | ( chan->t38_status == T38_NEGOTIATED ) | |
| 337 | && ( peer->t38_status == T38_NEGOTIATED ) | |
| 338 | ) { | |
| 338 | (chan->t38_status == T38_NEGOTIATED) | |
| 339 | && (peer->t38_status == T38_NEGOTIATED)) | |
| 340 | { | |
| 339 | 341 | cw_log(LOG_DEBUG, "Stop gateway-ing frames (both channels are in t38 mode). [ %d,%d]\n", chan->t38_status, peer->t38_status); |
| 340 | 342 | running = RUNNING; |
| 341 | 343 | break; |
| --- | --- | |
| 347 | 349 | { |
| 348 | 350 | if ((f = cw_read(active))) |
| 349 | 351 | { |
| 350 | t38_core_rx_ifp_packet(&t38_state.t38, f->data, f->datalen, f->seq_no); | |
| 352 | t38_core_rx_ifp_packet(t38_core, f->data, f->datalen, f->seq_no); | |
| 351 | 353 | clean_frame(f); |
| 352 | 354 | } |
| 353 | 355 | else |
| --- | --- | |
| 621 | 623 | |
| 622 | 624 | res = RUNNING; |
| 623 | 625 | |
| 624 | while ( res == RUNNING ) { | |
| 626 | while (res == RUNNING) { | |
| 625 | 627 | |
| 626 | if ( res && ( chan->t38_status == peer->t38_status ) ) | |
| 628 | if (res && (chan->t38_status == peer->t38_status)) | |
| 627 | 629 | { |
| 628 | 630 | // Same on both sides, so just bridge |
| 629 | 631 | cw_log(LOG_DEBUG, "Bridging frames [ %d,%d]\n", chan->t38_status, peer->t38_status); |
| --- | --- | |
| 631 | 633 | } |
| 632 | 634 | |
| 633 | 635 | if ( |
| 634 | ( res == RUNNING ) | |
| 635 | && ( ( chan->t38_status == T38_STATUS_UNKNOWN ) || ( peer->t38_status == T38_STATUS_UNKNOWN ) ) | |
| 636 | && ( chan->t38_status != peer->t38_status ) | |
| 636 | (res == RUNNING) | |
| 637 | && ((chan->t38_status == T38_STATUS_UNKNOWN) || (peer->t38_status == T38_STATUS_UNKNOWN)) | |
| 638 | && (chan->t38_status != peer->t38_status) | |
| 637 | 639 | ) |
| 638 | 640 | { |
| 639 | 641 | // Different on each side, so gateway |
callweaver/branches/srtp_tls/apps/app_txfax.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 22 | 22 | #include <pthread.h> |
| 23 | 23 | #include <errno.h> |
| 24 | 24 | #include <sys/time.h> |
| 25 | ||
| 26 | 25 | #include <spandsp.h> |
| 26 | #include <spandsp/expose.h> | |
| 27 | 27 | |
| 28 | 28 | #include "callweaver.h" |
| 29 | 29 | |
| --- | --- | |
| 242 | 242 | res = 0; |
| 243 | 243 | uint64_t now; |
| 244 | 244 | uint64_t passage; |
| 245 | t30_state_t *t30; | |
| 246 | t38_core_state_t *t38_core; | |
| 245 | 247 | |
| 246 | 248 | memset(t38, 0, sizeof(*t38)); |
| 247 | 249 | |
| --- | --- | |
| 250 | 252 | cw_log(LOG_WARNING, "Unable to start T.38 termination.\n"); |
| 251 | 253 | return -1; |
| 252 | 254 | } |
| 253 | ||
| 255 | t30 = t38_terminal_get_t30_state(t38); | |
| 256 | t38_core = t38_terminal_get_t38_core_state(t38); | |
| 254 | 257 | span_log_set_message_handler(&t38->logging, span_message); |
| 255 | span_log_set_message_handler(&t38->t30_state.logging, span_message); | |
| 256 | span_log_set_message_handler(&t38->t38.logging, span_message); | |
| 258 | span_log_set_message_handler(&t30->logging, span_message); | |
| 259 | span_log_set_message_handler(&t38_core->logging, span_message); | |
| 257 | 260 | |
| 258 | 261 | if (verbose) |
| 259 | 262 | { |
| 260 | 263 | span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); |
| 261 | span_log_set_level(&t38->t30_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 262 | span_log_set_level(&t38->t38.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 264 | span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 265 | span_log_set_level(&t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 263 | 266 | } |
| 264 | 267 | |
| 265 | 268 | x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); |
| 266 | 269 | if (x && x[0]) |
| 267 | t30_set_tx_ident(&t38->t30_state, x); | |
| 270 | t30_set_tx_ident(t30, x); | |
| 268 | 271 | x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS"); |
| 269 | 272 | if (x && x[0]) |
| 270 | t30_set_tx_sub_address(&t38->t30_state, x); | |
| 273 | t30_set_tx_sub_address(t30, x); | |
| 271 | 274 | x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); |
| 272 | 275 | if (x && x[0]) |
| 273 | t30_set_tx_page_header_info(&t38->t30_state, x); | |
| 274 | t30_set_tx_file(&t38->t30_state, source_file, -1, -1); | |
| 276 | t30_set_tx_page_header_info(t30, x); | |
| 277 | t30_set_tx_file(t30, source_file, -1, -1); | |
| 275 | 278 | |
| 276 | //t30_set_phase_b_handler(&t38.t30_state, phase_b_handler, chan); | |
| 277 | //t30_set_phase_d_handler(&t38.t30_state, phase_d_handler, chan); | |
| 278 | t30_set_phase_e_handler(&t38->t30_state, phase_e_handler, chan); | |
| 279 | //t30_set_phase_b_handler(t30, phase_b_handler, chan); | |
| 280 | //t30_set_phase_d_handler(t30, phase_d_handler, chan); | |
| 281 | t30_set_phase_e_handler(t30, phase_e_handler, chan); | |
| 279 | 282 | |
| 280 | 283 | x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17"); |
| 281 | 284 | if (x && x[0]) |
| 282 | t30_set_supported_modems(&t38->t30_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 285 | t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 283 | 286 | else |
| 284 | t30_set_supported_modems(&t38->t30_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 287 | t30_set_supported_modems(t30, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 285 | 288 | |
| 286 | t30_set_supported_image_sizes(&t38->t30_state, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 287 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 288 | t30_set_supported_resolutions(&t38->t30_state, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 289 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 289 | t30_set_supported_image_sizes(t30, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 290 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 291 | t30_set_supported_resolutions(t30, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 292 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 290 | 293 | |
| 291 | 294 | if (ecm) { |
| 292 | t30_set_ecm_capability(&t38->t30_state, TRUE); | |
| 293 | t30_set_supported_compressions(&t38->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 295 | t30_set_ecm_capability(t30, TRUE); | |
| 296 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 294 | 297 | cw_log(LOG_DEBUG, "Enabling ECM mode for app_txfax\n" ); |
| 295 | 298 | } |
| 296 | 299 | else |
| 297 | 300 | { |
| 298 | t30_set_supported_compressions(&t38->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION ); | |
| 301 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION ); | |
| 299 | 302 | } |
| 300 | 303 | |
| 301 | 304 | passage = nowis(); |
| --- | --- | |
| 316 | 319 | t38_terminal_send_timeout(t38, (now - passage)/125); |
| 317 | 320 | passage = now; |
| 318 | 321 | /* End application when T38/T30 has finished */ |
| 319 | if ((t38->current_rx_type == T30_MODEM_DONE) || (t38->current_tx_type == T30_MODEM_DONE)) | |
| 322 | if (!t30_call_active(t30)) | |
| 320 | 323 | break; |
| 321 | 324 | |
| 322 | 325 | inf = cw_read(chan); |
| --- | --- | |
| 326 | 329 | } |
| 327 | 330 | |
| 328 | 331 | if (inf->frametype == CW_FRAME_MODEM && inf->subclass == CW_MODEM_T38) |
| 329 | t38_core_rx_ifp_packet(&t38->t38, inf->data, inf->datalen, inf->seq_no); | |
| 332 | t38_core_rx_ifp_packet(t38_core, inf->data, inf->datalen, inf->seq_no); | |
| 330 | 333 | |
| 331 | 334 | cw_fr_free(inf); |
| 332 | 335 | } |
| --- | --- | |
| 347 | 350 | generator_mode = 0; |
| 348 | 351 | uint64_t begin = 0, |
| 349 | 352 | received_frames = 0; |
| 350 | ||
| 351 | 353 | uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET]; |
| 352 | 354 | uint8_t *buf = __buf + CW_FRIENDLY_OFFSET; |
| 355 | t30_state_t *t30; | |
| 353 | 356 | |
| 354 | 357 | memset(fax, 0, sizeof(*fax)); |
| 355 | 358 | |
| --- | --- | |
| 359 | 362 | return -1; |
| 360 | 363 | } |
| 361 | 364 | fax_set_transmit_on_idle(fax, TRUE); |
| 365 | t30 = fax_get_t30_state(fax); | |
| 362 | 366 | span_log_set_message_handler(&fax->logging, span_message); |
| 363 | span_log_set_message_handler(&fax->t30_state.logging, span_message); | |
| 367 | span_log_set_message_handler(&t30->logging, span_message); | |
| 364 | 368 | if (verbose) |
| 365 | 369 | { |
| 366 | 370 | span_log_set_level(&fax->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); |
| 367 | span_log_set_level(&fax->t30_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 371 | span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); | |
| 368 | 372 | } |
| 369 | 373 | x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); |
| 370 | 374 | if (x && x[0]) |
| 371 | t30_set_tx_ident(&fax->t30_state, x); | |
| 375 | t30_set_tx_ident(t30, x); | |
| 372 | 376 | x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS"); |
| 373 | 377 | if (x && x[0]) |
| 374 | t30_set_tx_sub_address(&fax->t30_state, x); | |
| 378 | t30_set_tx_sub_address(t30, x); | |
| 375 | 379 | x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); |
| 376 | 380 | if (x && x[0]) |
| 377 | t30_set_tx_page_header_info(&fax->t30_state, x); | |
| 378 | t30_set_tx_file(&fax->t30_state, source_file, -1, -1); | |
| 379 | //t30_set_phase_b_handler(&fax.t30_state, phase_b_handler, chan); | |
| 380 | //t30_set_phase_d_handler(&fax.t30_state, phase_d_handler, chan); | |
| 381 | t30_set_phase_e_handler(&fax->t30_state, phase_e_handler, chan); | |
| 381 | t30_set_tx_page_header_info(t30, x); | |
| 382 | t30_set_tx_file(t30, source_file, -1, -1); | |
| 383 | //t30_set_phase_b_handler(t30, phase_b_handler, chan); | |
| 384 | //t30_set_phase_d_handler(t30, phase_d_handler, chan); | |
| 385 | t30_set_phase_e_handler(t30, phase_e_handler, chan); | |
| 382 | 386 | |
| 383 | 387 | x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17"); |
| 384 | 388 | if (x && x[0]) |
| 385 | t30_set_supported_modems(&fax->t30_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 389 | t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); | |
| 386 | 390 | |
| 387 | 391 | /* Support for different image sizes && resolutions*/ |
| 388 | t30_set_supported_image_sizes(&fax->t30_state, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 389 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 390 | t30_set_supported_resolutions(&fax->t30_state, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 391 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 392 | t30_set_supported_image_sizes(t30, T30_SUPPORT_US_LETTER_LENGTH | T30_SUPPORT_US_LEGAL_LENGTH | T30_SUPPORT_UNLIMITED_LENGTH | |
| 393 | | T30_SUPPORT_215MM_WIDTH | T30_SUPPORT_255MM_WIDTH | T30_SUPPORT_303MM_WIDTH); | |
| 394 | t30_set_supported_resolutions(t30, T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | |
| 395 | | T30_SUPPORT_R8_RESOLUTION | T30_SUPPORT_R16_RESOLUTION); | |
| 392 | 396 | if (ecm) { |
| 393 | t30_set_ecm_capability(&fax->t30_state, TRUE); | |
| 394 | t30_set_supported_compressions(&fax->t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 397 | t30_set_ecm_capability(t30, TRUE); | |
| 398 | t30_set_supported_compressions(t30, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); | |
| 395 | 399 | cw_log(LOG_DEBUG, "Enabling ECM mode for app_txfax\n" ); |
| 396 | 400 | } |
| 397 | 401 | |
| --- | --- | |
| 410 | 414 | break; |
| 411 | 415 | } |
| 412 | 416 | |
| 413 | if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE)) | |
| 417 | if (!t30_call_active(t30)) | |
| 414 | 418 | break; |
| 415 | 419 | |
| 416 | 420 | inf = cw_read(chan); |
| --- | --- | |
| 490 | 494 | break; |
| 491 | 495 | } |
| 492 | 496 | |
| 493 | if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE)) | |
| 497 | if (!t30_call_active(t30)) | |
| 494 | 498 | break; |
| 495 | 499 | |
| 496 | 500 | inf = cw_read(chan); |
| --- | --- | |
| 540 | 544 | |
| 541 | 545 | int original_read_fmt; |
| 542 | 546 | int original_write_fmt; |
| 547 | t30_state_t *t30; | |
| 543 | 548 | |
| 544 | 549 | /* Basic initial checkings */ |
| 545 | 550 | |
| --- | --- | |
| 643 | 648 | } |
| 644 | 649 | } |
| 645 | 650 | |
| 646 | ||
| 647 | 651 | /* This is the main loop */ |
| 648 | 652 | |
| 649 | 653 | ready = TRUE; |
| 650 | 654 | |
| 651 | while ( ready && ready_to_talk(chan) ) | |
| 655 | if (chan->t38_status == T38_NEGOTIATED) | |
| 656 | t30 = t38_terminal_get_t30_state(&t38); | |
| 657 | else | |
| 658 | t30 = fax_get_t30_state(&fax); | |
| 659 | while (ready && ready_to_talk(chan)) | |
| 652 | 660 | { |
| 653 | ||
| 654 | ||
| 655 | if ( ready && chan->t38_status != T38_NEGOTIATED ) { | |
| 656 | ready = txfax_audio( chan, &fax, source_file, calling_party, verbose, ecm); | |
| 661 | if (ready && chan->t38_status != T38_NEGOTIATED) | |
| 662 | { | |
| 663 | t30 = fax_get_t30_state(&fax); | |
| 664 | ready = txfax_audio(chan, &fax, source_file, calling_party, verbose, ecm); | |
| 657 | 665 | } |
| 658 | 666 | |
| 659 | if ( ready && chan->t38_status == T38_NEGOTIATED ) { | |
| 660 | ready = txfax_t38 ( chan, &t38, source_file, calling_party, verbose, ecm); | |
| 667 | if ( ready && chan->t38_status == T38_NEGOTIATED) | |
| 668 | { | |
| 669 | t30 = t38_terminal_get_t30_state(&t38); | |
| 670 | ready = txfax_t38(chan, &t38, source_file, calling_party, verbose, ecm); | |
| 661 | 671 | } |
| 662 | 672 | |
| 663 | if ( chan->t38_status != T38_NEGOTIATING ) | |
| 664 | ready = 0; // 1 loop is enough. This could be useful if we want to turn from udptl to RTP later. | |
| 665 | ||
| 673 | if (chan->t38_status != T38_NEGOTIATING) | |
| 674 | ready = FALSE; // 1 loop is enough. This could be useful if we want to turn from udptl to RTP later. | |
| 666 | 675 | } |
| 667 | 676 | |
| 668 | if (chan->t38_status == T38_NEGOTIATED) | |
| 669 | t30_terminate(&t38.t30_state); | |
| 670 | else | |
| 671 | t30_terminate(&fax.t30_state); | |
| 677 | t30_terminate(t30); | |
| 672 | 678 | |
| 673 | 679 | fax_release(&fax); |
| 674 | 680 | t38_terminal_release(&t38); |
| --- | --- | |
| 687 | 693 | } |
| 688 | 694 | |
| 689 | 695 | return ready; |
| 690 | ||
| 691 | 696 | } |
| 692 | 697 | /*- End of function --------------------------------------------------------*/ |
| 693 | 698 | |
| 694 | 699 | int unload_module(void) |
| 695 | 700 | { |
| 696 | 701 | int res = 0; |
| 702 | ||
| 697 | 703 | STANDARD_HANGUP_LOCALUSERS; |
| 698 | 704 | res |= cw_unregister_application(txfax_app); |
| 699 | 705 | return res; |
callweaver/branches/srtp_tls/channels/chan_zap.c (unified diff)
| r4979 | r5221 | |
|---|---|---|
| 40 | 40 | #include <unistd.h> |
| 41 | 41 | #include <sys/ioctl.h> |
| 42 | 42 | #include <spandsp.h> |
| 43 | #include <spandsp/expose.h> | |
| 43 | 44 | |
| 44 | ||
| 45 | 45 | #include <math.h> |
| 46 | 46 | #include ZAPTEL_H |
| 47 | 47 | #include TONEZONE_H |
callweaver/branches/srtp_tls/channels/fax/faxmodem.h (unified diff)
| r4761 | r5221 | |
|---|---|---|
| 32 | 32 | #include <inttypes.h> |
| 33 | 33 | #include <tiffio.h> |
| 34 | 34 | #include <spandsp.h> |
| 35 | #include <spandsp/expose.h> | |
| 35 | 36 | |
| 36 | 37 | typedef enum { |
| 37 | 38 | FAXMODEM_STATE_INIT, |
callweaver/branches/srtp_tls/codecs/codec_g722.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 35 | 35 | #include <string.h> |
| 36 | 36 | #include <unistd.h> |
| 37 | 37 | #include <spandsp.h> |
| 38 | #include <spandsp/expose.h> | |
| 38 | 39 | |
| 39 | 40 | #include "callweaver.h" |
| 40 | 41 |
callweaver/branches/srtp_tls/codecs/codec_g722_16k_8k.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 35 | 35 | #include <string.h> |
| 36 | 36 | #include <unistd.h> |
| 37 | 37 | #include <spandsp.h> |
| 38 | #include <spandsp/expose.h> | |
| 38 | 39 | |
| 39 | 40 | #include "callweaver.h" |
| 40 | 41 |
callweaver/branches/srtp_tls/codecs/codec_g726.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 35 | 35 | #include <string.h> |
| 36 | 36 | #include <unistd.h> |
| 37 | 37 | #include <spandsp.h> |
| 38 | #include <spandsp/expose.h> | |
| 38 | 39 | |
| 39 | 40 | #include "callweaver.h" |
| 40 | 41 |
callweaver/branches/srtp_tls/configure.ac (unified diff)
| r5153 | r5221 | |
|---|---|---|
| 777 | 777 | [AC_HELP_STRING([--with-spandsp-libs],[Location of SpanDSP library files.])], |
| 778 | 778 | [LDFLAGS="$LDFLAGS -L${withval}"]) |
| 779 | 779 | |
| 780 | AC_CHECK_HEADERS([spandsp.h],[HAVE_SPANDSP_H=1],[AC_MSG_ERROR(SpanDSP version 0.0.5pre4 or newer is required to compile CallWeaver.)]) | |
| 780 | AC_CHECK_HEADERS([spandsp.h],[HAVE_SPANDSP_H=1],[AC_MSG_ERROR(SpanDSP version 0.0.6pre2 or newer is required to compile CallWeaver.)]) | |
| 781 | 781 | |
| 782 | AC_CHECK_HEADERS([spandsp/version.h],[HAVE_SPANDSP_VERSION_H=1],[AC_MSG_ERROR(SpanDSP does not appear to be new enough. You must have version 0.0.5pre4 or newer to compile CallWeaver.)], | |
| 782 | AC_CHECK_HEADERS([spandsp/version.h],[HAVE_SPANDSP_VERSION_H=1],[AC_MSG_ERROR(SpanDSP does not appear to be new enough. You must have version 0.0.6pre2 or newer to compile CallWeaver.)], | |
| 783 | 783 | [#ifdef HAVE_SPANDSP_H |
| 784 | 784 | #include <spandsp.h> |
| 785 | 785 | #endif |
| 786 | 786 | #include <spandsp/version.h> |
| 787 | 787 | |
| 788 | #if SPANDSP_RELEASE_DATE < 20080616 | |
| 788 | #if SPANDSP_RELEASE_DATE < 20081018 | |
| 789 | 789 | |
| 790 | 790 | #error |
| 791 | 791 | #endif |
callweaver/branches/srtp_tls/corelib/callerid.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 1 | /* Temporary things, until everyone is using the latest spandsp */ | |
| 2 | #if !defined(CLIP_DTMF_C_TERMINATED) | |
| 3 | #define CLIP_DTMF_C_TERMINATED 'C' | |
| 4 | #endif | |
| 5 | #if !defined(CLIP_DTMF_HASH_TERMINATED) | |
| 6 | #define CLIP_DTMF_HASH_TERMINATED '#' | |
| 7 | #endif | |
| 8 | #if !defined(CLIP_DTMF_C_CALLER_NUMBER) | |
| 9 | #define CLIP_DTMF_C_CALLER_NUMBER CLIP_DTMF_CALLER_NUMBER | |
| 10 | #define adsi_tx_set_preamble(a,b,c,d,e) /**/ | |
| 11 | #endif | |
| 12 | ||
| 13 | 1 | /* |
| 14 | 2 | * CallWeaver -- An open source telephony toolkit. |
| 15 | 3 | * |
| --- | --- | |
| 46 | 34 | #include <math.h> |
| 47 | 35 | #include <ctype.h> |
| 48 | 36 | #include <spandsp.h> |
| 37 | #include <spandsp/expose.h> | |
| 49 | 38 | |
| 50 | 39 | #include "callweaver.h" |
| 51 | 40 | |
| --- | --- | |
| 149 | 138 | int mate_generate(uint8_t *outbuf, int outlen, const char *msg, int codec) |
| 150 | 139 | { |
| 151 | 140 | int16_t lin[MAX_CALLERID_SIZE]; |
| 141 | adsi_tx_state_t adsi; | |
| 152 | 142 | int slen; |
| 153 | 143 | |
| 154 | adsi_tx_state_t adsi; | |
| 155 | 144 | adsi_tx_init(&adsi, ADSI_STANDARD_CLASS); |
| 156 | ||
| 157 | /* FIXME: mate formatting should really be implemented in spandsp | |
| 158 | * rather than mucking around under the hood here | |
| 159 | */ | |
| 160 | for (adsi.msg_len = 0; msg[adsi.msg_len]; adsi.msg_len++) | |
| 161 | adsi.msg[adsi.msg_len] = msg[adsi.msg_len]; | |
| 162 | 145 | adsi_tx_set_preamble(&adsi, 0, 80, -1, -1); |
| 163 | 146 | |
| 147 | adsi_tx_put_message(&adsi, (const uint8_t *) msg, strlen(msg)); | |
| 164 | 148 | slen = adsi_tx(&adsi, lin, sizeof(lin)/sizeof(lin[0])); |
| 165 | 149 | return lin2xlaw(codec, lin, slen, outbuf, outlen); |
| 166 | 150 | } |
callweaver/branches/srtp_tls/corelib/dsp.c (unified diff)
| r4933 | r5221 | |
|---|---|---|
| 35 | 35 | #include <errno.h> |
| 36 | 36 | #include <stdio.h> |
| 37 | 37 | #include <spandsp.h> |
| 38 | #include <spandsp/expose.h> | |
| 38 | 39 | |
| 39 | 40 | #include "callweaver.h" |
| 40 | 41 |
callweaver/branches/srtp_tls/corelib/udptl.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 705 | 705 | { |
| 706 | 706 | int res; |
| 707 | 707 | int actions; |
| 708 | struct sockaddr_in original_dest; | |
| 708 | 709 | struct sockaddr_in sin; |
| 709 | 710 | socklen_t len; |
| 710 | 711 | char iabuf[INET_ADDRSTRLEN]; |
| --- | --- | |
| 713 | 714 | |
| 714 | 715 | len = sizeof(sin); |
| 715 | 716 | |
| 717 | memcpy(&original_dest, udp_socket_get_them(udptl->udptl_sock_info), sizeof(original_dest)); | |
| 718 | ||
| 716 | 719 | /* Cache where the header will go */ |
| 717 | 720 | res = udp_socket_recvfrom(udptl->udptl_sock_info, |
| 718 | 721 | udptl->rawdata + CW_FRIENDLY_OFFSET, |
| --- | --- | |
| 750 | 753 | #if 0 |
| 751 | 754 | printf("Got UDPTL packet from %s:%d (len %d)\n", cw_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), res); |
| 752 | 755 | #endif |
| 753 | udptl_rx_packet(udptl, udptl->rawdata + CW_FRIENDLY_OFFSET, res); | |
| 756 | /* If its not a valid UDPTL packet, restore the original port */ | |
| 757 | if (udptl_rx_packet(udptl, udptl->rawdata + CW_FRIENDLY_OFFSET, res) < 0) | |
| 758 | udp_socket_set_them(udptl->udptl_sock_info, &original_dest); | |
| 754 | 759 | |
| 755 | 760 | return &udptl->f[0]; |
| 756 | 761 | } |
callweaver/branches/srtp_tls/debian/callweaver.init (unified diff)
| r2720 | r5221 | |
|---|---|---|
| 16 | 16 | # |
| 17 | 17 | # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl |
| 18 | 18 | # |
| 19 | ### BEGIN INIT INFO | |
| 20 | # Provides: callweaver | |
| 21 | # Required-Start: $network $local_fs $remote_fs | |
| 22 | # Required-Stop: | |
| 23 | # Default-Start: 2 3 4 5 | |
| 24 | # Default-Stop: 0 1 6 | |
| 25 | # Short-Description: init-Script for callweaver daemon | |
| 26 | ### END INIT INFO | |
| 19 | 27 | |
| 20 | 28 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 21 | 29 | NAME=callweaver |
callweaver/branches/srtp_tls/res/res_adsi.c (unified diff)
| r4723 | r5221 | |
|---|---|---|
| 1 | /* Temporary things, until everyone is using the latest spandsp */ | |
| 2 | #if !defined(CLIP_DTMF_C_TERMINATED) | |
| 3 | #define CLIP_DTMF_C_TERMINATED 'C' | |
| 4 | #endif | |
| 5 | #if !defined(CLIP_DTMF_HASH_TERMINATED) | |
| 6 | #define CLIP_DTMF_HASH_TERMINATED '#' | |
| 7 | #endif | |
| 8 | #if !defined(CLIP_DTMF_C_CALLER_NUMBER) | |
| 9 | #define CLIP_DTMF_C_CALLER_NUMBER CLIP_DTMF_CALLER_NUMBER | |
| 10 | #define adsi_tx_set_preamble(a,b,c,d,e) /**/ | |
| 11 | #endif | |
| 12 | ||
| 13 | 1 | /* |
| 14 | 2 | * CallWeaver -- An open source telephony toolkit. |
| 15 | 3 | * |
| --- | --- | |
| 48 | 36 | #include <math.h> |
| 49 | 37 | #include <errno.h> |
| 50 | 38 | #include <spandsp.h> |
| 51 | #include <spandsp/adsi.h> | |
| 39 | #include <spandsp/expose.h> | |
| 52 | 40 | |
| 53 | 41 | #include "callweaver.h" |
| 54 | 42 |
![Home changeset 5221 [home]](/images/logo.png?1180520111)
RSS Feeds