- Timestamp:
- Dec 10, 2010 11:04:30 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/splitcomb.c
r2394 r3392 190 190 */ 191 191 static pj_status_t put_frame(pjmedia_port *this_port, 192 constpjmedia_frame *frame);192 pjmedia_frame *frame); 193 193 static pj_status_t get_frame(pjmedia_port *this_port, 194 194 pjmedia_frame *frame); … … 196 196 197 197 static pj_status_t rport_put_frame(pjmedia_port *this_port, 198 constpjmedia_frame *frame);198 pjmedia_frame *frame); 199 199 static pj_status_t rport_get_frame(pjmedia_port *this_port, 200 200 pjmedia_frame *frame); … … 285 285 286 286 /* Check the channel number */ 287 PJ_ASSERT_RETURN(ch_num < sc->base.info.channel_count, PJ_EINVAL);287 PJ_ASSERT_RETURN(ch_num < PJMEDIA_PIA_CCNT(&sc->base.info), PJ_EINVAL); 288 288 289 289 /* options is unused for now */ … … 309 309 struct splitcomb *sc = (struct splitcomb*) splitcomb; 310 310 struct reverse_port *rport; 311 unsigned buf_cnt, ptime; 311 unsigned buf_cnt; 312 const pjmedia_audio_format_detail *sc_afd, *p_afd; 312 313 pjmedia_port *port; 313 314 pj_status_t status; … … 320 321 321 322 /* Check the channel number */ 322 PJ_ASSERT_RETURN(ch_num < sc->base.info.channel_count, PJ_EINVAL);323 PJ_ASSERT_RETURN(ch_num < PJMEDIA_PIA_CCNT(&sc->base.info), PJ_EINVAL); 323 324 324 325 /* options is unused for now */ 325 326 PJ_UNUSED_ARG(options); 327 328 sc_afd = pjmedia_format_get_audio_format_detail(&splitcomb->info.fmt, 1); 326 329 327 330 /* Create the port */ … … 333 336 port = &rport->base; 334 337 pjmedia_port_info_init(&port->info, &name, SIGNATURE_PORT, 335 splitcomb->info.clock_rate, 1, 336 splitcomb->info.bits_per_sample, 337 splitcomb->info.samples_per_frame / 338 splitcomb->info.channel_count); 338 sc_afd->clock_rate, 1, 339 sc_afd->bits_per_sample, 340 PJMEDIA_PIA_SPF(&splitcomb->info) / 341 sc_afd->channel_count); 342 343 p_afd = pjmedia_format_get_audio_format_detail(&port->info.fmt, 1); 339 344 340 345 /* ... and the callbacks */ … … 348 353 buf_cnt = MAX_BUF_CNT; 349 354 350 ptime = port->info.samples_per_frame * 1000 / port->info.clock_rate /351 port->info.channel_count;352 353 355 rport->max_burst = MAX_BURST; 354 356 rport->max_null_frames = MAX_NULL_FRAMES; … … 356 358 /* Create downstream/put buffers */ 357 359 status = pjmedia_delay_buf_create(pool, "scombdb-dn", 358 p ort->info.clock_rate,359 port->info.samples_per_frame,360 p ort->info.channel_count,361 buf_cnt * p time,0,362 &rport->buf[DIR_DOWNSTREAM].dbuf);360 p_afd->clock_rate, 361 PJMEDIA_PIA_SPF(&port->info), 362 p_afd->channel_count, 363 buf_cnt * p_afd->frame_time_usec / 1000, 364 0, &rport->buf[DIR_DOWNSTREAM].dbuf); 363 365 if (status != PJ_SUCCESS) { 364 366 return status; … … 367 369 /* Create upstream/get buffers */ 368 370 status = pjmedia_delay_buf_create(pool, "scombdb-up", 369 p ort->info.clock_rate,370 port->info.samples_per_frame,371 p ort->info.channel_count,372 buf_cnt * p time,0,373 &rport->buf[DIR_UPSTREAM].dbuf);371 p_afd->clock_rate, 372 PJMEDIA_PIA_SPF(&port->info), 373 p_afd->channel_count, 374 buf_cnt * p_afd->frame_time_usec / 1000, 375 0, &rport->buf[DIR_UPSTREAM].dbuf); 374 376 if (status != PJ_SUCCESS) { 375 377 pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf); … … 379 381 /* And temporary upstream/get buffer */ 380 382 rport->tmp_up_buf = (pj_int16_t*) 381 pj_pool_alloc(pool, port->info.bytes_per_frame); 383 pj_pool_alloc(pool, 384 PJMEDIA_PIA_AVG_FSZ(&port->info)); 382 385 383 386 /* Save port in the splitcomb */ … … 437 440 438 441 if (op == OP_PUT) { 439 rport->buf[dir].ts.u64 += rport->base.info.samples_per_frame;442 rport->buf[dir].ts.u64 += PJMEDIA_PIA_SPF(&rport->base.info); 440 443 } 441 444 … … 485 488 */ 486 489 static pj_status_t put_frame(pjmedia_port *this_port, 487 constpjmedia_frame *frame)490 pjmedia_frame *frame) 488 491 { 489 492 struct splitcomb *sc = (struct splitcomb*) this_port; … … 492 495 /* Handle null frame */ 493 496 if (frame->type == PJMEDIA_FRAME_TYPE_NONE) { 494 for (ch=0; ch < this_port->info.channel_count; ++ch) {497 for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) { 495 498 pjmedia_port *port = sc->port_desc[ch].port; 496 499 … … 534 537 /* Generate zero frame. */ 535 538 pjmedia_zero_samples(sc->put_buf, 536 this_port->info.samples_per_frame);539 PJMEDIA_PIA_SPF(&this_port->info)); 537 540 538 541 /* Put frame to delay buffer */ … … 548 551 * it for now. 549 552 */ 550 PJ_ASSERT_RETURN(frame->size == this_port->info.bytes_per_frame,553 PJ_ASSERT_RETURN(frame->size == PJMEDIA_PIA_AVG_FSZ(&this_port->info), 551 554 PJ_EINVAL); 552 555 … … 554 557 * Write mono frame into each channels 555 558 */ 556 for (ch=0; ch < this_port->info.channel_count; ++ch) {559 for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) { 557 560 pjmedia_port *port = sc->port_desc[ch].port; 558 561 … … 562 565 /* Extract the mono frame to temporary buffer */ 563 566 extract_mono_frame((const pj_int16_t*)frame->buf, sc->put_buf, ch, 564 this_port->info.channel_count,567 PJMEDIA_PIA_CCNT(&this_port->info), 565 568 frame->size * 8 / 566 this_port->info.bits_per_sample/567 this_port->info.channel_count);569 PJMEDIA_PIA_BITS(&this_port->info) / 570 PJMEDIA_PIA_CCNT(&this_port->info)); 568 571 569 572 if (!sc->port_desc[ch].reversed) { … … 572 575 573 576 mono_frame.buf = sc->put_buf; 574 mono_frame.size = frame->size / this_port->info.channel_count;577 mono_frame.size = frame->size / PJMEDIA_PIA_CCNT(&this_port->info); 575 578 mono_frame.type = frame->type; 576 579 mono_frame.timestamp.u64 = frame->timestamp.u64; … … 613 616 614 617 /* Read frame from each port */ 615 for (ch=0; ch < this_port->info.channel_count; ++ch) {618 for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) { 616 619 pjmedia_port *port = sc->port_desc[ch].port; 617 620 pjmedia_frame mono_frame; … … 620 623 if (!port) { 621 624 pjmedia_zero_samples(sc->get_buf, 622 this_port->info.samples_per_frame/623 this_port->info.channel_count);625 PJMEDIA_PIA_SPF(&this_port->info) / 626 PJMEDIA_PIA_CCNT(&this_port->info)); 624 627 625 628 } else if (sc->port_desc[ch].reversed == PJ_FALSE) { 626 629 /* Read from normal port */ 627 630 mono_frame.buf = sc->get_buf; 628 mono_frame.size = port->info.bytes_per_frame;631 mono_frame.size = PJMEDIA_PIA_AVG_FSZ(&port->info); 629 632 mono_frame.timestamp.u64 = frame->timestamp.u64; 630 633 … … 634 637 { 635 638 pjmedia_zero_samples(sc->get_buf, 636 port->info.samples_per_frame);639 PJMEDIA_PIA_SPF(&port->info)); 637 640 } 638 641 … … 652 655 } else { 653 656 pjmedia_zero_samples(sc->get_buf, 654 port->info.samples_per_frame);657 PJMEDIA_PIA_SPF(&port->info)); 655 658 } 656 659 … … 661 664 store_mono_frame(sc->get_buf, 662 665 (pj_int16_t*)frame->buf, ch, 663 this_port->info.channel_count,664 this_port->info.samples_per_frame/665 this_port->info.channel_count);666 PJMEDIA_PIA_CCNT(&this_port->info), 667 PJMEDIA_PIA_SPF(&this_port->info) / 668 PJMEDIA_PIA_CCNT(&this_port->info)); 666 669 667 670 has_frame = PJ_TRUE; … … 671 674 if (has_frame) { 672 675 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 673 frame->size = this_port->info.bytes_per_frame;676 frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info); 674 677 } else 675 678 frame->type = PJMEDIA_FRAME_TYPE_NONE; … … 695 698 */ 696 699 static pj_status_t rport_put_frame(pjmedia_port *this_port, 697 constpjmedia_frame *frame)700 pjmedia_frame *frame) 698 701 { 699 702 struct reverse_port *rport = (struct reverse_port*) this_port; 700 703 701 pj_assert(frame->size <= rport->base.info.bytes_per_frame);704 pj_assert(frame->size <= PJMEDIA_PIA_AVG_FSZ(&rport->base.info)); 702 705 703 706 /* Handle NULL frame */ … … 731 734 /* Generate zero frame. */ 732 735 pjmedia_zero_samples(rport->tmp_up_buf, 733 this_port->info.samples_per_frame);736 PJMEDIA_PIA_SPF(&this_port->info)); 734 737 735 738 /* Put frame to delay buffer */ … … 739 742 740 743 /* Not sure how to handle partial frame, so better reject for now */ 741 PJ_ASSERT_RETURN(frame->size == this_port->info.bytes_per_frame,744 PJ_ASSERT_RETURN(frame->size == PJMEDIA_PIA_AVG_FSZ(&this_port->info), 742 745 PJ_EINVAL); 743 746 … … 756 759 */ 757 760 pjmedia_copy_samples(rport->tmp_up_buf, (const pj_int16_t*)frame->buf, 758 this_port->info.samples_per_frame);761 PJMEDIA_PIA_SPF(&this_port->info)); 759 762 760 763 /* Put frame to delay buffer */ … … 784 787 785 788 /* Get frame from delay buffer */ 786 frame->size = this_port->info.bytes_per_frame;789 frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info); 787 790 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 788 791 frame->timestamp.u64 = rport->buf[DIR_DOWNSTREAM].ts.u64;
Note: See TracChangeset
for help on using the changeset viewer.