|
Home --> Documentations --> PJMEDIA Reference
This file is pjsip-apps/src/samples/mix.c
29#include <pjlib-util.h>
32#define THIS_FILE "mix.c"
34static const char *desc =
38 " Mix input WAV files and save it to output WAV. Input WAV can have\n"
39 " different clock rate.\n"
43 " mix [options] output.wav input1.wav [input2.wav] ...\n"
46 " output.wav Set the output WAV filename.\n"
47 " input1.wav Set the input WAV filename.\n"
48 " input2.wav Set the input WAV filename.\n"
51 " -c N Set clock rate to N Hz (default 16000)\n"
52 " -f Force write (overwrite output without warning\n"
66static int err_ret( const char *title, pj_status_t status)
70 PJ_LOG(3,(THIS_FILE, "%s error: %s", title, errmsg));
74static void usage( void)
79int main( int argc, char *argv[])
84 unsigned clock_rate = 16000;
86 const char *out_fname;
91 unsigned i, input_cnt = 0;
94#define CHECK(op) do { \
96 if (status != PJ_SUCCESS) \
97 return err_ret(#op, status); \
102 while ((c=pj_getopt(argc, argv, "c:f")) != -1) {
105 clock_rate = atoi(pj_optarg);
106 if (clock_rate < 1000) {
107 puts( "Error: invalid clock rate");
119 if (pj_optind == argc) {
120 puts( "Error: no WAV output is specified");
125 out_fname = argv[pj_optind++];
129 printf( "File %s exists, overwrite? [Y/N] ", out_fname);
131 if (fgets(in, sizeof(in), stdin) == NULL)
138 for (input_cnt=0 ; pj_optind<argc && input_cnt<MAX_WAV;
139 ++pj_optind, ++input_cnt)
142 printf( "Error: input file %s doesn't exist\n",
146 wav_input[input_cnt].fname = argv[pj_optind];
151 if (input_cnt == 0) {
152 puts( "Error: no input WAV is specified");
166 clock_rate * PTIME / 1000, 16,
171 clock_rate * PTIME / 1000,
172 16, 0, 0, &wavout) );
175 for (i=0; i<input_cnt; ++i) {
195 while (processed < longest + clock_rate * APPEND * 2 / 1000) {
200 frame. buf = framebuf;
213 processed += frame. size;
216 PJ_LOG(3,(THIS_FILE, "Done. Output duration: %d.%03d",
217 (processed >> 2)/clock_rate,
218 ((processed >> 2)*1000/clock_rate) % 1000));
222 for (i=0; i<input_cnt; ++i) {
pj_status_t pjlib_util_init(void)
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 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_bool_t pj_file_exists(const char *filename)
#define PJ_LOG(level, arg)
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)
void pj_bzero(void *dst, pj_size_t size)
int pj_tolower(unsigned char c)
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.
|