- Timestamp:
- Feb 13, 2009 11:53:12 AM (16 years ago)
- Location:
- pjproject/branches/projects/aps-direct
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia.dsp
r2290 r2452 110 110 # Begin Source File 111 111 112 SOURCE=..\src\pjmedia\conf_switch.c 113 # End Source File 114 # Begin Source File 115 112 116 SOURCE=..\src\pjmedia\conference.c 113 117 # End Source File -
pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_codec.dsp
r2358 r2452 148 148 # Begin Source File 149 149 150 SOURCE="..\src\pjmedia-codec\passthrough.c" 151 # End Source File 152 # Begin Source File 153 150 154 SOURCE="..\src\pjmedia-codec\speex_codec.c" 151 155 … … 190 194 191 195 SOURCE="..\include\pjmedia-codec\l16.h" 196 # End Source File 197 # Begin Source File 198 199 SOURCE="..\include\pjmedia-codec\passthrough.h" 192 200 # End Source File 193 201 # Begin Source File -
pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_codec.vcproj
r2430 r2452 399 399 </File> 400 400 <File 401 RelativePath="..\src\pjmedia-codec\passthrough.c" 402 > 403 </File> 404 <File 401 405 RelativePath="..\src\pjmedia-codec\speex_codec.c" 402 406 > -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-codec/amr_helper.h
r2444 r2452 689 689 unsigned frame_len) 690 690 { 691 unsignedi;691 int i; 692 692 693 693 if (amrnb) { 694 694 for (i = 0; i < 9; ++i) 695 695 if (frame_len == pjmedia_codec_amrnb_framelen[i]) 696 return i;696 return (pj_int8_t)i; 697 697 } else { 698 698 for (i = 0; i < 10; ++i) { 699 699 if (frame_len == pjmedia_codec_amrwb_framelen[i]) 700 return i;700 return (pj_int8_t)i; 701 701 } 702 702 } -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/alaw_ulaw.h
r2416 r2452 145 145 * @param dst Destination buffer for 8-bit U-Law data. 146 146 * @param src Source, 16-bit linear PCM data. 147 * @param lenNumber of samples.147 * @param count Number of samples. 148 148 */ 149 149 PJ_INLINE(void) pjmedia_ulaw_encode(pj_uint8_t *dst, const pj_int16_t *src, 150 pj_size_t len)151 { 152 const pj_int16_t *end = src + len;150 pj_size_t count) 151 { 152 const pj_int16_t *end = src + count; 153 153 154 154 while (src < end) { … … 162 162 * @param dst Destination buffer for 8-bit A-Law data. 163 163 * @param src Source, 16-bit linear PCM data. 164 * @param lenNumber of samples.164 * @param count Number of samples. 165 165 */ 166 166 PJ_INLINE(void) pjmedia_alaw_encode(pj_uint8_t *dst, const pj_int16_t *src, 167 pj_size_t len)168 { 169 const pj_int16_t *end = src + len;167 pj_size_t count) 168 { 169 const pj_int16_t *end = src + count; 170 170 171 171 while (src < end) { … … 179 179 * @param dst Destination buffer for 16-bit PCM data. 180 180 * @param src Source, 8-bit U-Law data. 181 * @param len Number of samples.181 * @param len Encoded frame/source length in bytes. 182 182 */ 183 183 PJ_INLINE(void) pjmedia_ulaw_decode(pj_int16_t *dst, const pj_uint8_t *src, … … 196 196 * @param dst Destination buffer for 16-bit PCM data. 197 197 * @param src Source, 8-bit A-Law data. 198 * @param len Number of samples.198 * @param len Encoded frame/source length in bytes. 199 199 */ 200 200 PJ_INLINE(void) pjmedia_alaw_decode(pj_int16_t *dst, const pj_uint8_t *src, -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/config.h
r2434 r2452 108 108 #endif 109 109 110 /** 111 * Specify if the sound device implementation supports handling encoded 112 * frames. Setting this to zero will activate some emulation in the 113 * sound port. 114 */ 115 #if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_SYMB_APS_SOUND || \ 116 PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_SYMB_VAS_SOUND 117 # define PJMEDIA_SND_SUPPORT_OPEN2 1 118 #else 119 # define PJMEDIA_SND_SUPPORT_OPEN2 0 120 #endif 110 121 111 122 /** -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h
r2445 r2452 320 320 321 321 frm->subframe_cnt++; 322 frm->samples_cnt = frm->samples_cnt + (pj_uint16_t)samples_cnt;322 frm->samples_cnt = (pj_uint16_t)(frm->samples_cnt + samples_cnt); 323 323 } 324 324 -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-codec/passthrough.c
r2445 r2452 642 642 return PJMEDIA_CODEC_EINMODE; 643 643 644 s->enc_setting.amr_nb = desc->pt == PJMEDIA_RTP_PT_AMR;644 s->enc_setting.amr_nb = (pj_uint8_t)(desc->pt == PJMEDIA_RTP_PT_AMR); 645 645 s->enc_setting.octet_aligned = octet_align; 646 646 s->enc_setting.reorder = PJ_FALSE; /* Note this! passthrough codec … … 649 649 s->enc_setting.cmr = 15; 650 650 651 s->dec_setting.amr_nb = desc->pt == PJMEDIA_RTP_PT_AMR;651 s->dec_setting.amr_nb = (pj_uint8_t)(desc->pt == PJMEDIA_RTP_PT_AMR); 652 652 s->dec_setting.octet_aligned = octet_align; 653 653 s->dec_setting.reorder = PJ_FALSE; /* Note this! passthrough codec … … 770 770 output->size += sf_len; 771 771 772 #if PJMEDIA_HAS_INTEL_IPP_CODEC_G729773 772 /* If there is SID or DTX frame, break the loop. */ 774 773 if (desc->pt == PJMEDIA_RTP_PT_G729 && … … 777 776 break; 778 777 } 779 #endif780 778 781 779 } … … 799 797 800 798 pj_assert(input); 799 PJ_UNUSED_ARG(output_buf_len); 801 800 802 801 #if PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c
r2445 r2452 1031 1031 * samples per frame. 1032 1032 */ 1033 if (f_dst->samples_cnt == cport_dst->info->samples_per_frame)1033 if (f_dst->samples_cnt >= cport_dst->info->samples_per_frame) 1034 1034 { 1035 1035 if (cport_dst->slot) { … … 1360 1360 pjmedia_frame_ext *f_dst = (pjmedia_frame_ext*)frame; 1361 1361 pjmedia_frame_ext_subframe *sf; 1362 pj_uint16_tsamples_per_subframe;1362 unsigned samples_per_subframe; 1363 1363 1364 1364 if (f_src_->samples_cnt < this_cport->info->samples_per_frame) { -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/sound_port.c
r2438 r2452 19 19 */ 20 20 #include <pjmedia/sound_port.h> 21 #include <pjmedia/alaw_ulaw.h> 21 22 #include <pjmedia/delaybuf.h> 22 23 #include <pjmedia/echo.h> … … 36 37 //#define TEST_OVERFLOW_UNDERFLOW 37 38 38 39 39 struct pjmedia_snd_port 40 40 { … … 63 63 pjmedia_delay_buf *delay_buf; 64 64 #endif 65 66 /* Encoded sound emulation */ 67 #if !defined(PJMEDIA_SND_SUPPORT_OPEN2) || !PJMEDIA_SND_SUPPORT_OPEN2 68 unsigned frm_buf_size; 69 pj_uint8_t *put_frm_buf; 70 pj_uint8_t *get_frm_buf; 71 #endif 65 72 }; 66 73 … … 79 86 pj_status_t status; 80 87 81 /* We're risking accessing the port without holding any mutex.82 * It's possible that port is disconnected then destroyed while83 * we're trying to access it.84 * But in the name of performance, we'll try this approach until85 * someone complains when it crashes.86 */87 88 port = snd_port->port; 88 89 if (port == NULL) … … 198 199 pjmedia_frame frame; 199 200 200 /* We're risking accessing the port without holding any mutex.201 * It's possible that port is disconnected then destroyed while202 * we're trying to access it.203 * But in the name of performance, we'll try this approach until204 * someone complains when it crashes.205 */206 201 port = snd_port->port; 207 202 if (port == NULL) … … 245 240 /* out */ unsigned size) 246 241 { 242 #if defined(PJMEDIA_SND_SUPPORT_OPEN2) && PJMEDIA_SND_SUPPORT_OPEN2!=0 243 /* This is the version to use when the sound device supports 244 * open2(). 245 */ 247 246 pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data; 248 247 pjmedia_port *port; … … 253 252 PJ_UNUSED_ARG(timestamp); 254 253 255 /* We're risking accessing the port without holding any mutex.256 * It's possible that port is disconnected then destroyed while257 * we're trying to access it.258 * But in the name of performance, we'll try this approach until259 * someone complains when it crashes.260 */261 254 port = snd_port->port; 262 255 if (port == NULL) { … … 268 261 269 262 return status; 263 #else 264 /* This is the emulation version */ 265 pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data; 266 pjmedia_port *port = snd_port->port; 267 pjmedia_frame_ext *fx = (pjmedia_frame_ext*) snd_port->get_frm_buf; 268 pj_status_t status; 269 270 if (port==NULL) { 271 goto no_frame; 272 } 273 274 pj_bzero(fx, sizeof(*fx)); 275 fx->base.type = PJMEDIA_FRAME_TYPE_NONE; 276 fx->base.buf = ((pj_uint8_t*)fx) + sizeof(*fx); 277 fx->base.size = snd_port->frm_buf_size - sizeof(*fx); 278 fx->base.timestamp.u32.hi = 0; 279 fx->base.timestamp.u32.lo = timestamp; 280 281 status = pjmedia_port_get_frame(port, &fx->base); 282 if (status != PJ_SUCCESS) 283 goto no_frame; 284 285 if (fx->base.type == PJMEDIA_FRAME_TYPE_AUDIO) { 286 pj_assert(fx->base.size == size); 287 pj_memcpy(output, fx->base.buf, size); 288 } else if (fx->base.type == PJMEDIA_FRAME_TYPE_EXTENDED) { 289 void (*decoder)(pj_int16_t*, const pj_uint8_t*, pj_size_t) = NULL; 290 unsigned i, size_decoded; 291 292 switch (snd_port->setting.format.u32) { 293 case PJMEDIA_FOURCC_PCMA: 294 decoder = &pjmedia_alaw_decode; 295 break; 296 case PJMEDIA_FOURCC_PCMU: 297 decoder = &pjmedia_ulaw_decode; 298 break; 299 default: 300 PJ_LOG(1,(THIS_FILE, "Unsupported format %d", 301 snd_port->setting.format.u32)); 302 goto no_frame; 303 } 304 305 if (fx->samples_cnt > size>>1) { 306 PJ_LOG(4,(THIS_FILE, "Frame too large by %d samples", 307 fx->samples_cnt - (size>>1))); 308 } else if (fx->samples_cnt < size>>1) { 309 PJ_LOG(4,(THIS_FILE, "Not enough frame by %d samples", 310 (size>>1) - fx->samples_cnt)); 311 } 312 313 for (i=0, size_decoded=0; 314 i<fx->subframe_cnt && size_decoded<size; 315 ++i) 316 { 317 pjmedia_frame_ext_subframe *subfrm; 318 319 subfrm = pjmedia_frame_ext_get_subframe(fx, i); 320 321 if ((subfrm->bitlen>>3) > (int)(size-size_decoded)) { 322 subfrm->bitlen = (pj_uint16_t)((size-size_decoded) << 3); 323 } 324 325 (*decoder)((short*)((pj_uint8_t*)output + size_decoded), 326 subfrm->data, subfrm->bitlen>>3); 327 328 size_decoded += (subfrm->bitlen>>3) << 1; 329 } 330 331 if (size_decoded < size) { 332 pj_bzero((pj_uint8_t*)output + size_decoded, size-size_decoded); 333 } 334 335 } else { 336 goto no_frame; 337 } 338 339 return PJ_SUCCESS; 340 341 no_frame: 342 pj_bzero(output, size); 343 return PJ_SUCCESS; 344 345 #endif /* PJMEDIA_SND_SUPPORT_OPEN2 */ 270 346 } 271 347 … … 280 356 /* in*/ unsigned size) 281 357 { 358 #if defined(PJMEDIA_SND_SUPPORT_OPEN2) && PJMEDIA_SND_SUPPORT_OPEN2!=0 359 /* This is the version to use when the sound device supports 360 * open2(). 361 */ 282 362 pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data; 283 363 pjmedia_port *port; … … 287 367 PJ_UNUSED_ARG(timestamp); 288 368 289 /* We're risking accessing the port without holding any mutex.290 * It's possible that port is disconnected then destroyed while291 * we're trying to access it.292 * But in the name of performance, we'll try this approach until293 * someone complains when it crashes.294 */295 369 port = snd_port->port; 296 370 if (port == NULL) … … 300 374 301 375 return PJ_SUCCESS; 376 #else 377 pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data; 378 pjmedia_port *port = snd_port->port; 379 pjmedia_frame_ext *fx = (pjmedia_frame_ext*) snd_port->put_frm_buf; 380 void (*encoder)(pj_uint8_t*, const pj_int16_t*, pj_size_t) = NULL; 381 382 if (port==NULL) 383 return PJ_SUCCESS; 384 385 pj_bzero(fx, sizeof(*fx)); 386 fx->base.buf = NULL; 387 fx->base.size = snd_port->frm_buf_size - sizeof(*fx); 388 fx->base.type = PJMEDIA_FRAME_TYPE_EXTENDED; 389 fx->base.timestamp.u32.lo = timestamp; 390 391 switch (snd_port->setting.format.u32) { 392 case PJMEDIA_FOURCC_PCMA: 393 encoder = &pjmedia_alaw_encode; 394 break; 395 case PJMEDIA_FOURCC_PCMU: 396 encoder = &pjmedia_ulaw_encode; 397 break; 398 default: 399 PJ_LOG(1,(THIS_FILE, "Unsupported format %d", 400 snd_port->setting.format.u32)); 401 return PJ_SUCCESS; 402 } 403 404 (*encoder)((pj_uint8_t*)input, (pj_int16_t*)input, size >> 1); 405 406 pjmedia_frame_ext_append_subframe(fx, input, (size >> 1) << 3, 407 size >> 1); 408 pjmedia_port_put_frame(port, &fx->base); 409 410 return PJ_SUCCESS; 411 #endif 302 412 } 303 413 … … 332 442 } 333 443 444 #if defined(PJMEDIA_SND_SUPPORT_OPEN2) && PJMEDIA_SND_SUPPORT_OPEN2!=0 334 445 status = pjmedia_snd_open2( snd_port->dir, 335 446 snd_port->rec_id, … … 344 455 &snd_port->setting, 345 456 &snd_port->snd_stream); 457 #else 458 status = pjmedia_snd_open( snd_port->rec_id, 459 snd_port->play_id, 460 snd_port->clock_rate, 461 snd_port->channel_count, 462 snd_port->samples_per_frame, 463 snd_port->bits_per_sample, 464 snd_rec_cb, 465 snd_play_cb, 466 snd_port, 467 &snd_port->snd_stream); 468 #endif 346 469 347 470 if (status != PJ_SUCCESS) … … 572 695 snd_port->samples_per_frame = samples_per_frame; 573 696 snd_port->bits_per_sample = bits_per_sample; 574 snd_port->setting = *setting;697 pj_memcpy(&snd_port->setting, setting, sizeof(*setting)); 575 698 576 699 #if PJMEDIA_SOUND_USE_DELAYBUF … … 589 712 0, &snd_port->delay_buf); 590 713 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 714 } 715 #endif 716 717 #if !defined(PJMEDIA_SND_SUPPORT_OPEN2) || PJMEDIA_SND_SUPPORT_OPEN2==0 718 /* For devices that doesn't support open2(), enable simulation */ 719 if (snd_port->setting.format.u32 != 0 && 720 snd_port->setting.format.u32 != PJMEDIA_FOURCC_L16) 721 { 722 snd_port->frm_buf_size = sizeof(pjmedia_frame_ext) + 723 (samples_per_frame >> 1) + 724 16 * sizeof(pjmedia_frame_ext_subframe); 725 snd_port->put_frm_buf = (pj_uint8_t*) 726 pj_pool_alloc(pool, snd_port->frm_buf_size); 727 snd_port->get_frm_buf = (pj_uint8_t*) 728 pj_pool_alloc(pool, snd_port->frm_buf_size); 591 729 } 592 730 #endif -
pjproject/branches/projects/aps-direct/pjsip-apps/src/pjsua/pjsua_app.c
r2408 r2452 2402 2402 } 2403 2403 2404 #ifdef PJSUA_SIMULATE_APS_DIRECT 2405 /* To simulate APS direct, add these to config_site.h: 2406 #define PJSUA_SIMULATE_APS_DIRECT 2407 #ifdef PJSUA_SIMULATE_APS_DIRECT 2408 #define PJMEDIA_CONF_USE_SWITCH_BOARD 1 2409 #define PJMEDIA_HAS_PASSTHROUGH_CODECS 1 2410 2411 #define PJMEDIA_HAS_L16_CODEC 0 2412 #define PJMEDIA_HAS_GSM_CODEC 0 2413 #define PJMEDIA_HAS_SPEEX_CODEC 0 2414 #define PJMEDIA_HAS_ILBC_CODEC 0 2415 #define PJMEDIA_HAS_G722_CODEC 0 2416 #define PJMEDIA_HAS_INTEL_IPP 0 2417 2418 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 0 2419 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 0 2420 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 0 2421 #endif 2422 */ 2423 2424 /* Global sound port. */ 2425 static pjmedia_snd_port *g_snd_port; 2426 2427 2428 /* Reopen sound device on on_stream_created() pjsua callback. */ 2429 static void on_call_stream_created(pjsua_call_id call_id, 2430 pjmedia_session *sess, 2431 unsigned stream_idx, 2432 pjmedia_port **p_port) 2433 { 2434 pjmedia_port *conf; 2435 pjmedia_session_info sess_info; 2436 pjmedia_stream_info *strm_info; 2437 pjmedia_snd_setting setting; 2438 unsigned samples_per_frame; 2439 pj_status_t status; 2440 2441 PJ_UNUSED_ARG(call_id); 2442 PJ_UNUSED_ARG(p_port); 2443 2444 /* Get active format for this stream, based on SDP negotiation result. */ 2445 pjmedia_session_get_info(sess, &sess_info); 2446 strm_info = &sess_info.stream_info[stream_idx]; 2447 2448 /* Init sound device setting based on stream info. */ 2449 pj_bzero(&setting, sizeof(setting)); 2450 setting.format = strm_info->param->info.format; 2451 setting.bitrate = strm_info->param->info.avg_bps; 2452 setting.cng = strm_info->param->setting.cng; 2453 setting.vad = strm_info->param->setting.vad; 2454 setting.plc = strm_info->param->setting.plc; 2455 2456 /* Close sound device and get the conference port. */ 2457 conf = pjsua_set_no_snd_dev(); 2458 2459 samples_per_frame = strm_info->param->info.clock_rate * 2460 strm_info->param->info.frm_ptime * 2461 strm_info->param->setting.frm_per_pkt * 2462 strm_info->param->info.channel_cnt / 2463 1000; 2464 2465 /* Reset conference port attributes. */ 2466 conf->info.samples_per_frame = samples_per_frame; 2467 conf->info.clock_rate = 8000; 2468 conf->info.channel_count = 1; 2469 conf->info.bits_per_sample = 16; 2470 2471 /* Reopen sound device. */ 2472 status = pjmedia_snd_port_create2(app_config.pool, 2473 PJMEDIA_DIR_CAPTURE_PLAYBACK, 2474 -1, 2475 -1, 2476 8000, 2477 1, 2478 samples_per_frame, 2479 16, 2480 &setting, 2481 &g_snd_port); 2482 if (status != PJ_SUCCESS) { 2483 pjsua_perror(THIS_FILE, "Error opening sound device", status); 2484 return; 2485 } 2486 2487 /* Connect sound to conference port. */ 2488 pjmedia_snd_port_connect(g_snd_port, conf); 2489 } 2490 2491 static void on_call_stream_destroyed(pjsua_call_id call_id, 2492 pjmedia_session *sess, 2493 unsigned stream_idx) 2494 { 2495 PJ_UNUSED_ARG(call_id); 2496 PJ_UNUSED_ARG(sess); 2497 PJ_UNUSED_ARG(stream_idx); 2498 2499 if (g_snd_port) { 2500 pjmedia_snd_port_destroy(g_snd_port); 2501 g_snd_port = NULL; 2502 } 2503 } 2504 2505 #endif 2506 2404 2507 /* 2405 2508 * DTMF callback. … … 4047 4150 app_config.cfg.cb.on_call_state = &on_call_state; 4048 4151 app_config.cfg.cb.on_call_media_state = &on_call_media_state; 4152 #ifdef PJSUA_SIMULATE_APS_DIRECT 4153 app_config.cfg.cb.on_stream_created = &on_call_stream_created; 4154 app_config.cfg.cb.on_stream_destroyed = &on_call_stream_destroyed; 4155 #endif 4049 4156 app_config.cfg.cb.on_incoming_call = &on_incoming_call; 4050 4157 app_config.cfg.cb.on_call_tsx_state = &on_call_tsx_state;
Note: See TracChangeset
for help on using the changeset viewer.