Changeset 1684
- Timestamp:
- Jan 12, 2008 2:16:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/mix.c
r1682 r1684 50 50 " options:\n" 51 51 " -c N Set clock rate to N Hz (default 16000)\n" 52 " -f Force write (overwrite output without warning\n" 52 53 ; 53 54 54 55 #define MAX_WAV 16 55 56 #define PTIME 20 57 #define APPEND 1000 56 58 57 59 struct wav_input … … 76 78 pjmedia_endpt *med_ept; 77 79 unsigned clock_rate = 16000; 78 int c ;80 int c, force=0; 79 81 const char *out_fname; 80 82 pjmedia_conf *conf; … … 93 95 94 96 /* Parse arguments */ 95 while ((c=pj_getopt(argc, argv, "c: ")) != -1) {97 while ((c=pj_getopt(argc, argv, "c:f")) != -1) { 96 98 switch (c) { 97 99 case 'c': … … 102 104 } 103 105 break; 106 case 'f': 107 force = 1; 108 break; 104 109 } 105 110 } … … 112 117 113 118 out_fname = argv[pj_optind++]; 114 if ( pj_file_exists(out_fname)) {119 if (force==0 && pj_file_exists(out_fname)) { 115 120 char in[8]; 116 121 … … 167 172 &wav_input[i].port) ); 168 173 len = pjmedia_wav_player_get_len(wav_input[i].port); 169 len = len * clock_rate / wav_input[i].port->info.clock_rate; 174 len = (pj_ssize_t)(len * 1.0 * clock_rate / 175 wav_input[i].port->info.clock_rate); 170 176 if (len > longest) 171 177 longest = len; … … 179 185 /* Loop reading frame from the bridge and write it to WAV */ 180 186 processed = 0; 181 while (processed < longest ) {187 while (processed < longest + clock_rate * APPEND * 2 / 1000) { 182 188 pj_int16_t framebuf[PTIME * 48000 / 1000]; 183 189 pjmedia_port *cp = pjmedia_conf_get_master_port(conf); … … 188 194 pj_assert(frame.size <= sizeof(framebuf)); 189 195 190 status = pjmedia_port_get_frame(cp, &frame); 191 if (status != PJ_SUCCESS) 192 break; 196 CHECK( pjmedia_port_get_frame(cp, &frame) ); 193 197 194 198 CHECK( pjmedia_port_put_frame(wavout, &frame)); … … 196 200 processed += frame.size; 197 201 } 202 203 PJ_LOG(3,(THIS_FILE, "Done. Output duration: %d.%03d", 204 (processed >> 2)/clock_rate, 205 ((processed >> 2)*1000/clock_rate) % 1000)); 198 206 199 207 /* Shutdown everything */
Note: See TracChangeset
for help on using the changeset viewer.