Home --> Documentations --> PJMEDIA Reference
This is a very simple example to use the WAV File Player and Sound Device Port. In this example, we open both the file and sound device, and connect the two of them, and voila! Sound will be playing the contents of the file.
- See also
- page_pjmedia_samples_recfile_c
This file is pjsip-apps/src/samples/playfile.c
21#include <pjlib-util.h>
61#define THIS_FILE "playfile.c"
64static const char *desc =
71" Demonstrate how to play a WAV file. \n"
75" playfile FILE.WAV \n"
77" The WAV file could have mono or stereo channels with arbitrary \n"
78" sampling rate, but MUST contain uncompressed (i.e. 16bit) PCM. \n";
84int main( int argc, char *argv[])
96 puts( "Error: filename required");
133 app_perror(THIS_FILE, "Unable to use WAV file", status);
149 app_perror(THIS_FILE, "Unable to open sound device", status);
170 printf( "Playing %s..\n", argv[1]);
172 puts( "Press <ENTER> to stop playing and quit");
174 if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
175 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_disconnect(pjmedia_snd_port *snd_port)
pj_status_t pjmedia_snd_port_create_player(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)
pj_status_t pjmedia_snd_port_destroy(pjmedia_snd_port *snd_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)
PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.
|