Hi, We are trying to stream audio coming from calls to an NLP engine to get the text transcription, for this we created a socket in *app_mixmonitor.c* and we are writing audio frames to socket descriptor. We have tried with TCP(SOCK_STREAM) and UDP(SOCK_DGRAM) protocols to send the audio frames to the socket server.
We are using latest asterisk complied from GitHub source code (asterisk repo). Here are some of the suggestions I found on asterisk forums http://forums.asterisk.org/viewtopic.php?f=13&t=89365#p196720 on this thread, it was suggested to use CHANSPY, but we have edited mixmonitor code to both record and stream in realtime, which has sufficed our needs. Here is the socket code we used inside the *mixmonitor_thread* function in app_mixmonitor.c file. + + int sockfd; + char buffer[1024]; + char *hello = "Hello from client"; + struct sockaddr_in servaddr; + + // Creating socket file descriptor + if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { + ast_log(LOG_NOTICE, "socket creation failed"); +// exit(EXIT_FAILURE); + } + + memset(&servaddr, 0, sizeof(servaddr)); + + // Filling server information + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons(8080); + servaddr.sin_addr.s_addr = INADDR_ANY; + + if (connect(sockfd,(struct sockaddr *) &servaddr,sizeof(servaddr)) < 0) + ast_log(LOG_ERROR, "ERROR connecting\n"); + ast_log(LOG_NOTICE, "socket connected with server \n"); + + //socket code ends here and here is the code of writing audio frames to the socket. for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) { ast_writestream(*fs, cur); + // writing to socket + write(sockfd, cur->data.ptr, cur->datalen); } And we were able to see the frames on the other side of the socket. We want to ask you if there is any other better approach to stream audio in real time. Thanks & Regards Manikanta Zemoso Technologies
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
