Changeset 412
- Timestamp:
- Apr 27, 2006 10:37:08 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/build/Samples-vc.mak
r408 r412 6 6 7 7 !if "$(BUILD_MODE)" == "debug" 8 BUILD_FLAGS = /MTd /Od /Zi 8 BUILD_FLAGS = /MTd /Od /Zi /W4 9 9 !else 10 BUILD_FLAGS = /Ox /MD /DNDEBUG 10 BUILD_FLAGS = /Ox /MD /DNDEBUG /W4 11 11 !endif 12 12 -
pjproject/trunk/pjsip-apps/src/samples/confsample.c
r361 r412 185 185 186 186 #if RECORDER 187 status = pjmedia_ file_writer_port_create(pool, "confrecord.wav",187 status = pjmedia_wav_writer_port_create( pool, "confrecord.wav", 188 188 clock_rate, channel_count, 189 189 samples_per_frame, … … 205 205 206 206 /* Load the WAV file to file port. */ 207 status = pjmedia_ file_player_port_create(207 status = pjmedia_wav_player_port_create( 208 208 pool, /* pool. */ 209 209 argv[i+pj_optind], /* filename */ 210 0, /* use default ptime */ 210 211 0, /* flags */ 211 212 0, /* buf size */ -
pjproject/trunk/pjsip-apps/src/samples/level.c
r350 r412 45 45 { 46 46 char errmsg[PJ_ERR_MSG_SIZE]; 47 48 PJ_UNUSED_ARG(sender); 47 49 48 50 pj_strerror(status, errmsg, sizeof(errmsg)); … … 97 99 98 100 /* Create file media port from the WAV file */ 99 status = pjmedia_ file_player_port_create(pool, /* memory pool */101 status = pjmedia_wav_player_port_create( pool, /* memory pool */ 100 102 argv[1], /* file to play */ 103 0, /* use default ptime*/ 101 104 0, /* flags */ 102 105 0, /* default buffer */ -
pjproject/trunk/pjsip-apps/src/samples/playfile.c
r407 r412 77 77 78 78 79 PJ_UNUSED_ARG(argc); 80 81 79 82 /* Must init PJLIB first: */ 80 83 status = pj_init(); … … 100 103 101 104 /* Create file media port from the WAV file */ 102 status = pjmedia_ file_player_port_create(pool, /* memory pool */105 status = pjmedia_wav_player_port_create( pool, /* memory pool */ 103 106 argv[1], /* file to play */ 107 20, /* ptime. */ 104 108 0, /* flags */ 105 109 0, /* default buffer */ … … 116 120 pool, /* pool */ 117 121 -1, /* use default dev. */ 118 file_port->info. sample_rate, /* clock rate. */122 file_port->info.clock_rate, /* clock rate. */ 119 123 file_port->info.channel_count, /* # of channels. */ 120 124 file_port->info.samples_per_frame, /* samples per frame. */ -
pjproject/trunk/pjsip-apps/src/samples/playsine.c
r350 r412 48 48 { 49 49 char errmsg[PJ_ERR_MSG_SIZE]; 50 51 PJ_UNUSED_ARG(sender); 50 52 51 53 pj_strerror(status, errmsg, sizeof(errmsg)); … … 128 130 port->info.need_info = 0; 129 131 port->info.pt = 0xFF; 130 port->info. sample_rate = sampling_rate;132 port->info.clock_rate = sampling_rate; 131 133 port->info.samples_per_frame = sampling_rate * 20 / 1000 * channel_count; 132 134 port->info.bytes_per_frame = port->info.samples_per_frame * 2; … … 230 232 pool, /* pool */ 231 233 -1, /* use default dev. */ 232 sine_port->info. sample_rate, /* clock rate. */234 sine_port->info.clock_rate, /* clock rate. */ 233 235 sine_port->info.channel_count, /* # of channels. */ 234 236 sine_port->info.samples_per_frame, /* samples per frame. */ -
pjproject/trunk/pjsip-apps/src/samples/recfile.c
r361 r412 105 105 106 106 /* Create WAVE file writer port. */ 107 status = pjmedia_ file_writer_port_create(pool, argv[1],107 status = pjmedia_wav_writer_port_create( pool, argv[1], 108 108 CLOCK_RATE, 109 109 NCHANNELS, … … 121 121 pool, /* pool */ 122 122 -1, /* use default dev. */ 123 file_port->info. sample_rate, /* clock rate. */123 file_port->info.clock_rate, /* clock rate. */ 124 124 file_port->info.channel_count, /* # of channels. */ 125 125 file_port->info.samples_per_frame, /* samples per frame. */ -
pjproject/trunk/pjsip-apps/src/samples/resampleplay.c
r361 r412 109 109 110 110 /* Create the file port. */ 111 status = pjmedia_ file_player_port_create( pool, argv[pj_optind], 0,112 111 status = pjmedia_wav_player_port_create( pool, argv[pj_optind], 0, 0, 112 0, 0, &file_port); 113 113 if (status != PJ_SUCCESS) { 114 114 app_perror(THIS_FILE, "Unable to open file", status); … … 129 129 /* Create the resample port. */ 130 130 status = pjmedia_resample_port_create( pool, 1, 1, 131 file_port->info. sample_rate,131 file_port->info.clock_rate, 132 132 sampling_rate, 133 133 channel_count, 134 134 (unsigned)( 135 135 samples_per_frame * 1.0 * 136 file_port->info. sample_rate /136 file_port->info.clock_rate / 137 137 sampling_rate), 138 138 &resample_port); … … 187 187 188 188 printf("Playing %s at sampling rate %d (original file sampling rate=%d)\n", 189 argv[pj_optind], sampling_rate, file_port->info. sample_rate);189 argv[pj_optind], sampling_rate, file_port->info.clock_rate); 190 190 puts(""); 191 191 puts("Press <ENTER> to stop playing and quit"); -
pjproject/trunk/pjsip-apps/src/samples/simpleua.c
r361 r412 420 420 pjsip_event *e) 421 421 { 422 PJ_UNUSED_ARG(e); 423 422 424 if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { 423 425 … … 442 444 { 443 445 /* To be done... */ 446 PJ_UNUSED_ARG(inv); 447 PJ_UNUSED_ARG(e); 444 448 } 445 449 … … 634 638 inv->pool, /* pool */ 635 639 -1, /* sound dev id */ 636 media_port->info. sample_rate, /* clock rate */640 media_port->info.clock_rate, /* clock rate */ 637 641 media_port->info.channel_count, /* channel count */ 638 642 media_port->info.samples_per_frame, /* samples per frame*/ … … 643 647 app_perror( THIS_FILE, "Unable to create sound player", status); 644 648 PJ_LOG(3,(THIS_FILE, "%d %d %d %d", 645 media_port->info. sample_rate, /* clock rate */649 media_port->info.clock_rate, /* clock rate */ 646 650 media_port->info.channel_count, /* channel count */ 647 651 media_port->info.samples_per_frame, /* samples per frame*/ … … 660 664 inv->pool, /* pool */ 661 665 -1, /* sound dev id */ 662 media_port->info. sample_rate, /* clock rate */666 media_port->info.clock_rate, /* clock rate */ 663 667 media_port->info.channel_count, /* channel count */ 664 668 media_port->info.samples_per_frame, /* samples per frame*/ -
pjproject/trunk/pjsip-apps/src/samples/siprtp.c
r408 r412 1239 1239 } 1240 1240 1241 audio->clock_rate = audio->si.fmt. sample_rate;1241 audio->clock_rate = audio->si.fmt.clock_rate; 1242 1242 audio->samples_per_frame = audio->clock_rate * codec_desc->ptime / 1000; 1243 1243 audio->bytes_per_frame = codec_desc->bit_rate * codec_desc->ptime / 1000 / 8; -
pjproject/trunk/pjsip-apps/src/samples/sndinfo.c
r410 r412 74 74 } 75 75 76 static intclock_rate;77 static intplay_counter;78 static intrec_counter;79 static intmin_delay = 0xFFFF, max_delay;76 static unsigned clock_rate; 77 static unsigned play_counter; 78 static unsigned rec_counter; 79 static unsigned min_delay = 0xFFFF, max_delay; 80 80 static char play_delays[1000]; 81 81 static pj_uint32_t last_play_timestamp, last_rec_timestamp; … … 85 85 { 86 86 static pj_timestamp last_cb; 87 88 89 PJ_UNUSED_ARG(user_data); 90 PJ_UNUSED_ARG(output); 91 PJ_UNUSED_ARG(size); 92 87 93 88 94 ++play_counter; … … 93 99 } else if (play_counter <= PJ_ARRAY_SIZE(play_delays)) { 94 100 pj_timestamp now; 95 intdelay;101 unsigned delay; 96 102 97 103 pj_get_timestamp(&now); … … 105 111 last_cb = now; 106 112 107 play_delays[play_counter-1] = delay;113 play_delays[play_counter-1] = (char)delay; 108 114 } 109 115 … … 114 120 const void *input, unsigned size) 115 121 { 122 123 PJ_UNUSED_ARG(size); 124 PJ_UNUSED_ARG(input); 125 PJ_UNUSED_ARG(user_data); 126 127 116 128 ++rec_counter; 117 129 … … 249 261 250 262 int dev_id; 251 pjmedia_dir dir ;263 pjmedia_dir dir = PJMEDIA_DIR_NONE; 252 264 int nchannel; 253 265 int bits; -
pjproject/trunk/pjsip-apps/src/samples/streamutil.c
r408 r412 32 32 "\n" 33 33 " Options:\n" 34 " --codec=CODEC Set the codec name. Valid codec names are: \n" 35 " pcma, pcmu, gsm, speexnb, speexwb, speexuwb. \n" 36 " (default: pcma). \n" 34 " --codec=CODEC Set the codec name. \n" 37 35 " --local-port=PORT Set local RTP port (default=4000) \n" 38 36 " --remote=IP:PORT Set the remote peer. If this option is set, \n" … … 65 63 66 64 67 struct codec68 {69 char *name;70 char *encoding_name;71 int pt;72 int clock_rate;73 } codec[] =74 {75 { "pcma", "pcma", PJMEDIA_RTP_PT_PCMA, 8000 },76 { "pcmu", "pcmu", PJMEDIA_RTP_PT_PCMU, 8000 },77 { "gsm", "gsm", PJMEDIA_RTP_PT_GSM, 8000 },78 { "speexnb", "speex", 120, 8000 },79 { "speexwb", "speex", 121, 16000 },80 { "speexuwb", "speex", 122, 32000 },81 };82 83 65 84 66 /* Prototype */ … … 102 84 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 103 85 86 status = pjmedia_codec_l16_init(med_endpt, 0); 87 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 88 104 89 return PJ_SUCCESS; 105 90 } … … 111 96 static pj_status_t create_stream( pj_pool_t *pool, 112 97 pjmedia_endpt *med_endpt, 113 unsigned codec_index,98 const pjmedia_codec_info *codec_info, 114 99 pjmedia_dir dir, 115 100 pj_uint16_t local_port, … … 128 113 info.type = PJMEDIA_TYPE_AUDIO; 129 114 info.dir = dir; 130 info.fmt.encoding_name = pj_str(codec[codec_index].encoding_name); 131 info.fmt.type = PJMEDIA_TYPE_AUDIO; 132 info.fmt.sample_rate = codec[codec_index].clock_rate; 133 info.fmt.pt = codec[codec_index].pt; 134 info.tx_pt = codec[codec_index].pt; 115 pj_memcpy(&info.fmt, codec_info, sizeof(pjmedia_codec_info)); 116 info.tx_pt = codec_info->pt; 135 117 info.ssrc = pj_rand(); 136 118 … … 199 181 } 200 182 183 184 /* 185 * usage() 186 */ 187 static void usage() 188 { 189 puts(desc); 190 } 201 191 202 192 /* … … 218 208 219 209 /* Default values */ 220 int codec_index = 0;210 const pjmedia_codec_info *codec_info; 221 211 pjmedia_dir dir = PJMEDIA_DIR_DECODING; 222 212 pj_sockaddr_in remote_addr; 223 213 pj_uint16_t local_port = 4000; 214 char *codec_id = NULL; 224 215 char *rec_file = NULL; 225 216 char *play_file = NULL; … … 234 225 OPT_SEND_ONLY = 's', 235 226 OPT_RECV_ONLY = 'i', 227 OPT_HELP = 'h', 236 228 }; 237 229 … … 245 237 { "send-only", 0, 0, OPT_SEND_ONLY }, 246 238 { "recv-only", 0, 0, OPT_RECV_ONLY }, 239 { "help", 0, 0, OPT_HELP }, 247 240 { NULL, 0, 0, 0 }, 248 241 }; … … 262 255 /* Parse arguments */ 263 256 pj_optind = 0; 264 while((c=pj_getopt_long(argc,argv, " ", long_options, &option_index))!=-1) {257 while((c=pj_getopt_long(argc,argv, "h", long_options, &option_index))!=-1) { 265 258 266 259 switch (c) { 267 260 case OPT_CODEC: 268 { 269 unsigned i; 270 for (i=0; i<PJ_ARRAY_SIZE(codec); ++i) { 271 if (pj_ansi_stricmp(pj_optarg, codec[i].name)==0) { 272 break; 273 } 274 } 275 276 if (i == PJ_ARRAY_SIZE(codec)) { 277 printf("Error: unknown codec %s\n", pj_optarg); 278 return 1; 279 } 280 281 codec_index = i; 282 } 261 codec_id = pj_optarg; 283 262 break; 284 263 … … 323 302 dir = PJMEDIA_DIR_DECODING; 324 303 break; 304 305 case OPT_HELP: 306 usage(); 307 return 1; 325 308 326 309 default: … … 370 353 371 354 355 /* Find which codec to use. */ 356 if (codec_id) { 357 unsigned count = 1; 358 pj_str_t str_codec_id = pj_str(codec_id); 359 pjmedia_codec_mgr *codec_mgr = pjmedia_endpt_get_codec_mgr(med_endpt); 360 status = pjmedia_codec_mgr_find_codecs_by_id( codec_mgr, 361 &str_codec_id, &count, 362 &codec_info, NULL); 363 if (status != PJ_SUCCESS) { 364 printf("Error: unable to find codec %s\n", codec_id); 365 return 1; 366 } 367 } else { 368 /* Default to pcmu */ 369 pjmedia_codec_mgr_get_codec_info( pjmedia_endpt_get_codec_mgr(med_endpt), 370 0, &codec_info); 371 } 372 372 373 /* Create stream based on program arguments */ 373 status = create_stream(pool, med_endpt, codec_in dex, dir, local_port,374 status = create_stream(pool, med_endpt, codec_info, dir, local_port, 374 375 &remote_addr, &stream); 375 376 if (status != PJ_SUCCESS) … … 383 384 384 385 if (play_file) { 385 386 status = pjmedia_file_player_port_create(pool, play_file, 0, 387 -1, NULL, &play_file_port); 386 unsigned wav_ptime; 387 388 wav_ptime = stream_port->info.samples_per_frame * 1000 / 389 stream_port->info.clock_rate; 390 status = pjmedia_wav_player_port_create(pool, play_file, wav_ptime, 391 0, -1, NULL, &play_file_port); 388 392 if (status != PJ_SUCCESS) { 389 393 app_perror(THIS_FILE, "Unable to use file", status); … … 410 414 if (dir == PJMEDIA_DIR_ENCODING_DECODING) 411 415 status = pjmedia_snd_port_create(pool, -1, -1, 412 stream_port->info. sample_rate,416 stream_port->info.clock_rate, 413 417 stream_port->info.channel_count, 414 418 stream_port->info.samples_per_frame, … … 417 421 else if (dir == PJMEDIA_DIR_ENCODING) 418 422 status = pjmedia_snd_port_create_rec(pool, -1, 419 stream_port->info. sample_rate,423 stream_port->info.clock_rate, 420 424 stream_port->info.channel_count, 421 425 stream_port->info.samples_per_frame, … … 424 428 else 425 429 status = pjmedia_snd_port_create_player(pool, -1, 426 stream_port->info. sample_rate,430 stream_port->info.clock_rate, 427 431 stream_port->info.channel_count, 428 432 stream_port->info.samples_per_frame, … … 577 581 (int)port->info.encoding_name.slen, 578 582 port->info.encoding_name.ptr, 579 port->info. sample_rate,580 port->info.samples_per_frame * 1000 / port->info. sample_rate,581 good_number(bps, port->info.bytes_per_frame * port->info. sample_rate /582 port->info.sample _rate),583 port->info.clock_rate, 584 port->info.samples_per_frame * 1000 / port->info.clock_rate, 585 good_number(bps, port->info.bytes_per_frame * port->info.clock_rate / 586 port->info.samples_per_frame), 583 587 good_number(ipbps, (port->info.bytes_per_frame+32) * 584 port->info. sample_rate / port->info.sample_rate));588 port->info.clock_rate / port->info.clock_rate)); 585 589 586 590 if (stat.rx.update_cnt == 0) -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r370 r412 663 663 #endif /* PJMEDIA_HAS_GSM_CODEC */ 664 664 665 #if PJMEDIA_HAS_L16_CODEC 666 /* Register L16 */ 667 status = pjmedia_codec_l16_init(pjsua.med_endpt, 0); 668 if (status != PJ_SUCCESS) { 669 pjsua_perror(THIS_FILE, "Error initializing L16 codec", 670 status); 671 return status; 672 } 673 674 pjsua.codec_arg[pjsua.codec_cnt] = pj_str("l16"); 675 pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_l16_deinit; 676 pjsua.codec_cnt++; 677 #endif /* PJMEDIA_HAS_L16_CODEC */ 678 679 665 680 #if PJMEDIA_HAS_G711_CODEC 666 681 /* Register PCMA and PCMU */ … … 731 746 } 732 747 #endif /* PJMEDIA_HAS_GSM_CODEC */ 748 749 #if PJMEDIA_HAS_L16_CODEC 750 /* Is it l16? */ 751 else if (!pj_stricmp2(&pjsua.codec_arg[i], "l16")) { 752 753 status = pjmedia_codec_l16_init(pjsua.med_endpt, 0); 754 if (status != PJ_SUCCESS) { 755 pjsua_perror(THIS_FILE, "Error initializing L16 codec", 756 status); 757 return status; 758 } 759 760 pjsua.codec_deinit[i] = &pjmedia_codec_l16_deinit; 761 762 pjsua.clock_rate = 44100; 763 } 764 #endif /* PJMEDIA_HAS_L16_CODEC */ 733 765 734 766 #if PJMEDIA_HAS_G711_CODEC … … 795 827 796 828 /* Create the file player port. */ 797 status = pjmedia_ file_player_port_create(pjsua.pool, pjsua.wav_file,798 0, -1, NULL,829 status = pjmedia_wav_player_port_create( pjsua.pool, pjsua.wav_file, 830 0, 0, -1, NULL, 799 831 &pjsua.file_port); 800 832 if (status != PJ_SUCCESS) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r398 r412 676 676 info.stream_info[i].fmt.encoding_name.slen, 677 677 info.stream_info[i].fmt.encoding_name.ptr, 678 info.stream_info[i].fmt. sample_rate / 1000,678 info.stream_info[i].fmt.clock_rate / 1000, 679 679 dir, 680 680 rem_addr, rem_port));
Note: See TracChangeset
for help on using the changeset viewer.