Home --> Documentations --> PJMEDIA Reference
In this example, we capture audio from the sound device and save it to WAVE file.
- See also
- page_pjmedia_samples_playfile_c
This file is pjsip-apps/src/samples/recfile.c
39#define THIS_FILE "recfile.c"
43#define CLOCK_RATE 44100
45#define SAMPLES_PER_FRAME (NCHANNELS * (CLOCK_RATE * 10 / 1000))
46#define BITS_PER_SAMPLE 16
49static const char *desc =
54 " Record microphone to WAVE file. \n"
57 " recfile FILE.WAV \n"
62static int app_perror( const char *sender, const char *title,
71 printf( "%s: %s [code=%d]\n", title, errmsg, status);
79int main( int argc, char *argv[])
128 app_perror(THIS_FILE, "Unable to open WAV file for writing", status);
144 app_perror(THIS_FILE, "Unable to open sound device", status);
165 printf( "Recodring %s..\n", argv[1]);
167 puts( "Press <ENTER> to stop recording and quit");
169 if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
170 puts( "EOF while reading stdin, will quit now..");
pj_status_t pjmedia_endpt_create(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt) Definition: endpoint.h:127
pj_status_t pjmedia_endpt_destroy(pjmedia_endpt *endpt) Definition: endpoint.h:168
pj_status_t pjmedia_snd_port_connect(pjmedia_snd_port *snd_port, pjmedia_port *port)
pj_status_t pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port)
pj_status_t pjmedia_snd_port_create_rec(pj_pool_t *pool, int index, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_snd_port **p_port)
struct pjmedia_snd_port pjmedia_snd_port Definition: sound_port.h:145
pj_status_t pj_init(void)
void pj_caching_pool_destroy(pj_caching_pool *ch_pool)
void pj_caching_pool_init(pj_caching_pool *ch_pool, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
pj_pool_factory_policy pj_pool_factory_default_policy
pj_pool_t * pj_pool_create(pj_pool_factory *factory, const char *name, pj_size_t initial_size, pj_size_t increment_size, pj_pool_callback *callback)
void pj_pool_release(pj_pool_t *pool)
pj_status_t pj_thread_sleep(unsigned msec)
#define PJ_ASSERT_RETURN(expr, retval)
#define PJ_UNUSED_ARG(arg)
pj_str_t pj_strerror(pj_status_t statcode, char *buf, pj_size_t bufsize)
PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.
|