annotate test-voice/rtp_tx.c @ 17:830af7de3403

sipout-test-voice: disallow empty files for play command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 May 2024 22:31:24 -0800
parents 71f01a834820
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement outgoing RTP stream generation.
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
6 #include <sys/file.h>
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
7 #include <sys/stat.h>
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/socket.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <sys/time.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <netinet/in.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdio.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdint.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdlib.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <string.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <strings.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <unistd.h>
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "../include/tmgw_const.h"
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "../include/rtp_defs.h"
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "../libutil/osmo_bits.h"
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 extern struct sockaddr_in rtp_local_addr, rtp_remote_addr;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern int rtp_udp_fd, rtcp_udp_fd, pcma_selected;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 extern struct timeval cur_event_time;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
13
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
25 static const uint8_t dmw_alaw[8] =
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
26 {0x34, 0x21, 0x21, 0x34, 0xB4, 0xA1, 0xA1, 0xB4};
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
27 static const uint8_t dmw_ulaw[8] =
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
28 {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E};
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
29
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 static uint32_t rtp_ssrc;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 static uint32_t rtp_out_ts;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 static uint16_t rtp_out_seq;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 static uint8_t pcm_fill_octet;
13
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
35 static int dmw_active;
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
37 static uint8_t *play_buffer;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
38 static unsigned play_buf_nframes, play_buf_ptr;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
39 static int play_loop;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
40
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 static uint16_t tfo_fill_buf[9], tfo_req_buf[7];
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 static uint16_t *is_out_ptr;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 static unsigned is_out_count;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 static int tfo_stop_req;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 assign_rtpout_ssrc()
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid();
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 init_pcm_fill_octet()
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if (pcma_selected)
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 pcm_fill_octet = 0xD5;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 else
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 pcm_fill_octet = 0xFF;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 prepare_tfo_fill()
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 tfo_fill_buf[0] = 0x15A;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 tfo_fill_buf[1] = 0x1A9;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 tfo_fill_buf[2] = 0x129;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 tfo_fill_buf[3] = 0x15A;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 tfo_fill_buf[4] = 0x1A9;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 tfo_fill_buf[5] = 0x129;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 tfo_fill_buf[6] = 0x15A;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 tfo_fill_buf[7] = 0x1A9;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 tfo_fill_buf[8] = 0x129;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 static void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 insert_is_msg(payload, word)
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 uint8_t *payload;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 uint16_t word;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 ubit_t is_bits[10];
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 uint8_t *bytep;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 unsigned n;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 uint16_to_bits(word, is_bits, 10);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 for (n = 0; n < 10; n++) {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 bytep = payload + n * 16;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 *bytep &= 0xFE;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 *bytep |= is_bits[n];
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
13
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
92 static void
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
93 fill_with_dmw(buf)
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
94 uint8_t *buf;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
95 {
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
96 const uint8_t *src;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
97 unsigned n;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
98
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
99 if (pcma_selected)
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
100 src = dmw_alaw;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
101 else
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
102 src = dmw_ulaw;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
103 for (n = 0; n < 20; n++) {
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
104 memcpy(buf, src, 8);
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
105 buf += 8;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
106 }
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
107 }
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
108
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
109 static void
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
110 fill_with_play(outbuf)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
111 uint8_t *outbuf;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
112 {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
113 memcpy(outbuf, play_buffer + play_buf_ptr * 160, 160);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
114 play_buf_ptr++;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
115 if (play_buf_ptr < play_buf_nframes)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
116 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
117 if (play_loop)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
118 play_buf_ptr = 0;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
119 else {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
120 free(play_buffer);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
121 play_buffer = 0;
15
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
122 printf("file play finished\n");
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
123 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
124 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
125
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 generate_rtp_packet()
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 struct rtp_packet pkt;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 socklen_t addrlen;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 pkt.v_p_x_cc = 0x80;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 pkt.m_pt = pcma_selected ? PSTN_CODEC_PCMA : PSTN_CODEC_PCMU;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 pkt.seq = htons(rtp_out_seq++);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 pkt.tstamp = htonl(rtp_out_ts);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 rtp_out_ts += 160;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 pkt.ssrc = rtp_ssrc;
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
138 if (play_buffer)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
139 fill_with_play(pkt.payload);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
140 else if (dmw_active)
13
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
141 fill_with_dmw(pkt.payload);
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
142 else
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
143 memset(pkt.payload, pcm_fill_octet, RTP_MAX_PAYLOAD);
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 if (is_out_count) {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 insert_is_msg(pkt.payload, *is_out_ptr++);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 is_out_count--;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 if (!is_out_count && !tfo_stop_req) {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 is_out_ptr = tfo_req_buf;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 is_out_count = 7;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 addrlen = sizeof(struct sockaddr_in);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 sendto(rtp_udp_fd, &pkt, RTP_PACKET_SIZE_PSTN, 0,
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 (struct sockaddr *) &rtp_remote_addr, addrlen);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 set_pcm_fill_octet(oct)
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 unsigned oct;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 pcm_fill_octet = oct;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 send_tfo_req(sig, codec)
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 unsigned sig, codec;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 tfo_req_buf[0] = 0x15A;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 tfo_req_buf[1] = 0x1A9;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 tfo_req_buf[2] = 0x05D;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 tfo_req_buf[3] = 0x14E;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 tfo_req_buf[4] = 0x14B;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 encode_tfo_ext_words(sig, codec, 0, tfo_req_buf + 5);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 is_out_ptr = tfo_fill_buf;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 is_out_count = 9;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 tfo_stop_req = 0;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 }
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 void
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 stop_tfo_out()
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 tfo_stop_req = 1;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 }
13
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
184
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
185 void
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
186 cmd_dmw_on()
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
187 {
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
188 dmw_active = 1;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
189 }
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
190
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
191 void
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
192 cmd_dmw_off()
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
193 {
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
194 dmw_active = 0;
059b79c9f0c3 sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
195 }
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
196
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
197 void
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
198 play_file_cmdop(filename, loop)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
199 char *filename;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
200 {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
201 int fd;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
202 struct stat st;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
203
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
204 if (play_buffer) {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
205 fprintf(stderr, "error: file play already in progress\n");
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
206 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
207 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
208 fd = open(filename, O_RDONLY);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
209 if (fd < 0) {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
210 perror(filename);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
211 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
212 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
213 fstat(fd, &st);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
214 if (!S_ISREG(st.st_mode)) {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
215 close(fd);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
216 fprintf(stderr, "error: %s is not a regular file\n", filename);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
217 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
218 }
17
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
219 if (!st.st_size) {
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
220 close(fd);
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
221 fprintf(stderr, "error: %s is an empty file\n", filename);
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
222 return;
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
223 }
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
224 if (st.st_size % 160) {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
225 close(fd);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
226 fprintf(stderr,
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
227 "error: size of %s is not a multiple of 160 bytes\n",
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
228 filename);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
229 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
230 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
231 play_buffer = malloc(st.st_size);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
232 if (!play_buffer) {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
233 close(fd);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
234 fprintf(stderr, "unable to malloc buffer for %s\n", filename);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
235 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
236 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
237 read(fd, play_buffer, st.st_size);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
238 close(fd);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
239 play_buf_nframes = st.st_size / 160;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
240 play_buf_ptr = 0;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
241 play_loop = loop;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
242 }
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
243
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
244 void
15
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
245 play_file_offset(filename, offset)
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
246 char *filename;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
247 unsigned offset;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
248 {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
249 int fd;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
250 struct stat st;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
251 unsigned pre_offset;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
252
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
253 if (play_buffer) {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
254 fprintf(stderr, "error: file play already in progress\n");
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
255 return;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
256 }
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
257 fd = open(filename, O_RDONLY);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
258 if (fd < 0) {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
259 perror(filename);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
260 return;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
261 }
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
262 fstat(fd, &st);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
263 if (!S_ISREG(st.st_mode)) {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
264 close(fd);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
265 fprintf(stderr, "error: %s is not a regular file\n", filename);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
266 return;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
267 }
17
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
268 if (!st.st_size) {
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
269 close(fd);
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
270 fprintf(stderr, "error: %s is an empty file\n", filename);
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
271 return;
830af7de3403 sipout-test-voice: disallow empty files for play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
272 }
15
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
273 if (st.st_size % 160) {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
274 close(fd);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
275 fprintf(stderr,
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
276 "error: size of %s is not a multiple of 160 bytes\n",
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
277 filename);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
278 return;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
279 }
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
280 play_buffer = malloc(st.st_size + 160);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
281 if (!play_buffer) {
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
282 close(fd);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
283 fprintf(stderr, "unable to malloc buffer for %s\n", filename);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
284 return;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
285 }
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
286 pre_offset = 160 - offset;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
287 memset(play_buffer, pcm_fill_octet, pre_offset);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
288 read(fd, play_buffer + pre_offset, st.st_size);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
289 close(fd);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
290 memset(play_buffer + pre_offset + st.st_size, pcm_fill_octet, offset);
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
291 play_buf_nframes = st.st_size / 160 + 1;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
292 play_buf_ptr = 0;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
293 play_loop = 0;
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
294 }
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
295
71f01a834820 sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
296 void
14
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
297 play_file_stop()
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
298 {
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
299 if (!play_buffer)
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
300 return;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
301 free(play_buffer);
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
302 play_buffer = 0;
f96153d15889 sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
303 }