Wed Jan 8 2020 09:49:44

Asterisk developer's documentation


chan_oss.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2007, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * FreeBSD changes and multiple device support by Luigi Rizzo, 2005.05.25
9  * note-this code best seen with ts=8 (8-spaces tabs) in the editor
10  *
11  * See http://www.asterisk.org for more information about
12  * the Asterisk project. Please do not directly contact
13  * any of the maintainers of this project for assistance;
14  * the project provides a web site, mailing lists and IRC
15  * channels for your use.
16  *
17  * This program is free software, distributed under the terms of
18  * the GNU General Public License Version 2. See the LICENSE file
19  * at the top of the source tree.
20  */
21 
22 // #define HAVE_VIDEO_CONSOLE // uncomment to enable video
23 /*! \file
24  *
25  * \brief Channel driver for OSS sound cards
26  *
27  * \author Mark Spencer <markster@digium.com>
28  * \author Luigi Rizzo
29  *
30  * \par See also
31  * \arg \ref Config_oss
32  *
33  * \ingroup channel_drivers
34  */
35 
36 /*** MODULEINFO
37  <depend>oss</depend>
38  <support_level>extended</support_level>
39  ***/
40 
41 #include "asterisk.h"
42 
43 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 412480 $")
44 
45 #include <ctype.h> /* isalnum() used here */
46 #include <math.h>
47 #include <sys/ioctl.h>
48 
49 #ifdef __linux
50 #include <linux/soundcard.h>
51 #elif defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__GLIBC__) || defined(__sun)
52 #include <sys/soundcard.h>
53 #else
54 #include <soundcard.h>
55 #endif
56 
57 #include "asterisk/channel.h"
58 #include "asterisk/file.h"
59 #include "asterisk/callerid.h"
60 #include "asterisk/module.h"
61 #include "asterisk/pbx.h"
62 #include "asterisk/cli.h"
63 #include "asterisk/causes.h"
64 #include "asterisk/musiconhold.h"
65 #include "asterisk/app.h"
66 
67 #include "console_video.h"
68 
69 /*! Global jitterbuffer configuration - by default, jb is disabled
70  * \note Values shown here match the defaults shown in oss.conf.sample */
71 static struct ast_jb_conf default_jbconf =
72 {
73  .flags = 0,
74  .max_size = 200,
75  .resync_threshold = 1000,
76  .impl = "fixed",
77  .target_extra = 40,
78 };
79 static struct ast_jb_conf global_jbconf;
80 
81 /*
82  * Basic mode of operation:
83  *
84  * we have one keyboard (which receives commands from the keyboard)
85  * and multiple headset's connected to audio cards.
86  * Cards/Headsets are named as the sections of oss.conf.
87  * The section called [general] contains the default parameters.
88  *
89  * At any time, the keyboard is attached to one card, and you
90  * can switch among them using the command 'console foo'
91  * where 'foo' is the name of the card you want.
92  *
93  * oss.conf parameters are
94 START_CONFIG
95 
96 [general]
97  ; General config options, with default values shown.
98  ; You should use one section per device, with [general] being used
99  ; for the first device and also as a template for other devices.
100  ;
101  ; All but 'debug' can go also in the device-specific sections.
102  ;
103  ; debug = 0x0 ; misc debug flags, default is 0
104 
105  ; Set the device to use for I/O
106  ; device = /dev/dsp
107 
108  ; Optional mixer command to run upon startup (e.g. to set
109  ; volume levels, mutes, etc.
110  ; mixer =
111 
112  ; Software mic volume booster (or attenuator), useful for sound
113  ; cards or microphones with poor sensitivity. The volume level
114  ; is in dB, ranging from -20.0 to +20.0
115  ; boost = n ; mic volume boost in dB
116 
117  ; Set the callerid for outgoing calls
118  ; callerid = John Doe <555-1234>
119 
120  ; autoanswer = no ; no autoanswer on call
121  ; autohangup = yes ; hangup when other party closes
122  ; extension = s ; default extension to call
123  ; context = default ; default context for outgoing calls
124  ; language = "" ; default language
125 
126  ; Default Music on Hold class to use when this channel is placed on hold in
127  ; the case that the music class is not set on the channel with
128  ; Set(CHANNEL(musicclass)=whatever) in the dialplan and the peer channel
129  ; putting this one on hold did not suggest a class to use.
130  ;
131  ; mohinterpret=default
132 
133  ; If you set overridecontext to 'yes', then the whole dial string
134  ; will be interpreted as an extension, which is extremely useful
135  ; to dial SIP, IAX and other extensions which use the '@' character.
136  ; The default is 'no' just for backward compatibility, but the
137  ; suggestion is to change it.
138  ; overridecontext = no ; if 'no', the last @ will start the context
139  ; if 'yes' the whole string is an extension.
140 
141  ; low level device parameters in case you have problems with the
142  ; device driver on your operating system. You should not touch these
143  ; unless you know what you are doing.
144  ; queuesize = 10 ; frames in device driver
145  ; frags = 8 ; argument to SETFRAGMENT
146 
147  ;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
148  ; jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of an
149  ; OSS channel. Defaults to "no". An enabled jitterbuffer will
150  ; be used only if the sending side can create and the receiving
151  ; side can not accept jitter. The OSS channel can't accept jitter,
152  ; thus an enabled jitterbuffer on the receive OSS side will always
153  ; be used if the sending side can create jitter.
154 
155  ; jbmaxsize = 200 ; Max length of the jitterbuffer in milliseconds.
156 
157  ; jbresyncthreshold = 1000 ; Jump in the frame timestamps over which the jitterbuffer is
158  ; resynchronized. Useful to improve the quality of the voice, with
159  ; big jumps in/broken timestamps, usualy sent from exotic devices
160  ; and programs. Defaults to 1000.
161 
162  ; jbimpl = fixed ; Jitterbuffer implementation, used on the receiving side of an OSS
163  ; channel. Two implementations are currenlty available - "fixed"
164  ; (with size always equals to jbmax-size) and "adaptive" (with
165  ; variable size, actually the new jb of IAX2). Defaults to fixed.
166 
167  ; jblog = no ; Enables jitterbuffer frame logging. Defaults to "no".
168  ;-----------------------------------------------------------------------------------
169 
170 [card1]
171  ; device = /dev/dsp1 ; alternate device
172 
173 END_CONFIG
174 
175 .. and so on for the other cards.
176 
177  */
178 
179 /*
180  * The following parameters are used in the driver:
181  *
182  * FRAME_SIZE the size of an audio frame, in samples.
183  * 160 is used almost universally, so you should not change it.
184  *
185  * FRAGS the argument for the SETFRAGMENT ioctl.
186  * Overridden by the 'frags' parameter in oss.conf
187  *
188  * Bits 0-7 are the base-2 log of the device's block size,
189  * bits 16-31 are the number of blocks in the driver's queue.
190  * There are a lot of differences in the way this parameter
191  * is supported by different drivers, so you may need to
192  * experiment a bit with the value.
193  * A good default for linux is 30 blocks of 64 bytes, which
194  * results in 6 frames of 320 bytes (160 samples).
195  * FreeBSD works decently with blocks of 256 or 512 bytes,
196  * leaving the number unspecified.
197  * Note that this only refers to the device buffer size,
198  * this module will then try to keep the lenght of audio
199  * buffered within small constraints.
200  *
201  * QUEUE_SIZE The max number of blocks actually allowed in the device
202  * driver's buffer, irrespective of the available number.
203  * Overridden by the 'queuesize' parameter in oss.conf
204  *
205  * Should be >=2, and at most as large as the hw queue above
206  * (otherwise it will never be full).
207  */
208 
209 #define FRAME_SIZE 160
210 #define QUEUE_SIZE 10
211 
212 #if defined(__FreeBSD__)
213 #define FRAGS 0x8
214 #else
215 #define FRAGS ( ( (6 * 5) << 16 ) | 0x6 )
216 #endif
217 
218 /*
219  * XXX text message sizes are probably 256 chars, but i am
220  * not sure if there is a suitable definition anywhere.
221  */
222 #define TEXT_SIZE 256
223 
224 #if 0
225 #define TRYOPEN 1 /* try to open on startup */
226 #endif
227 #define O_CLOSE 0x444 /* special 'close' mode for device */
228 /* Which device to use */
229 #if defined( __OpenBSD__ ) || defined( __NetBSD__ )
230 #define DEV_DSP "/dev/audio"
231 #else
232 #define DEV_DSP "/dev/dsp"
233 #endif
234 
235 static char *config = "oss.conf"; /* default config file */
236 
237 static int oss_debug;
238 
239 /*!
240  * \brief descriptor for one of our channels.
241  *
242  * There is one used for 'default' values (from the [general] entry in
243  * the configuration file), and then one instance for each device
244  * (the default is cloned from [general], others are only created
245  * if the relevant section exists).
246  */
247 struct chan_oss_pvt {
249 
250  char *name;
251  int total_blocks; /*!< total blocks in the output device */
252  int sounddev;
254  int autoanswer; /*!< Boolean: whether to answer the immediately upon calling */
255  int autohangup; /*!< Boolean: whether to hangup the call when the remote end hangs up */
256  int hookstate; /*!< Boolean: 1 if offhook; 0 if onhook */
257  char *mixer_cmd; /*!< initial command to issue to the mixer */
258  unsigned int queuesize; /*!< max fragments in queue */
259  unsigned int frags; /*!< parameter for SETFRAGMENT */
260 
261  int warned; /*!< various flags used for warnings */
262 #define WARN_used_blocks 1
263 #define WARN_speed 2
264 #define WARN_frag 4
265  int w_errors; /*!< overfull in the write path */
266  struct timeval lastopen;
267 
269  int mute;
270 
271  /*! boost support. BOOST_SCALE * 10 ^(BOOST_MAX/20) must
272  * be representable in 16 bits to avoid overflows.
273  */
274 #define BOOST_SCALE (1<<9)
275 #define BOOST_MAX 40 /*!< slightly less than 7 bits */
276  int boost; /*!< input boost, scaled by BOOST_SCALE */
277  char device[64]; /*!< device to open */
278 
279  pthread_t sthread;
280 
282 
283  struct video_desc *env; /*!< parameters for video support */
284 
288  char cid_name[256]; /*!< Initial CallerID name */
289  char cid_num[256]; /*!< Initial CallerID number */
291 
292  /*! buffers used in oss_write */
295  /*! buffers used in oss_read - AST_FRIENDLY_OFFSET space for headers
296  * plus enough room for a full frame
297  */
299  int readpos; /*!< read position above */
300  struct ast_frame read_f; /*!< returned by oss_read */
301 };
302 
303 /*! forward declaration */
304 static struct chan_oss_pvt *find_desc(const char *dev);
305 
306 static char *oss_active; /*!< the active device */
307 
308 /*! \brief return the pointer to the video descriptor */
309 struct video_desc *get_video_desc(struct ast_channel *c)
310 {
311  struct chan_oss_pvt *o = c ? c->tech_pvt : find_desc(oss_active);
312  return o ? o->env : NULL;
313 }
314 static struct chan_oss_pvt oss_default = {
315  .sounddev = -1,
316  .duplex = M_UNSET, /* XXX check this */
317  .autoanswer = 1,
318  .autohangup = 1,
319  .queuesize = QUEUE_SIZE,
320  .frags = FRAGS,
321  .ext = "s",
322  .ctx = "default",
323  .readpos = AST_FRIENDLY_OFFSET, /* start here on reads */
324  .lastopen = { 0, 0 },
325  .boost = BOOST_SCALE,
326 };
327 
328 
329 static int setformat(struct chan_oss_pvt *o, int mode);
330 
331 static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor,
332  void *data, int *cause);
333 static int oss_digit_begin(struct ast_channel *c, char digit);
334 static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration);
335 static int oss_text(struct ast_channel *c, const char *text);
336 static int oss_hangup(struct ast_channel *c);
337 static int oss_answer(struct ast_channel *c);
338 static struct ast_frame *oss_read(struct ast_channel *chan);
339 static int oss_call(struct ast_channel *c, char *dest, int timeout);
340 static int oss_write(struct ast_channel *chan, struct ast_frame *f);
341 static int oss_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen);
342 static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
343 static char tdesc[] = "OSS Console Channel Driver";
344 
345 /* cannot do const because need to update some fields at runtime */
346 static struct ast_channel_tech oss_tech = {
347  .type = "Console",
348  .description = tdesc,
349  .capabilities = AST_FORMAT_SLINEAR, /* overwritten later */
350  .requester = oss_request,
351  .send_digit_begin = oss_digit_begin,
352  .send_digit_end = oss_digit_end,
353  .send_text = oss_text,
354  .hangup = oss_hangup,
355  .answer = oss_answer,
356  .read = oss_read,
357  .call = oss_call,
358  .write = oss_write,
359  .write_video = console_write_video,
360  .indicate = oss_indicate,
361  .fixup = oss_fixup,
362 };
363 
364 /*!
365  * \brief returns a pointer to the descriptor with the given name
366  */
367 static struct chan_oss_pvt *find_desc(const char *dev)
368 {
369  struct chan_oss_pvt *o = NULL;
370 
371  if (!dev)
372  ast_log(LOG_WARNING, "null dev\n");
373 
374  for (o = oss_default.next; o && o->name && dev && strcmp(o->name, dev) != 0; o = o->next);
375 
376  if (!o)
377  ast_log(LOG_WARNING, "could not find <%s>\n", dev ? dev : "--no-device--");
378 
379  return o;
380 }
381 
382 /* !
383  * \brief split a string in extension-context, returns pointers to malloc'ed
384  * strings.
385  *
386  * If we do not have 'overridecontext' then the last @ is considered as
387  * a context separator, and the context is overridden.
388  * This is usually not very necessary as you can play with the dialplan,
389  * and it is nice not to need it because you have '@' in SIP addresses.
390  *
391  * \return the buffer address.
392  */
393 static char *ast_ext_ctx(const char *src, char **ext, char **ctx)
394 {
395  struct chan_oss_pvt *o = find_desc(oss_active);
396 
397  if (ext == NULL || ctx == NULL)
398  return NULL; /* error */
399 
400  *ext = *ctx = NULL;
401 
402  if (src && *src != '\0')
403  *ext = ast_strdup(src);
404 
405  if (*ext == NULL)
406  return NULL;
407 
408  if (!o->overridecontext) {
409  /* parse from the right */
410  *ctx = strrchr(*ext, '@');
411  if (*ctx)
412  *(*ctx)++ = '\0';
413  }
414 
415  return *ext;
416 }
417 
418 /*!
419  * \brief Returns the number of blocks used in the audio output channel
420  */
421 static int used_blocks(struct chan_oss_pvt *o)
422 {
423  struct audio_buf_info info;
424 
425  if (ioctl(o->sounddev, SNDCTL_DSP_GETOSPACE, &info)) {
426  if (!(o->warned & WARN_used_blocks)) {
427  ast_log(LOG_WARNING, "Error reading output space\n");
428  o->warned |= WARN_used_blocks;
429  }
430  return 1;
431  }
432 
433  if (o->total_blocks == 0) {
434  if (0) /* debugging */
435  ast_log(LOG_WARNING, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments);
436  o->total_blocks = info.fragments;
437  }
438 
439  return o->total_blocks - info.fragments;
440 }
441 
442 /*! Write an exactly FRAME_SIZE sized frame */
443 static int soundcard_writeframe(struct chan_oss_pvt *o, short *data)
444 {
445  int res;
446 
447  if (o->sounddev < 0)
448  setformat(o, O_RDWR);
449  if (o->sounddev < 0)
450  return 0; /* not fatal */
451  /*
452  * Nothing complex to manage the audio device queue.
453  * If the buffer is full just drop the extra, otherwise write.
454  * XXX in some cases it might be useful to write anyways after
455  * a number of failures, to restart the output chain.
456  */
457  res = used_blocks(o);
458  if (res > o->queuesize) { /* no room to write a block */
459  if (o->w_errors++ == 0 && (oss_debug & 0x4))
460  ast_log(LOG_WARNING, "write: used %d blocks (%d)\n", res, o->w_errors);
461  return 0;
462  }
463  o->w_errors = 0;
464  return write(o->sounddev, (void *)data, FRAME_SIZE * 2);
465 }
466 
467 /*!
468  * reset and close the device if opened,
469  * then open and initialize it in the desired mode,
470  * trigger reads and writes so we can start using it.
471  */
472 static int setformat(struct chan_oss_pvt *o, int mode)
473 {
474  int fmt, desired, res, fd;
475 
476  if (o->sounddev >= 0) {
477  ioctl(o->sounddev, SNDCTL_DSP_RESET, 0);
478  close(o->sounddev);
479  o->duplex = M_UNSET;
480  o->sounddev = -1;
481  }
482  if (mode == O_CLOSE) /* we are done */
483  return 0;
484  if (ast_tvdiff_ms(ast_tvnow(), o->lastopen) < 1000)
485  return -1; /* don't open too often */
486  o->lastopen = ast_tvnow();
487  fd = o->sounddev = open(o->device, mode | O_NONBLOCK);
488  if (fd < 0) {
489  ast_log(LOG_WARNING, "Unable to re-open DSP device %s: %s\n", o->device, strerror(errno));
490  return -1;
491  }
492  if (o->owner)
493  ast_channel_set_fd(o->owner, 0, fd);
494 
495 #if __BYTE_ORDER == __LITTLE_ENDIAN
496  fmt = AFMT_S16_LE;
497 #else
498  fmt = AFMT_S16_BE;
499 #endif
500  res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
501  if (res < 0) {
502  ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
503  return -1;
504  }
505  switch (mode) {
506  case O_RDWR:
507  res = ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
508  /* Check to see if duplex set (FreeBSD Bug) */
509  res = ioctl(fd, SNDCTL_DSP_GETCAPS, &fmt);
510  if (res == 0 && (fmt & DSP_CAP_DUPLEX)) {
511  ast_verb(2, "Console is full duplex\n");
512  o->duplex = M_FULL;
513  };
514  break;
515 
516  case O_WRONLY:
517  o->duplex = M_WRITE;
518  break;
519 
520  case O_RDONLY:
521  o->duplex = M_READ;
522  break;
523  }
524 
525  fmt = 0;
526  res = ioctl(fd, SNDCTL_DSP_STEREO, &fmt);
527  if (res < 0) {
528  ast_log(LOG_WARNING, "Failed to set audio device to mono\n");
529  return -1;
530  }
531  fmt = desired = DEFAULT_SAMPLE_RATE; /* 8000 Hz desired */
532  res = ioctl(fd, SNDCTL_DSP_SPEED, &fmt);
533 
534  if (res < 0) {
535  ast_log(LOG_WARNING, "Failed to set sample rate to %d\n", desired);
536  return -1;
537  }
538  if (fmt != desired) {
539  if (!(o->warned & WARN_speed)) {
541  "Requested %d Hz, got %d Hz -- sound may be choppy\n",
542  desired, fmt);
543  o->warned |= WARN_speed;
544  }
545  }
546  /*
547  * on Freebsd, SETFRAGMENT does not work very well on some cards.
548  * Default to use 256 bytes, let the user override
549  */
550  if (o->frags) {
551  fmt = o->frags;
552  res = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fmt);
553  if (res < 0) {
554  if (!(o->warned & WARN_frag)) {
556  "Unable to set fragment size -- sound may be choppy\n");
557  o->warned |= WARN_frag;
558  }
559  }
560  }
561  /* on some cards, we need SNDCTL_DSP_SETTRIGGER to start outputting */
562  res = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT;
563  res = ioctl(fd, SNDCTL_DSP_SETTRIGGER, &res);
564  /* it may fail if we are in half duplex, never mind */
565  return 0;
566 }
567 
568 /*
569  * some of the standard methods supported by channels.
570  */
571 static int oss_digit_begin(struct ast_channel *c, char digit)
572 {
573  return 0;
574 }
575 
576 static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration)
577 {
578  /* no better use for received digits than print them */
579  ast_verbose(" << Console Received digit %c of duration %u ms >> \n",
580  digit, duration);
581  return 0;
582 }
583 
584 static int oss_text(struct ast_channel *c, const char *text)
585 {
586  /* print received messages */
587  ast_verbose(" << Console Received text %s >> \n", text);
588  return 0;
589 }
590 
591 /*!
592  * \brief handler for incoming calls. Either autoanswer, or start ringing
593  */
594 static int oss_call(struct ast_channel *c, char *dest, int timeout)
595 {
596  struct chan_oss_pvt *o = c->tech_pvt;
597  struct ast_frame f = { AST_FRAME_CONTROL, };
599  AST_APP_ARG(name);
601  );
602  char *parse = ast_strdupa(dest);
603 
604  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
605 
606  ast_verbose(" << Call to device '%s' dnid '%s' rdnis '%s' on console from '%s' <%s> >>\n",
607  dest,
608  S_OR(c->dialed.number.str, ""),
610  S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
611  S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""));
612  if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "answer") == 0) {
614  ast_queue_frame(c, &f);
615  } else if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "noanswer") == 0) {
617  ast_queue_frame(c, &f);
619  } else if (o->autoanswer) {
620  ast_verbose(" << Auto-answered >> \n");
622  ast_queue_frame(c, &f);
623  o->hookstate = 1;
624  } else {
625  ast_verbose("<< Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
627  ast_queue_frame(c, &f);
629  }
630  return 0;
631 }
632 
633 /*!
634  * \brief remote side answered the phone
635  */
636 static int oss_answer(struct ast_channel *c)
637 {
638  struct chan_oss_pvt *o = c->tech_pvt;
639  ast_verbose(" << Console call has been answered >> \n");
641  o->hookstate = 1;
642  return 0;
643 }
644 
645 static int oss_hangup(struct ast_channel *c)
646 {
647  struct chan_oss_pvt *o = c->tech_pvt;
648 
649  c->tech_pvt = NULL;
650  o->owner = NULL;
651  ast_verbose(" << Hangup on console >> \n");
654  if (o->hookstate) {
655  if (o->autoanswer || o->autohangup) {
656  /* Assume auto-hangup too */
657  o->hookstate = 0;
658  setformat(o, O_CLOSE);
659  }
660  }
661  return 0;
662 }
663 
664 /*! \brief used for data coming from the network */
665 static int oss_write(struct ast_channel *c, struct ast_frame *f)
666 {
667  int src;
668  struct chan_oss_pvt *o = c->tech_pvt;
669 
670  /*
671  * we could receive a block which is not a multiple of our
672  * FRAME_SIZE, so buffer it locally and write to the device
673  * in FRAME_SIZE chunks.
674  * Keep the residue stored for future use.
675  */
676  src = 0; /* read position into f->data */
677  while (src < f->datalen) {
678  /* Compute spare room in the buffer */
679  int l = sizeof(o->oss_write_buf) - o->oss_write_dst;
680 
681  if (f->datalen - src >= l) { /* enough to fill a frame */
682  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
683  soundcard_writeframe(o, (short *) o->oss_write_buf);
684  src += l;
685  o->oss_write_dst = 0;
686  } else { /* copy residue */
687  l = f->datalen - src;
688  memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l);
689  src += l; /* but really, we are done */
690  o->oss_write_dst += l;
691  }
692  }
693  return 0;
694 }
695 
696 static struct ast_frame *oss_read(struct ast_channel *c)
697 {
698  int res;
699  struct chan_oss_pvt *o = c->tech_pvt;
700  struct ast_frame *f = &o->read_f;
701 
702  /* XXX can be simplified returning &ast_null_frame */
703  /* prepare a NULL frame in case we don't have enough data to return */
704  memset(f, '\0', sizeof(struct ast_frame));
706  f->src = oss_tech.type;
707 
708  res = read(o->sounddev, o->oss_read_buf + o->readpos, sizeof(o->oss_read_buf) - o->readpos);
709  if (res < 0) /* audio data not ready, return a NULL frame */
710  return f;
711 
712  o->readpos += res;
713  if (o->readpos < sizeof(o->oss_read_buf)) /* not enough samples */
714  return f;
715 
716  if (o->mute)
717  return f;
718 
719  o->readpos = AST_FRIENDLY_OFFSET; /* reset read pointer for next frame */
720  if (c->_state != AST_STATE_UP) /* drop data if frame is not up */
721  return f;
722  /* ok we can build and deliver the frame to the caller */
725  f->samples = FRAME_SIZE;
726  f->datalen = FRAME_SIZE * 2;
728  if (o->boost != BOOST_SCALE) { /* scale and clip values */
729  int i, x;
730  int16_t *p = (int16_t *) f->data.ptr;
731  for (i = 0; i < f->samples; i++) {
732  x = (p[i] * o->boost) / BOOST_SCALE;
733  if (x > 32767)
734  x = 32767;
735  else if (x < -32768)
736  x = -32768;
737  p[i] = x;
738  }
739  }
740 
742  return f;
743 }
744 
745 static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
746 {
747  struct chan_oss_pvt *o = newchan->tech_pvt;
748  o->owner = newchan;
749  return 0;
750 }
751 
752 static int oss_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
753 {
754  struct chan_oss_pvt *o = c->tech_pvt;
755  int res = 0;
756 
757  switch (cond) {
759  case AST_CONTROL_BUSY:
761  case AST_CONTROL_RINGING:
762  case -1:
763  res = -1;
764  break;
769  break;
770  case AST_CONTROL_HOLD:
771  ast_verbose(" << Console Has Been Placed on Hold >> \n");
772  ast_moh_start(c, data, o->mohinterpret);
773  break;
774  case AST_CONTROL_UNHOLD:
775  ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
776  ast_moh_stop(c);
777  break;
778  default:
779  ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, c->name);
780  return -1;
781  }
782 
783  return res;
784 }
785 
786 /*!
787  * \brief allocate a new channel.
788  */
789 static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const char *linkedid)
790 {
791  struct ast_channel *c;
792 
793  c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Console/%s", o->device + 5);
794  if (c == NULL)
795  return NULL;
796  c->tech = &oss_tech;
797  if (o->sounddev < 0)
798  setformat(o, O_RDWR);
799  ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
801  /* if the console makes the call, add video to the offer */
802  if (state == AST_STATE_RINGING)
804 
807  c->tech_pvt = o;
808 
809  if (!ast_strlen_zero(o->language))
811  /* Don't use ast_set_callerid() here because it will
812  * generate a needless NewCallerID event */
813  if (!ast_strlen_zero(o->cid_num)) {
814  c->caller.ani.number.valid = 1;
816  }
817  if (!ast_strlen_zero(ext)) {
818  c->dialed.number.str = ast_strdup(ext);
819  }
820 
821  o->owner = c;
824  if (state != AST_STATE_DOWN) {
825  if (ast_pbx_start(c)) {
826  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
827  ast_hangup(c);
828  o->owner = c = NULL;
829  }
830  }
831  console_video_start(get_video_desc(c), c); /* XXX cleanup */
832 
833  return c;
834 }
835 
836 static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
837 {
838  struct ast_channel *c;
839  struct chan_oss_pvt *o;
841  AST_APP_ARG(name);
842  AST_APP_ARG(flags);
843  );
844  char *parse = ast_strdupa(data);
845  char buf[256];
846 
847  AST_NONSTANDARD_APP_ARGS(args, parse, '/');
848  o = find_desc(args.name);
849 
850  ast_log(LOG_WARNING, "oss_request ty <%s> data 0x%p <%s>\n", type, data, (char *) data);
851  if (o == NULL) {
852  ast_log(LOG_NOTICE, "Device %s not found\n", args.name);
853  /* XXX we could default to 'dsp' perhaps ? */
854  return NULL;
855  }
856  if ((format & AST_FORMAT_SLINEAR) == 0) {
857  ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), format));
858  return NULL;
859  }
860  if (o->owner) {
861  ast_log(LOG_NOTICE, "Already have a call (chan %p) on the OSS channel\n", o->owner);
862  *cause = AST_CAUSE_BUSY;
863  return NULL;
864  }
865  c = oss_new(o, NULL, NULL, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL);
866  if (c == NULL) {
867  ast_log(LOG_WARNING, "Unable to create new OSS channel\n");
868  return NULL;
869  }
870  return c;
871 }
872 
873 static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value);
874 
875 /*! Generic console command handler. Basically a wrapper for a subset
876  * of config file options which are also available from the CLI
877  */
878 static char *console_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
879 {
880  struct chan_oss_pvt *o = find_desc(oss_active);
881  const char *var, *value;
882  switch (cmd) {
883  case CLI_INIT:
885  e->usage =
886  "Usage: " CONSOLE_VIDEO_CMDS "...\n"
887  " Generic handler for console commands.\n";
888  return NULL;
889 
890  case CLI_GENERATE:
891  return NULL;
892  }
893 
894  if (a->argc < e->args)
895  return CLI_SHOWUSAGE;
896  if (o == NULL) {
897  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
898  oss_active);
899  return CLI_FAILURE;
900  }
901  var = a->argv[e->args-1];
902  value = a->argc > e->args ? a->argv[e->args] : NULL;
903  if (value) /* handle setting */
904  store_config_core(o, var, value);
905  if (!console_video_cli(o->env, var, a->fd)) /* print video-related values */
906  return CLI_SUCCESS;
907  /* handle other values */
908  if (!strcasecmp(var, "device")) {
909  ast_cli(a->fd, "device is [%s]\n", o->device);
910  }
911  return CLI_SUCCESS;
912 }
913 
914 static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
915 {
916  struct chan_oss_pvt *o = find_desc(oss_active);
917 
918  switch (cmd) {
919  case CLI_INIT:
920  e->command = "console {set|show} autoanswer [on|off]";
921  e->usage =
922  "Usage: console {set|show} autoanswer [on|off]\n"
923  " Enables or disables autoanswer feature. If used without\n"
924  " argument, displays the current on/off status of autoanswer.\n"
925  " The default value of autoanswer is in 'oss.conf'.\n";
926  return NULL;
927 
928  case CLI_GENERATE:
929  return NULL;
930  }
931 
932  if (a->argc == e->args - 1) {
933  ast_cli(a->fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
934  return CLI_SUCCESS;
935  }
936  if (a->argc != e->args)
937  return CLI_SHOWUSAGE;
938  if (o == NULL) {
939  ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
940  oss_active);
941  return CLI_FAILURE;
942  }
943  if (!strcasecmp(a->argv[e->args-1], "on"))
944  o->autoanswer = 1;
945  else if (!strcasecmp(a->argv[e->args - 1], "off"))
946  o->autoanswer = 0;
947  else
948  return CLI_SHOWUSAGE;
949  return CLI_SUCCESS;
950 }
951 
952 /*! \brief helper function for the answer key/cli command */
953 static char *console_do_answer(int fd)
954 {
955  struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
956  struct chan_oss_pvt *o = find_desc(oss_active);
957  if (!o->owner) {
958  if (fd > -1)
959  ast_cli(fd, "No one is calling us\n");
960  return CLI_FAILURE;
961  }
962  o->hookstate = 1;
963  ast_queue_frame(o->owner, &f);
964  return CLI_SUCCESS;
965 }
966 
967 /*!
968  * \brief answer command from the console
969  */
970 static char *console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
971 {
972  switch (cmd) {
973  case CLI_INIT:
974  e->command = "console answer";
975  e->usage =
976  "Usage: console answer\n"
977  " Answers an incoming call on the console (OSS) channel.\n";
978  return NULL;
979 
980  case CLI_GENERATE:
981  return NULL; /* no completion */
982  }
983  if (a->argc != e->args)
984  return CLI_SHOWUSAGE;
985  return console_do_answer(a->fd);
986 }
987 
988 /*!
989  * \brief Console send text CLI command
990  *
991  * \note concatenate all arguments into a single string. argv is NULL-terminated
992  * so we can use it right away
993  */
994 static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
995 {
996  struct chan_oss_pvt *o = find_desc(oss_active);
997  char buf[TEXT_SIZE];
998 
999  if (cmd == CLI_INIT) {
1000  e->command = "console send text";
1001  e->usage =
1002  "Usage: console send text <message>\n"
1003  " Sends a text message for display on the remote terminal.\n";
1004  return NULL;
1005  } else if (cmd == CLI_GENERATE)
1006  return NULL;
1007 
1008  if (a->argc < e->args + 1)
1009  return CLI_SHOWUSAGE;
1010  if (!o->owner) {
1011  ast_cli(a->fd, "Not in a call\n");
1012  return CLI_FAILURE;
1013  }
1014  ast_join(buf, sizeof(buf) - 1, a->argv + e->args);
1015  if (!ast_strlen_zero(buf)) {
1016  struct ast_frame f = { 0, };
1017  int i = strlen(buf);
1018  buf[i] = '\n';
1020  f.subclass.integer = 0;
1021  f.data.ptr = buf;
1022  f.datalen = i + 1;
1023  ast_queue_frame(o->owner, &f);
1024  }
1025  return CLI_SUCCESS;
1026 }
1027 
1028 static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1029 {
1030  struct chan_oss_pvt *o = find_desc(oss_active);
1031 
1032  if (cmd == CLI_INIT) {
1033  e->command = "console hangup";
1034  e->usage =
1035  "Usage: console hangup\n"
1036  " Hangs up any call currently placed on the console.\n";
1037  return NULL;
1038  } else if (cmd == CLI_GENERATE)
1039  return NULL;
1040 
1041  if (a->argc != e->args)
1042  return CLI_SHOWUSAGE;
1043  if (!o->owner && !o->hookstate) { /* XXX maybe only one ? */
1044  ast_cli(a->fd, "No call to hang up\n");
1045  return CLI_FAILURE;
1046  }
1047  o->hookstate = 0;
1048  if (o->owner)
1050  setformat(o, O_CLOSE);
1051  return CLI_SUCCESS;
1052 }
1053 
1054 static char *console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1055 {
1056  struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH } };
1057  struct chan_oss_pvt *o = find_desc(oss_active);
1058 
1059  if (cmd == CLI_INIT) {
1060  e->command = "console flash";
1061  e->usage =
1062  "Usage: console flash\n"
1063  " Flashes the call currently placed on the console.\n";
1064  return NULL;
1065  } else if (cmd == CLI_GENERATE)
1066  return NULL;
1067 
1068  if (a->argc != e->args)
1069  return CLI_SHOWUSAGE;
1070  if (!o->owner) { /* XXX maybe !o->hookstate too ? */
1071  ast_cli(a->fd, "No call to flash\n");
1072  return CLI_FAILURE;
1073  }
1074  o->hookstate = 0;
1075  if (o->owner)
1076  ast_queue_frame(o->owner, &f);
1077  return CLI_SUCCESS;
1078 }
1079 
1080 static char *console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1081 {
1082  char *s = NULL;
1083  char *mye = NULL, *myc = NULL;
1084  struct chan_oss_pvt *o = find_desc(oss_active);
1085 
1086  if (cmd == CLI_INIT) {
1087  e->command = "console dial";
1088  e->usage =
1089  "Usage: console dial [extension[@context]]\n"
1090  " Dials a given extension (and context if specified)\n";
1091  return NULL;
1092  } else if (cmd == CLI_GENERATE)
1093  return NULL;
1094 
1095  if (a->argc > e->args + 1)
1096  return CLI_SHOWUSAGE;
1097  if (o->owner) { /* already in a call */
1098  int i;
1099  struct ast_frame f = { AST_FRAME_DTMF, { 0 } };
1100  const char *s;
1101 
1102  if (a->argc == e->args) { /* argument is mandatory here */
1103  ast_cli(a->fd, "Already in a call. You can only dial digits until you hangup.\n");
1104  return CLI_FAILURE;
1105  }
1106  s = a->argv[e->args];
1107  /* send the string one char at a time */
1108  for (i = 0; i < strlen(s); i++) {
1109  f.subclass.integer = s[i];
1110  ast_queue_frame(o->owner, &f);
1111  }
1112  return CLI_SUCCESS;
1113  }
1114  /* if we have an argument split it into extension and context */
1115  if (a->argc == e->args + 1)
1116  s = ast_ext_ctx(a->argv[e->args], &mye, &myc);
1117  /* supply default values if needed */
1118  if (mye == NULL)
1119  mye = o->ext;
1120  if (myc == NULL)
1121  myc = o->ctx;
1122  if (ast_exists_extension(NULL, myc, mye, 1, NULL)) {
1123  o->hookstate = 1;
1124  oss_new(o, mye, myc, AST_STATE_RINGING, NULL);
1125  } else
1126  ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
1127  if (s)
1128  ast_free(s);
1129  return CLI_SUCCESS;
1130 }
1131 
1132 static char *console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1133 {
1134  struct chan_oss_pvt *o = find_desc(oss_active);
1135  const char *s;
1136  int toggle = 0;
1137 
1138  if (cmd == CLI_INIT) {
1139  e->command = "console {mute|unmute} [toggle]";
1140  e->usage =
1141  "Usage: console {mute|unmute} [toggle]\n"
1142  " Mute/unmute the microphone.\n";
1143  return NULL;
1144  } else if (cmd == CLI_GENERATE)
1145  return NULL;
1146 
1147  if (a->argc > e->args)
1148  return CLI_SHOWUSAGE;
1149  if (a->argc == e->args) {
1150  if (strcasecmp(a->argv[e->args-1], "toggle"))
1151  return CLI_SHOWUSAGE;
1152  toggle = 1;
1153  }
1154  s = a->argv[e->args-2];
1155  if (!strcasecmp(s, "mute"))
1156  o->mute = toggle ? !o->mute : 1;
1157  else if (!strcasecmp(s, "unmute"))
1158  o->mute = toggle ? !o->mute : 0;
1159  else
1160  return CLI_SHOWUSAGE;
1161  ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
1162  return CLI_SUCCESS;
1163 }
1164 
1165 static char *console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1166 {
1167  struct chan_oss_pvt *o = find_desc(oss_active);
1168  struct ast_channel *b = NULL;
1169  char *tmp, *ext, *ctx;
1170 
1171  switch (cmd) {
1172  case CLI_INIT:
1173  e->command = "console transfer";
1174  e->usage =
1175  "Usage: console transfer <extension>[@context]\n"
1176  " Transfers the currently connected call to the given extension (and\n"
1177  " context if specified)\n";
1178  return NULL;
1179  case CLI_GENERATE:
1180  return NULL;
1181  }
1182 
1183  if (a->argc != 3)
1184  return CLI_SHOWUSAGE;
1185  if (o == NULL)
1186  return CLI_FAILURE;
1187  if (o->owner == NULL || (b = ast_bridged_channel(o->owner)) == NULL) {
1188  ast_cli(a->fd, "There is no call to transfer\n");
1189  return CLI_SUCCESS;
1190  }
1191 
1192  tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
1193  if (ctx == NULL) /* supply default context if needed */
1194  ctx = o->owner->context;
1195  if (!ast_exists_extension(b, ctx, ext, 1,
1196  S_COR(b->caller.id.number.valid, b->caller.id.number.str, NULL))) {
1197  ast_cli(a->fd, "No such extension exists\n");
1198  } else {
1199  ast_cli(a->fd, "Whee, transferring %s to %s@%s.\n", b->name, ext, ctx);
1200  if (ast_async_goto(b, ctx, ext, 1))
1201  ast_cli(a->fd, "Failed to transfer :(\n");
1202  }
1203  if (tmp)
1204  ast_free(tmp);
1205  return CLI_SUCCESS;
1206 }
1207 
1208 static char *console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1209 {
1210  switch (cmd) {
1211  case CLI_INIT:
1212  e->command = "console {set|show} active [<device>]";
1213  e->usage =
1214  "Usage: console active [device]\n"
1215  " If used without a parameter, displays which device is the current\n"
1216  " console. If a device is specified, the console sound device is changed to\n"
1217  " the device specified.\n";
1218  return NULL;
1219  case CLI_GENERATE:
1220  return NULL;
1221  }
1222 
1223  if (a->argc == 3)
1224  ast_cli(a->fd, "active console is [%s]\n", oss_active);
1225  else if (a->argc != 4)
1226  return CLI_SHOWUSAGE;
1227  else {
1228  struct chan_oss_pvt *o;
1229  if (strcmp(a->argv[3], "show") == 0) {
1230  for (o = oss_default.next; o; o = o->next)
1231  ast_cli(a->fd, "device [%s] exists\n", o->name);
1232  return CLI_SUCCESS;
1233  }
1234  o = find_desc(a->argv[3]);
1235  if (o == NULL)
1236  ast_cli(a->fd, "No device [%s] exists\n", a->argv[3]);
1237  else
1238  oss_active = o->name;
1239  }
1240  return CLI_SUCCESS;
1241 }
1242 
1243 /*!
1244  * \brief store the boost factor
1245  */
1246 static void store_boost(struct chan_oss_pvt *o, const char *s)
1247 {
1248  double boost = 0;
1249  if (sscanf(s, "%30lf", &boost) != 1) {
1250  ast_log(LOG_WARNING, "invalid boost <%s>\n", s);
1251  return;
1252  }
1253  if (boost < -BOOST_MAX) {
1254  ast_log(LOG_WARNING, "boost %s too small, using %d\n", s, -BOOST_MAX);
1255  boost = -BOOST_MAX;
1256  } else if (boost > BOOST_MAX) {
1257  ast_log(LOG_WARNING, "boost %s too large, using %d\n", s, BOOST_MAX);
1258  boost = BOOST_MAX;
1259  }
1260  boost = exp(log(10) * boost / 20) * BOOST_SCALE;
1261  o->boost = boost;
1262  ast_log(LOG_WARNING, "setting boost %s to %d\n", s, o->boost);
1263 }
1264 
1265 static char *console_boost(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1266 {
1267  struct chan_oss_pvt *o = find_desc(oss_active);
1268 
1269  switch (cmd) {
1270  case CLI_INIT:
1271  e->command = "console boost";
1272  e->usage =
1273  "Usage: console boost [boost in dB]\n"
1274  " Sets or display mic boost in dB\n";
1275  return NULL;
1276  case CLI_GENERATE:
1277  return NULL;
1278  }
1279 
1280  if (a->argc == 2)
1281  ast_cli(a->fd, "boost currently %5.1f\n", 20 * log10(((double) o->boost / (double) BOOST_SCALE)));
1282  else if (a->argc == 3)
1283  store_boost(o, a->argv[2]);
1284  return CLI_SUCCESS;
1285 }
1286 
1287 static struct ast_cli_entry cli_oss[] = {
1288  AST_CLI_DEFINE(console_answer, "Answer an incoming console call"),
1289  AST_CLI_DEFINE(console_hangup, "Hangup a call on the console"),
1290  AST_CLI_DEFINE(console_flash, "Flash a call on the console"),
1291  AST_CLI_DEFINE(console_dial, "Dial an extension on the console"),
1292  AST_CLI_DEFINE(console_mute, "Disable/Enable mic input"),
1293  AST_CLI_DEFINE(console_transfer, "Transfer a call to a different extension"),
1294  AST_CLI_DEFINE(console_cmd, "Generic console command"),
1295  AST_CLI_DEFINE(console_sendtext, "Send text to the remote device"),
1296  AST_CLI_DEFINE(console_autoanswer, "Sets/displays autoanswer"),
1297  AST_CLI_DEFINE(console_boost, "Sets/displays mic boost in dB"),
1298  AST_CLI_DEFINE(console_active, "Sets/displays active console"),
1299 };
1300 
1301 /*!
1302  * store the mixer argument from the config file, filtering possibly
1303  * invalid or dangerous values (the string is used as argument for
1304  * system("mixer %s")
1305  */
1306 static void store_mixer(struct chan_oss_pvt *o, const char *s)
1307 {
1308  int i;
1309 
1310  for (i = 0; i < strlen(s); i++) {
1311  if (!isalnum(s[i]) && strchr(" \t-/", s[i]) == NULL) {
1312  ast_log(LOG_WARNING, "Suspect char %c in mixer cmd, ignoring:\n\t%s\n", s[i], s);
1313  return;
1314  }
1315  }
1316  if (o->mixer_cmd)
1317  ast_free(o->mixer_cmd);
1318  o->mixer_cmd = ast_strdup(s);
1319  ast_log(LOG_WARNING, "setting mixer %s\n", s);
1320 }
1321 
1322 /*!
1323  * store the callerid components
1324  */
1325 static void store_callerid(struct chan_oss_pvt *o, const char *s)
1326 {
1327  ast_callerid_split(s, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
1328 }
1329 
1330 static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
1331 {
1332  CV_START(var, value);
1333 
1334  /* handle jb conf */
1335  if (!ast_jb_read_conf(&global_jbconf, var, value))
1336  return;
1337 
1338  if (!console_video_config(&o->env, var, value))
1339  return; /* matched there */
1340  CV_BOOL("autoanswer", o->autoanswer);
1341  CV_BOOL("autohangup", o->autohangup);
1342  CV_BOOL("overridecontext", o->overridecontext);
1343  CV_STR("device", o->device);
1344  CV_UINT("frags", o->frags);
1345  CV_UINT("debug", oss_debug);
1346  CV_UINT("queuesize", o->queuesize);
1347  CV_STR("context", o->ctx);
1348  CV_STR("language", o->language);
1349  CV_STR("mohinterpret", o->mohinterpret);
1350  CV_STR("extension", o->ext);
1351  CV_F("mixer", store_mixer(o, value));
1352  CV_F("callerid", store_callerid(o, value)) ;
1353  CV_F("boost", store_boost(o, value));
1354 
1355  CV_END;
1356 }
1357 
1358 /*!
1359  * grab fields from the config file, init the descriptor and open the device.
1360  */
1361 static struct chan_oss_pvt *store_config(struct ast_config *cfg, char *ctg)
1362 {
1363  struct ast_variable *v;
1364  struct chan_oss_pvt *o;
1365 
1366  if (ctg == NULL) {
1367  o = &oss_default;
1368  ctg = "general";
1369  } else {
1370  if (!(o = ast_calloc(1, sizeof(*o))))
1371  return NULL;
1372  *o = oss_default;
1373  /* "general" is also the default thing */
1374  if (strcmp(ctg, "general") == 0) {
1375  o->name = ast_strdup("dsp");
1376  oss_active = o->name;
1377  goto openit;
1378  }
1379  o->name = ast_strdup(ctg);
1380  }
1381 
1382  strcpy(o->mohinterpret, "default");
1383 
1384  o->lastopen = ast_tvnow(); /* don't leave it 0 or tvdiff may wrap */
1385  /* fill other fields from configuration */
1386  for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
1387  store_config_core(o, v->name, v->value);
1388  }
1389  if (ast_strlen_zero(o->device))
1390  ast_copy_string(o->device, DEV_DSP, sizeof(o->device));
1391  if (o->mixer_cmd) {
1392  char *cmd;
1393 
1394  if (ast_asprintf(&cmd, "mixer %s", o->mixer_cmd) >= 0) {
1395  ast_log(LOG_WARNING, "running [%s]\n", cmd);
1396  if (system(cmd) < 0) {
1397  ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno));
1398  }
1399  ast_free(cmd);
1400  }
1401  }
1402 
1403  /* if the config file requested to start the GUI, do it */
1404  if (get_gui_startup(o->env))
1405  console_video_start(o->env, NULL);
1406 
1407  if (o == &oss_default) /* we are done with the default */
1408  return NULL;
1409 
1410 openit:
1411 #ifdef TRYOPEN
1412  if (setformat(o, O_RDWR) < 0) { /* open device */
1413  ast_verb(1, "Device %s not detected\n", ctg);
1414  ast_verb(1, "Turn off OSS support by adding " "'noload=chan_oss.so' in /etc/asterisk/modules.conf\n");
1415  goto error;
1416  }
1417  if (o->duplex != M_FULL)
1418  ast_log(LOG_WARNING, "XXX I don't work right with non " "full-duplex sound cards XXX\n");
1419 #endif /* TRYOPEN */
1420 
1421  /* link into list of devices */
1422  if (o != &oss_default) {
1423  o->next = oss_default.next;
1424  oss_default.next = o;
1425  }
1426  return o;
1427 
1428 #ifdef TRYOPEN
1429 error:
1430  if (o != &oss_default)
1431  ast_free(o);
1432  return NULL;
1433 #endif
1434 }
1435 
1436 static int load_module(void)
1437 {
1438  struct ast_config *cfg = NULL;
1439  char *ctg = NULL;
1440  struct ast_flags config_flags = { 0 };
1441 
1442  /* Copy the default jb config over global_jbconf */
1443  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
1444 
1445  /* load config file */
1446  if (!(cfg = ast_config_load(config, config_flags))) {
1447  ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
1448  return AST_MODULE_LOAD_DECLINE;
1449  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
1450  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
1451  return AST_MODULE_LOAD_DECLINE;
1452  }
1453 
1454  do {
1455  store_config(cfg, ctg);
1456  } while ( (ctg = ast_category_browse(cfg, ctg)) != NULL);
1457 
1458  ast_config_destroy(cfg);
1459 
1460  if (find_desc(oss_active) == NULL) {
1461  ast_log(LOG_NOTICE, "Device %s not found\n", oss_active);
1462  /* XXX we could default to 'dsp' perhaps ? */
1463  /* XXX should cleanup allocated memory etc. */
1464  return AST_MODULE_LOAD_FAILURE;
1465  }
1466 
1467  oss_tech.capabilities |= console_video_formats;
1468 
1469  if (ast_channel_register(&oss_tech)) {
1470  ast_log(LOG_ERROR, "Unable to register channel type 'OSS'\n");
1471  return AST_MODULE_LOAD_DECLINE;
1472  }
1473 
1474  ast_cli_register_multiple(cli_oss, ARRAY_LEN(cli_oss));
1475 
1476  return AST_MODULE_LOAD_SUCCESS;
1477 }
1478 
1479 
1480 static int unload_module(void)
1481 {
1482  struct chan_oss_pvt *o, *next;
1483 
1484  ast_channel_unregister(&oss_tech);
1485  ast_cli_unregister_multiple(cli_oss, ARRAY_LEN(cli_oss));
1486 
1487  o = oss_default.next;
1488  while (o) {
1489  close(o->sounddev);
1490  if (o->owner)
1492  if (o->owner)
1493  return -1;
1494  next = o->next;
1495  ast_free(o->name);
1496  ast_free(o);
1497  o = next;
1498  }
1499  return 0;
1500 }
1501 
1502 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "OSS Console Channel Driver");
int w_errors
Definition: chan_oss.c:265
struct chan_oss_pvt * next
Definition: chan_oss.c:248
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static void store_mixer(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1306
Main Channel structure associated with a channel.
Definition: channel.h:742
char ctx[AST_MAX_CONTEXT]
Definition: chan_oss.c:286
Music on hold handling.
#define AST_CLI_DEFINE(fn, txt,...)
Definition: cli.h:191
static char * console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:914
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:396
const char *const type
Definition: channel.h:508
enum chan_oss_pvt::@98 duplex
Asterisk main include file. File version handling, generic pbx functions.
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int offset
Definition: frame.h:156
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
void ast_module_unref(struct ast_module *)
Definition: loader.c:1312
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
static char * config
Definition: chan_oss.c:235
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1093
format_t capabilities
Definition: channel.h:511
#define TEXT_SIZE
Definition: chan_oss.c:222
static int unload_module(void)
Definition: chan_oss.c:1480
#define ast_strdup(a)
Definition: astmm.h:109
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
format_t writeformat
Definition: channel.h:854
#define DEFAULT_SAMPLE_RATE
Definition: asterisk.h:41
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
unsigned int queuesize
Definition: chan_oss.c:258
#define WARN_speed
Definition: chan_oss.c:263
static char * console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
answer command from the console
Definition: chan_oss.c:970
static struct ast_channel_tech oss_tech
Definition: chan_oss.c:346
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
#define CV_STR(__x, __dst)
Definition: config.h:744
#define MAX_MUSICCLASS
Definition: channel.h:139
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:938
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void * ptr
Definition: frame.h:160
void * tech_pvt
Definition: channel.h:744
#define CONSOLE_VIDEO_CMDS
Definition: console_video.h:27
#define O_CLOSE
Definition: chan_oss.c:227
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
static char * oss_active
Definition: chan_oss.c:306
static int oss_digit_begin(struct ast_channel *c, char digit)
Definition: chan_oss.c:571
descriptor for a cli entry.
Definition: cli.h:165
const int argc
Definition: cli.h:154
#define LOG_WARNING
Definition: logger.h:144
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:5879
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
static char * console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1132
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:577
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
static int oss_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen)
Definition: chan_oss.c:752
#define CV_UINT(__x, __dst)
Definition: config.h:743
pthread_t sthread
Definition: chan_oss.c:279
#define AST_FRAME_DTMF
Definition: frame.h:128
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
static char * console_do_answer(int fd)
helper function for the answer key/cli command
Definition: chan_oss.c:953
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
Definition: cli.h:146
int autohangup
Definition: chan_oss.c:255
static char * ast_ext_ctx(const char *src, char **ext, char **ctx)
Definition: chan_oss.c:393
char * str
Subscriber name (Malloced)
Definition: channel.h:214
void console_video_start(struct video_desc *env, struct ast_channel *owner)
for(;;)
Definition: ast_expr2.c:2460
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define QUEUE_SIZE
Definition: chan_oss.c:210
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:907
char * text
Definition: app_queue.c:1091
format_t nativeformats
Definition: channel.h:852
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
format_t codec
Definition: frame.h:137
int console_video_formats
const char * data
Definition: channel.h:755
char oss_write_buf[FRAME_SIZE *2]
Definition: chan_oss.c:293
int value
Definition: syslog.c:39
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
const ast_string_field linkedid
Definition: channel.h:787
const char * ext
Definition: http.c:112
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
static int oss_answer(struct ast_channel *c)
remote side answered the phone
Definition: chan_oss.c:636
#define ast_verb(level,...)
Definition: logger.h:243
int total_blocks
Definition: chan_oss.c:251
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
static int oss_call(struct ast_channel *c, char *dest, int timeout)
handler for incoming calls. Either autoanswer, or start ringing
Definition: chan_oss.c:594
int console_write_video(struct ast_channel *chan, struct ast_frame *f)
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
Definition: channel.c:9825
#define MAX_LANGUAGE
Definition: channel.h:138
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
int args
This gets set in ast_cli_register()
Definition: cli.h:179
static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration)
Definition: chan_oss.c:576
int console_video_config(struct video_desc **penv, const char *var, const char *val)
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_asprintf(a, b, c...)
Definition: astmm.h:121
const char * value
Definition: config.h:79
#define CV_END
close a variable parsing block
Definition: config.h:733
struct ast_module * self
Definition: module.h:227
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
General Asterisk PBX channel definitions.
#define CV_START(__in_var, __in_val)
the macro to open a block for variable parsing
Definition: config.h:727
static char tdesc[]
Definition: chan_oss.c:343
struct ast_party_dialed::@155 number
Dialed/Called number.
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
#define DEV_DSP
Definition: chan_oss.c:232
const char * src
Definition: frame.h:158
const int fd
Definition: cli.h:153
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
#define WARN_frag
Definition: chan_oss.c:264
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
unsigned int frags
Definition: chan_oss.c:259
ast_cond_t cond
Definition: app_meetme.c:963
#define AST_MAX_EXTENSION
Definition: channel.h:135
int datalen
Definition: frame.h:148
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static int setformat(struct chan_oss_pvt *o, int mode)
Definition: chan_oss.c:472
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
Definition: config.c:810
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2746
int hookstate
Definition: chan_oss.c:256
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
const char * name
Definition: config.h:77
char cid_name[256]
Definition: chan_oss.c:288
static struct ast_channel * oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state, const char *linkedid)
allocate a new channel.
Definition: chan_oss.c:789
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:5400
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
Core PBX routines and definitions.
static char * console_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:878
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
descriptor for one of our channels.
Definition: chan_oss.c:247
static struct chan_oss_pvt * find_desc(const char *dev)
returns a pointer to the descriptor with the given name
Definition: chan_oss.c:367
const char *const * argv
Definition: cli.h:155
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct ast_cli_entry cli_oss[]
Definition: chan_oss.c:1287
#define CV_BOOL(__x, __dst)
helper macros to assign the value to a BOOL, UINT, static string and dynamic string ...
Definition: config.h:742
#define LOG_ERROR
Definition: logger.h:155
char * mixer_cmd
Definition: chan_oss.c:257
int64_t format_t
Definition: frame_defs.h:32
static struct @350 args
#define CLI_SHOWUSAGE
Definition: cli.h:44
static char * console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Console send text CLI command.
Definition: chan_oss.c:994
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static int oss_write(struct ast_channel *chan, struct ast_frame *f)
used for data coming from the network
Definition: chan_oss.c:665
#define LOG_NOTICE
Definition: logger.h:133
static char * console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1208
static char * console_boost(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1265
static int used_blocks(struct chan_oss_pvt *o)
Returns the number of blocks used in the audio output channel.
Definition: chan_oss.c:421
#define CLI_FAILURE
Definition: cli.h:45
int errno
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static const char name[]
#define AST_MAX_CONTEXT
Definition: channel.h:136
char cid_num[256]
Definition: chan_oss.c:289
#define ast_free(a)
Definition: astmm.h:97
char * command
Definition: cli.h:180
static int oss_hangup(struct ast_channel *c)
Definition: chan_oss.c:645
static int oss_text(struct ast_channel *c, const char *text)
Definition: chan_oss.c:584
static void store_callerid(struct chan_oss_pvt *o, const char *s)
Definition: chan_oss.c:1325
void ast_join(char *s, size_t len, const char *const w[])
Definition: utils.c:1690
#define FRAME_SIZE
Definition: chan_oss.c:209
unsigned int flags
Definition: frame.h:166
static struct ast_format f[]
Definition: format_g726.c:181
struct ast_frame read_f
Definition: chan_oss.c:300
char ext[AST_MAX_EXTENSION]
Definition: chan_oss.c:285
struct ast_channel * owner
Definition: chan_oss.c:281
int oss_write_dst
Definition: chan_oss.c:294
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
Definition: abstract_jb.h:58
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
static const char type[]
Definition: chan_nbs.c:57
int console_video_cli(struct video_desc *env, const char *var, int fd)
Structure used to handle boolean flags.
Definition: utils.h:200
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
static struct ast_frame * oss_read(struct ast_channel *chan)
Definition: chan_oss.c:696
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
Definition: abstract_jb.c:616
const char * usage
Definition: cli.h:171
static void store_boost(struct chan_oss_pvt *o, const char *s)
store the boost factor
Definition: chan_oss.c:1246
#define CLI_SUCCESS
Definition: cli.h:43
char * name
Definition: chan_oss.c:250
#define CV_F(__pattern, __body)
call a generic function if the name matches.
Definition: config.h:736
int sounddev
Definition: chan_oss.c:252
#define BOOST_MAX
Definition: chan_oss.c:275
char mohinterpret[MAX_MUSICCLASS]
Definition: chan_oss.c:290
void console_video_uninit(struct video_desc *env)
static int load_module(void)
Definition: chan_oss.c:1436
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
Standard Command Line Interface.
format_t readformat
Definition: channel.h:853
#define ast_calloc(a, b)
Definition: astmm.h:82
static char * console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1028
int get_gui_startup(struct video_desc *env)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
#define WARN_used_blocks
Definition: chan_oss.c:262
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:8731
static char * console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1054
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_CAUSE_BUSY
Definition: causes.h:148
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
Data structure associated with a single frame of data.
Definition: frame.h:142
static struct ast_channel * oss_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Definition: chan_oss.c:836
Internal Asterisk hangup causes.
static char * console_transfer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1165
struct video_desc * env
Definition: chan_oss.c:283
#define FRAGS
Definition: chan_oss.c:215
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
enum ast_frame_type frametype
Definition: frame.h:144
struct ast_variable * next
Definition: config.h:82
char device[64]
Definition: chan_oss.c:277
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
struct timeval lastopen
Definition: chan_oss.c:266
int overridecontext
Definition: chan_oss.c:268
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
static void store_config_core(struct chan_oss_pvt *o, const char *var, const char *value)
Definition: chan_oss.c:1330
int autoanswer
Definition: chan_oss.c:254
static struct ast_jb_conf default_jbconf
Definition: chan_oss.c:71
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the &#39;nonstandard&#39; argument separation process for an application.
Definition: app.h:619
char oss_read_buf[FRAME_SIZE *2+AST_FRIENDLY_OFFSET]
Definition: chan_oss.c:298
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
static int oss_debug
Definition: chan_oss.c:237
static snd_pcm_format_t format
Definition: chan_alsa.c:93
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
char language[MAX_LANGUAGE]
Definition: chan_oss.c:287
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
#define BOOST_SCALE
Definition: chan_oss.c:274
struct video_desc * get_video_desc(struct ast_channel *c)
return the pointer to the video descriptor
Definition: chan_oss.c:309
General jitterbuffer configuration.
Definition: abstract_jb.h:55
static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
Definition: chan_oss.c:745
static char * console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: chan_oss.c:1080
static int soundcard_writeframe(struct chan_oss_pvt *o, short *data)
Definition: chan_oss.c:443
static struct ast_jb_conf global_jbconf
Definition: chan_oss.c:79
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180
static struct chan_oss_pvt oss_default
Definition: chan_oss.c:314
int samples
Definition: frame.h:150
static struct chan_oss_pvt * store_config(struct ast_config *cfg, char *ctg)
Definition: chan_oss.c:1361
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_module * ast_module_ref(struct ast_module *)
Definition: loader.c:1300
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292