I am working on an open source project called Asterisk, which is a telephone PBX software, and we are trying to make it more OS X friendly. It is originally Linux software.
There is something called music on hold, MOH, that will play a music file to any caller that is put on hold. This is using an external mp3 player called mpg123. I have looked through the examples, and found the PlayFile example.
Is it possible to modify this example to play to a file stream instead of through the computers speakers?
MOH is represented by a plugin called res_musiconhold which is a single source file res_musiconhold.c. This calls an external mpg123 player and feeds the output into an asterisk file stream like so ...
ast_set_write_format(chan, AST_FORMAT_SLINEAR)
and then ...
memset(&f, 0, sizeof(f)); f.frametype = AST_FRAME_VOICE; f.subclass = AST_FORMAT_SLINEAR; f.mallocd = 0; f.datalen = res; f.samples = res / 2; f.data = "" + AST_FRIENDLY_OFFSET / 2; f.offset = AST_FRIENDLY_OFFSET; if (ast_write(chan, &f)< 0) { ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno)); return -1; }
Ivan |