From dd1f7ceda45c9d067ddcde5b659106c7fa2145af Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 22 Dec 2006 15:24:11 +0000 Subject: Ticket #46: added recording capability in streamutil sample application git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@856 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/samples/streamutil.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pjsip-apps/src/samples/streamutil.c b/pjsip-apps/src/samples/streamutil.c index ed615eb6..cdeed5df 100644 --- a/pjsip-apps/src/samples/streamutil.c +++ b/pjsip-apps/src/samples/streamutil.c @@ -50,8 +50,8 @@ static const char *desc = " specified address. (default: recv only) \n" " --play-file=WAV Send audio from the WAV file instead of from \n" " the sound device. \n" -// " --record-file=WAV Record incoming audio to WAV file instead of \n" -// " playing it to sound device. \n" + " --record-file=WAV Record incoming audio to WAV file instead of \n" + " playing it to sound device. \n" " --send-recv Set stream direction to bidirectional. \n" " --send-only Set stream direction to send only \n" " --recv-only Set stream direction to recv only (default) \n" @@ -393,7 +393,36 @@ int main(int argc, char *argv[]) goto on_exit; } + printf("Playing from WAV file %s..\n", play_file); + } else if (rec_file) { + + status = pjmedia_wav_writer_port_create(pool, rec_file, + stream_port->info.clock_rate, + stream_port->info.channel_count, + stream_port->info.samples_per_frame, + stream_port->info.bits_per_sample, + 0, 0, &rec_file_port); + if (status != PJ_SUCCESS) { + app_perror(THIS_FILE, "Unable to use file", status); + goto on_exit; + } + + status = pjmedia_master_port_create(pool, stream_port, rec_file_port, + 0, &master_port); + if (status != PJ_SUCCESS) { + app_perror(THIS_FILE, "Unable to create master port", status); + goto on_exit; + } + + status = pjmedia_master_port_start(master_port); + if (status != PJ_SUCCESS) { + app_perror(THIS_FILE, "Error starting master port", status); + goto on_exit; + } + + printf("Recording to WAV file %s..\n", rec_file); + } else { /* Create sound device port. */ -- cgit v1.2.3