diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-12-22 15:24:11 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-12-22 15:24:11 +0000 |
commit | dd1f7ceda45c9d067ddcde5b659106c7fa2145af (patch) | |
tree | 3c3f200ede744ee6e89b9aa9f21cf02f92340bc0 /pjsip-apps | |
parent | 2372fa12e152c7fb69be5f0288f9a8eaa7372d9c (diff) |
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
Diffstat (limited to 'pjsip-apps')
-rw-r--r-- | pjsip-apps/src/samples/streamutil.c | 33 |
1 files 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. */ |