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 (unified diff)

r5007r5221
3838 #include <sys/stat.h>
3939 #include <spandsp.h>
4040
41 #include <spandsp/private/dtmf.h>
42 #include <spandsp/dtmf.h>
43
4144 #include "callweaver/lock.h"
4245 #include "callweaver/file.h"
4346 #include "callweaver/logger.h"

callweaver/branches/srtp_tls/apps/app_rxfax.c (unified diff)

r4723r5221
2222 #include <pthread.h>
2323 #include <errno.h>
2424 #include <sys/time.h>
25
2625 #include <spandsp.h>
26 #include <spandsp/expose.h>
2727
2828 #include "callweaver.h"
2929
------
4040 #include "callweaver/translate.h"
4141 #include "callweaver/manager.h"
4242
43 static char *tdesc = "Trivial FAX Receive Application";
43 static const char *tdesc = "Trivial FAX Receive Application";
4444
4545 static void *rxfax_app;
4646 static const char *rxfax_name = "RxFAX";
------
163163 alloc: faxgen_alloc,
164164 release: faxgen_release,
165165 generate: faxgen_generate,
166 } ;
166 };
167167
168168 /*- End of function --------------------------------------------------------*/
169169
------
273273 res = 0;
274274 uint64_t now;
275275 uint64_t passage;
276 t30_state_t *t30;
277 t38_core_state_t *t38_core;
276278
277279 memset(t38, 0, sizeof(*t38));
278280
------
281283 cw_log(LOG_WARNING, "Unable to start T.38 termination.\n");
282284 return -1;
283285 }
284
286 t30 = t38_terminal_get_t30_state(t38);
287 t38_core = t38_terminal_get_t38_core_state(t38);
285288 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);
288291
289292 if (verbose)
290293 {
291294 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);
294297 }
295298
296299 x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
297300 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);
299305 x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
300306 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);
303309
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);
307313
308314 x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17");
309315 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);
311317 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);
313319
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);
318324
319325 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);
322328 cw_log(LOG_DEBUG, "Enabling ECM mode for app_rxfax\n" );
323329 }
324330 else
325331 {
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 );
327333 }
328334
329335 passage = nowis();
------
331337 t38_terminal_set_tep_mode(t38, TRUE);
332338 while (ready && ready_to_talk(chan))
333339 {
334
335 if ( chan->t38_status != T38_NEGOTIATED )
340 if (chan->t38_status != T38_NEGOTIATED)
336341 break;
337342
338343 if ((res = cw_waitfor(chan, 20)) < 0) {
------
344349 t38_terminal_send_timeout(t38, (now - passage)/125);
345350 passage = now;
346351 /* 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))
348353 break;
349354
350355 inf = cw_read(chan);
------
354359 }
355360
356361 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);
358363
359364 cw_fr_free(inf);
360365 }
361366
362367 return ready;
363
364368 }
365369 /*- End of function --------------------------------------------------------*/
366370
------
378382 received_frames = 0;
379383
380384 struct cw_dsp *dsp = NULL;
385 t30_state_t *t30;
381386
382387 uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET];
383388 uint8_t *buf = __buf + CW_FRIENDLY_OFFSET;
------
389394 cw_log(LOG_WARNING, "Unable to start FAX\n");
390395 return -1;
391396 }
397 t30 = fax_get_t30_state(fax);
392398 fax_set_transmit_on_idle(fax, TRUE);
393399 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);
395401 if (verbose)
396402 {
397403 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);
399405 }
400406 x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
401407 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);
403412 x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
404413 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);
410419
411420 x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17");
412421 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);
414423
415424 /* 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);
420429 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);
423432 cw_log(LOG_DEBUG, "Enabling ECM mode for app_rxfax\n" );
424433 }
425434
------
429438 cw_log(LOG_WARNING, "Unable to allocate DSP!\n");
430439 else {
431440 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);
434443 }
435444
436
437445 /* This is the main loop */
438446
439447 begin = nowis();
440448
441 while ( ready && ready_to_talk(chan) )
449 while (ready && ready_to_talk(chan))
442450 {
443
444 if ( chan->t38_status == T38_NEGOTIATED )
451 if (chan->t38_status == T38_NEGOTIATED)
445452 break;
446453
447454 if ((res = cw_waitfor(chan, 20)) < 0) {
------
449456 break;
450457 }
451458
452 if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE))
459 if (!t30_call_active(t30))
453460 break;
454461
455462 inf = cw_read(chan);
------
539546
540547 cw_generator_activate(chan, &faxgen, fax);
541548
542 while ( ready && ready_to_talk(chan) ) {
549 while (ready && ready_to_talk(chan)) {
543550
544 if ( chan->t38_status == T38_NEGOTIATED )
551 if (chan->t38_status == T38_NEGOTIATED)
545552 break;
546553
547554 if ((res = cw_waitfor(chan, 20)) < 0) {
------
549556 break;
550557 }
551558
552 if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE))
559 if (!t30_call_active(t30))
553560 break;
554561
555562 inf = cw_read(chan);
------
577584 dspf = NULL;
578585 }
579586
580
581587 if (fax_rx(fax, inf->data, inf->samples)) {
582588 ready = 0;
583589 break;
------
594600 }
595601
596602 cw_generator_deactivate(chan);
597
598603 }
599604
600605 return ready;
------
603608
604609 static int rxfax_exec(struct cw_channel *chan, int argc, char **argv)
605610 {
606 fax_state_t fax;
611 fax_state_t fax;
607612 t38_terminal_state_t t38;
613 t30_state_t *t30;
608614
609615 int res = 0;
610616 char target_file[256];
------
711717
712718 ready = TRUE;
713719
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))
715725 {
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);
720729 }
721730
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);
724734 }
725735
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.
729738 }
730739
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);
735741
736742 fax_release(&fax);
737743 t38_terminal_release(&t38);
738744
745 /* Maybe we should restore gain and echo cancel settings here? */
746
739747 /* Restoring initial channel formats. */
740748
741749 if (original_read_fmt != CW_FORMAT_SLINEAR)

