[Asterisk-Dev] ztplay. How do I talk directly to zap channels?
Ben Miller
bgmiller at nframe.com
Fri Aug 13 07:33:57 MST 2004
I apologize if this is the wrong forum, but I am having trouble finding
information on programming to the zaptel interface directly.
I have a need to provide Music on Hold to another phone system that is
not nearly as flexible as *. The other system will apparently take MOH
from its FXO ports. What I would like to do is use my * box to provide
MOH for them. But I do not want to permanently tie up my Asterisk
process in doing so.
What I would like to do is use mpg123 to play music directly onto a zap
channel. This would provide a very high density flexible way to provide
MOH and leave my * process out of the mix.
I have taken a look at ztmonitor in hopes to understand how I would be
able to reverse the process and read from STDIN and write to a zap
channel. I am calling this new app ztplay. I do not fully understand
the relationship between pseudo channels and real channels, nor where
timing is derived. So please forgive the assumptions related to what I
have done.
I have followed the ztmonitor example and opened a pseudo channel. I
have created a ZT_CONF in ZT_CONT_CONF mode with channel 2 of my zaptel
span. Then, like ztmonitor, I simply loop, copying data from stdin
(instead of a sound card) to the pseudo channel (see code snippet
below). This however does not seem to be working. Can someone please
point me in the right direction of how I should be doing this? Is there
some sample code I could follow? Thanks in advance,
Ben
/* Open Pseudo device */
if ((pfd = pseudo_open()) < 0)
exit(1);
/* Conference them */
memset(&zc, 0, sizeof(zc));
zc.chan = 0;
zc.confno = atoi(argv[1]);
zc.confmode = ZT_CONF_CONF;
if (ioctl(pfd, ZT_SETCONF, &zc) < 0) {
fprintf(stderr, "Unable to conference: %s\n",
strerror(errno));
exit(1);
}
memset(&zc, 0, sizeof(zc));
/* Now, copy from stdin to pseudo */
for (;;) {
memset(buf,0,sizeof(buf));
res = read(0,buf,sizeof(buf));
if (res < 0) {
printf("Res: %d\n",res);
break;
}
if (pfd)
write(pfd, buf, res);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20040813/4c67af45/attachment.htm
More information about the asterisk-dev
mailing list