intercom.c
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:1k
- #include <sys/types.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <strings.h>
- #include <sys/ioctl.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include "ixjuser.h"
- int main(int argc, char *argv[])
- {
- int ixj1,ixj2;
- int b1, b2, codec;
- char pname1[80], pname2[80];
- sprintf(pname1, "/dev/ixj%s", argv[1]);
- sprintf(pname2, "/dev/ixj%s", argv[2]);
- codec = atoi(argv[3]);
- ixj1 = open(pname1, O_RDWR);
- ixj2 = open(pname2, O_RDWR);
- b1 = atoi(argv[1]);
- b2 = atoi(argv[2]);
- if(ixj1 <= 0)
- {
- printf("Open failed %sn", pname1);
- exit(0);
- }
- if(ixj2 <= 0)
- {
- printf("Open failed %sn", pname2);
- exit(0);
- }
- if(!ioctl(ixj1, IXJCTL_RING))
- {
- exit(0);
- }
- if(!ioctl(ixj2, IXJCTL_RING))
- {
- exit(0);
- }
- ioctl(ixj1, IXJCTL_REC_CODEC, codec);
- ioctl(ixj1, IXJCTL_PLAY_CODEC, codec);
- ioctl(ixj2, IXJCTL_REC_CODEC, codec);
- ioctl(ixj2, IXJCTL_PLAY_CODEC, codec);
- if(!ioctl(ixj1, IXJCTL_INTERCOM_START, b2))
- {
- printf("Intercom mode on %d to %dn", b1, b2);
- while(ioctl(ixj1, IXJCTL_HOOKSTATE) && ioctl(ixj2, IXJCTL_HOOKSTATE)){}
- // getchar();
- ioctl(ixj1, IXJCTL_INTERCOM_STOP, b2);
- printf("Intercom mode offn");
- }
- else
- {
- printf("Intercom Failuren");
- }
- close(ixj1);
- close(ixj2);
- }