callweaver/branches/srtp_tls/apps/app_sms.c (unified diff)

r4739r5221
3737 #include <sys/types.h>
3838 #include <sys/stat.h>
3939 #include <spandsp.h>
40 #include <spandsp/expose.h>
4041
4142 #include "callweaver/lock.h"
4243 #include "callweaver/file.h"

callweaver/branches/srtp_tls/apps/app_t38gateway.c (unified diff)

r4723r5221
2828 #include <unistd.h>
2929 #include <tiffio.h>
3030 #include <spandsp.h>
31 #include <spandsp/expose.h>
3132
3233 #include "callweaver/file.h"
3334 #include "callweaver/logger.h"
------
151152
152153 f->tx_copies = 1; /* TODO: this is only needed because not everything sets the tx_copies field properly */
153154
154 if ( ( chan->t38_status == T38_NEGOTIATING ) || ( peer->t38_status == T38_NEGOTIATING ) ) {
155 if ((chan->t38_status == T38_NEGOTIATING) || (peer->t38_status == T38_NEGOTIATING)) {
155156 /* TODO
156157 This is a very BASIC method to mute a channel. It should be improved
157158 and we should send EMPTY frames (not just avoid sending them)
------
216217
217218 /* Check if we need to change to gateway operation */
218219 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)
222223 ) {
223224 cw_log(LOG_DEBUG, "Stop bridging frames. [ %d,%d]\n", chan->t38_status, peer->t38_status);
224225 running = RUNNING;
------
270271 t38_gateway_state_t t38_state;
271272 uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET];
272273 uint8_t *buf = __buf + CW_FRIENDLY_OFFSET;
274 t38_core_state_t *t38_core;
273275
274276 if (chan->t38_status == T38_NEGOTIATED)
275277 {
------
284286
285287 original_read_fmt = channels[1]->readformat;
286288 original_write_fmt = channels[1]->writeformat;
287 if ( channels[1]->t38_status != T38_NEGOTIATED)
289 if (channels[1]->t38_status != T38_NEGOTIATED)
288290 {
289291 if (original_read_fmt != CW_FORMAT_SLINEAR)
290292 {
------
312314 return -1;
313315 }
314316 t38_gateway_set_transmit_on_idle(&t38_state, TRUE);
317 t38_core = t38_gateway_get_t38_core_state(&t38_state);
315318 x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17");
316319 if (x && x[0])
317320 t38_gateway_set_supported_modems(&t38_state, T30_SUPPORT_V29 | T30_SUPPORT_V27TER);
------
319322 t38_gateway_set_supported_modems(&t38_state, T30_SUPPORT_V17 | T30_SUPPORT_V29 | T30_SUPPORT_V27TER);
320323
321324 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);
323326 if (verbose)
324327 {
325328 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);
327330 }
328 t38_set_t38_version(&t38_state.t38, 0);
331 t38_set_t38_version(t38_core, 0);
329332 t38_gateway_set_ecm_capability(&t38_state, 1);
330333
331
332334 while (running == RUNNING && (running = ready_to_talk(channels[0], channels[1])))
333335 {
334336 //cw_log(LOG_NOTICE, "gw: t38status: [%d,%d]\n", chan->t38_status, peer->t38_status);
335337 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 {
339341 cw_log(LOG_DEBUG, "Stop gateway-ing frames (both channels are in t38 mode). [ %d,%d]\n", chan->t38_status, peer->t38_status);
340342 running = RUNNING;
341343 break;
------
347349 {
348350 if ((f = cw_read(active)))
349351 {
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);
351353 clean_frame(f);
352354 }
353355 else
------
621623
622624 res = RUNNING;
623625
624 while ( res == RUNNING ) {
626 while (res == RUNNING) {
625627
626 if ( res && ( chan->t38_status == peer->t38_status ) )
628 if (res && (chan->t38_status == peer->t38_status))
627629 {
628630 // Same on both sides, so just bridge
629631 cw_log(LOG_DEBUG, "Bridging frames [ %d,%d]\n", chan->t38_status, peer->t38_status);
------
631633 }
632634
633635 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)
637639 )
638640 {
639641 // Different on each side, so gateway

callweaver/branches/srtp_tls/apps/app_txfax.c (unified diff)

r4723r5221
2222 #include <pthread.h>
2323 #include <errno.h>
2424 #include <sys/time.h>
25
2625 #include <spandsp.h>
26 #include <spandsp/expose.h>
2727
2828 #include "callweaver.h"
2929
------
242242 res = 0;
243243 uint64_t now;
244244 uint64_t passage;
245 t30_state_t *t30;
246 t38_core_state_t *t38_core;
245247
246248 memset(t38, 0, sizeof(*t38));
247249
------
250252 cw_log(LOG_WARNING, "Unable to start T.38 termination.\n");
251253 return -1;
252254 }
253
255 t30 = t38_terminal_get_t30_state(t38);
256 t38_core = t38_terminal_get_t38_core_state(t38);
254257 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);
257260
258261 if (verbose)
259262 {
260263 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);
263266 }
264267
265268 x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
266269 if (x && x[0])
267 t30_set_tx_ident(&t38->t30_state, x);
270 t30_set_tx_ident(t30, x);
268271 x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS");
269272 if (x && x[0])
270 t30_set_tx_sub_address(&t38->t30_state, x);
273 t30_set_tx_sub_address(t30, x);
271274 x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
272275 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);
275278
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);
279282
280283 x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17");
281284 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);
283286 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);
285288
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);
290293
291294 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);
294297 cw_log(LOG_DEBUG, "Enabling ECM mode for app_txfax\n" );
295298 }
296299 else
297300 {
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 );
299302 }
300303
301304 passage = nowis();
------
316319 t38_terminal_send_timeout(t38, (now - passage)/125);
317320 passage = now;
318321 /* 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))
320323 break;
321324
322325 inf = cw_read(chan);
------
326329 }
327330
328331 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);
330333
331334 cw_fr_free(inf);
332335 }
------
347350 generator_mode = 0;
348351 uint64_t begin = 0,
349352 received_frames = 0;
350
351353 uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*CW_FRIENDLY_OFFSET];
352354 uint8_t *buf = __buf + CW_FRIENDLY_OFFSET;
355 t30_state_t *t30;
353356
354357 memset(fax, 0, sizeof(*fax));
355358
------
359362 return -1;
360363 }
361364 fax_set_transmit_on_idle(fax, TRUE);
365 t30 = fax_get_t30_state(fax);
362366 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);
364368 if (verbose)
365369 {
366370 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);
368372 }
369373 x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
370374 if (x && x[0])
371 t30_set_tx_ident(&fax->t30_state, x);
375 t30_set_tx_ident(t30, x);
372376 x = pbx_builtin_getvar_helper(chan, "LOCALSUBADDRESS");
373377 if (x && x[0])
374 t30_set_tx_sub_address(&fax->t30_state, x);
378 t30_set_tx_sub_address(t30, x);
375379 x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
376380 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);
382386
383387 x = pbx_builtin_getvar_helper(chan, "FAX_DISABLE_V17");
384388 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);
386390
387391 /* 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);
392396 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);
395399 cw_log(LOG_DEBUG, "Enabling ECM mode for app_txfax\n" );
396400 }
397401
------
410414 break;
411415 }
412416
413 if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE))
417 if (!t30_call_active(t30))
414418 break;
415419
416420 inf = cw_read(chan);
------
490494 break;
491495 }
492496
493 if ((fax->current_rx_type == T30_MODEM_DONE) || (fax->current_tx_type == T30_MODEM_DONE))
497 if (!t30_call_active(t30))
494498 break;
495499
496500 inf = cw_read(chan);
------
540544
541545 int original_read_fmt;
542546 int original_write_fmt;
547 t30_state_t *t30;
543548
544549 /* Basic initial checkings */
545550
------
643648 }
644649 }
645650
646
647651 /* This is the main loop */
648652
649653 ready = TRUE;
650654
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))
652660 {
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);
657665 }
658666
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);
661671 }
662672
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.
666675 }
667676
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);
672678
673679 fax_release(&fax);
674680 t38_terminal_release(&t38);
------
687693 }
688694
689695 return ready;
690
691696 }
692697 /*- End of function --------------------------------------------------------*/
693698
694699 int unload_module(void)
695700 {
696701 int res = 0;
702
697703 STANDARD_HANGUP_LOCALUSERS;
698704 res |= cw_unregister_application(txfax_app);
699705 return res;

callweaver/branches/srtp_tls/channels/chan_zap.c (unified diff)

r4979r5221
4040 #include <unistd.h>
4141 #include <sys/ioctl.h>
4242 #include <spandsp.h>
43 #include <spandsp/expose.h>
4344
44
4545 #include <math.h>
4646 #include ZAPTEL_H
4747 #include TONEZONE_H

callweaver/branches/srtp_tls/channels/fax/faxmodem.h (unified diff)

r4761r5221
3232 #include <inttypes.h>
3333 #include <tiffio.h>
3434 #include <spandsp.h>
35 #include <spandsp/expose.h>
3536
3637 typedef enum {
3738 FAXMODEM_STATE_INIT,

callweaver/branches/srtp_tls/codecs/codec_g722.c (unified diff)

r4723r5221
3535 #include <string.h>
3636 #include <unistd.h>
3737 #include <spandsp.h>
38 #include <spandsp/expose.h>
3839
3940 #include "callweaver.h"
4041

callweaver/branches/srtp_tls/codecs/codec_g722_16k_8k.c (unified diff)

r4723r5221
3535 #include <string.h>
3636 #include <unistd.h>
3737 #include <spandsp.h>
38 #include <spandsp/expose.h>
3839
3940 #include "callweaver.h"
4041

callweaver/branches/srtp_tls/codecs/codec_g726.c (unified diff)

r4723r5221
3535 #include <string.h>
3636 #include <unistd.h>
3737 #include <spandsp.h>
38 #include <spandsp/expose.h>
3839
3940 #include "callweaver.h"
4041

callweaver/branches/srtp_tls/configure.ac (unified diff)

r5153r5221
777777 [AC_HELP_STRING([--with-spandsp-libs],[Location of SpanDSP library files.])],
778778 [LDFLAGS="$LDFLAGS -L${withval}"])
779779
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.)])
781781
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.)],
783783 [#ifdef HAVE_SPANDSP_H
784784 #include <spandsp.h>
785785 #endif
786786 #include <spandsp/version.h>
787787
788 #if SPANDSP_RELEASE_DATE < 20080616
788 #if SPANDSP_RELEASE_DATE < 20081018
789789
790790 #error
791791 #endif

callweaver/branches/srtp_tls/corelib/callerid.c (unified diff)

r4723r5221
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
131 /*
142 * CallWeaver -- An open source telephony toolkit.
153 *
------
4634 #include <math.h>
4735 #include <ctype.h>
4836 #include <spandsp.h>
37 #include <spandsp/expose.h>
4938
5039 #include "callweaver.h"
5140
------
149138 int mate_generate(uint8_t *outbuf, int outlen, const char *msg, int codec)
150139 {
151140 int16_t lin[MAX_CALLERID_SIZE];
141 adsi_tx_state_t adsi;
152142 int slen;
153143
154 adsi_tx_state_t adsi;
155144 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];
162145 adsi_tx_set_preamble(&adsi, 0, 80, -1, -1);
163146
147 adsi_tx_put_message(&adsi, (const uint8_t *) msg, strlen(msg));
164148 slen = adsi_tx(&adsi, lin, sizeof(lin)/sizeof(lin[0]));
165149 return lin2xlaw(codec, lin, slen, outbuf, outlen);
166150 }

callweaver/branches/srtp_tls/corelib/dsp.c (unified diff)

r4933r5221
3535 #include <errno.h>
3636 #include <stdio.h>
3737 #include <spandsp.h>
38 #include <spandsp/expose.h>
3839
3940 #include "callweaver.h"
4041

callweaver/branches/srtp_tls/corelib/udptl.c (unified diff)

r4723r5221
705705 {
706706 int res;
707707 int actions;
708 struct sockaddr_in original_dest;
708709 struct sockaddr_in sin;
709710 socklen_t len;
710711 char iabuf[INET_ADDRSTRLEN];
------
713714
714715 len = sizeof(sin);
715716
717 memcpy(&original_dest, udp_socket_get_them(udptl->udptl_sock_info), sizeof(original_dest));
718
716719 /* Cache where the header will go */
717720 res = udp_socket_recvfrom(udptl->udptl_sock_info,
718721 udptl->rawdata + CW_FRIENDLY_OFFSET,
------
750753 #if 0
751754 printf("Got UDPTL packet from %s:%d (len %d)\n", cw_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), res);
752755 #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);
754759
755760 return &udptl->f[0];
756761 }

callweaver/branches/srtp_tls/debian/callweaver.init (unified diff)

r2720r5221
1616 #
1717 # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
1818 #
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
1927
2028 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
2129 NAME=callweaver

callweaver/branches/srtp_tls/res/res_adsi.c (unified diff)

r4723r5221
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
131 /*
142 * CallWeaver -- An open source telephony toolkit.
153 *
------
4836 #include <math.h>
4937 #include <errno.h>
5038 #include <spandsp.h>
51 #include <spandsp/adsi.h>
39 #include <spandsp/expose.h>
5240
5341 #include "callweaver.h"
5442