Home --> Documentations --> PJMEDIA Reference
This example demonstrates how to use Resample Port to change the sampling rate of the media streams.
This file is pjsip-apps/src/samples/resampleplay.c
33 #include <pjlib-util.h> 42 #define THIS_FILE "resampleplay.c" 45 static const char *desc = 52 " Demonstrate how use resample port to play a WAV file to sound \n" 53 " device using different sampling rate. \n" 57 " resampleplay [options] FILE.WAV \n" 62 " The WAV file could have mono or stereo channels with arbitrary \n" 63 " sampling rate, but MUST contain uncompressed (i.e. 16bit) PCM. \n"; 66 int main( int argc, char *argv[]) 78 int sampling_rate = CLOCK_RATE; 79 int channel_count = NCHANNELS; 80 int samples_per_frame = NSAMPLES; 81 int bits_per_sample = NBITS; 91 if (get_snd_options(THIS_FILE, argc, argv, &dev_id, &sampling_rate, 92 &channel_count, &samples_per_frame, &bits_per_sample)) 99 if (!argv[pj_optind]) { 100 puts( "Error: no file is specified"); 127 app_perror(THIS_FILE, "Unable to open file", status); 133 PJ_LOG(3,(THIS_FILE, "Error: file has different number of channels. " 134 "Perhaps you'd need -c option?")); 147 app_perror(THIS_FILE, "Unable to create resample port", status); 164 app_perror(THIS_FILE, "Unable to open sound device", status); 171 app_perror(THIS_FILE, "Error connecting sound ports", status); 177 dump_pool_usage(THIS_FILE, &cp); 188 printf( "Playing %s at sampling rate %d (original file sampling rate=%d)\n", 189 argv[pj_optind], sampling_rate, 192 puts( "Press <ENTER> to stop playing and quit"); 194 if (fgets(tmp, sizeof(tmp), stdin) == NULL) { 195 puts( "EOF while reading stdin, will quit now..");
#define PJ_ASSERT_RETURN(expr, retval)
void pj_pool_release(pj_pool_t *pool)
pj_status_t pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port)
#define PJ_LOG(level, arg)
struct pjmedia_snd_port pjmedia_snd_port Definition: sound_port.h:146
pj_pool_factory_policy pj_pool_factory_default_policy
pj_status_t pjmedia_snd_port_create(pj_pool_t *pool, int rec_id, int play_id, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_snd_port **p_port)
pj_status_t pjmedia_endpt_create(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt) Definition: endpoint.h:128
void pj_caching_pool_init(pj_caching_pool *ch_pool, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
pj_status_t pjmedia_snd_port_connect(pjmedia_snd_port *snd_port, pjmedia_port *port)
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)
pj_status_t pj_thread_sleep(unsigned msec)
pj_status_t pj_init(void)
pj_status_t pjmedia_endpt_destroy(pjmedia_endpt *endpt) Definition: endpoint.h:169
void pj_caching_pool_destroy(pj_caching_pool *ch_pool)
PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.
|