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