Ignore:
Timestamp:
Dec 10, 2010 11:04:30 AM (13 years ago)
Author:
bennylp
Message:

Migration of current video works from private repository to this repository. This closed #1176

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/splitcomb.c

    r2394 r3392  
    190190 */ 
    191191static pj_status_t put_frame(pjmedia_port *this_port,  
    192                              const pjmedia_frame *frame); 
     192                             pjmedia_frame *frame); 
    193193static pj_status_t get_frame(pjmedia_port *this_port,  
    194194                             pjmedia_frame *frame); 
     
    196196 
    197197static pj_status_t rport_put_frame(pjmedia_port *this_port,  
    198                                    const pjmedia_frame *frame); 
     198                                   pjmedia_frame *frame); 
    199199static pj_status_t rport_get_frame(pjmedia_port *this_port,  
    200200                                   pjmedia_frame *frame); 
     
    285285 
    286286    /* 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); 
    288288 
    289289    /* options is unused for now */ 
     
    309309    struct splitcomb *sc = (struct splitcomb*) splitcomb; 
    310310    struct reverse_port *rport; 
    311     unsigned buf_cnt, ptime; 
     311    unsigned buf_cnt; 
     312    const pjmedia_audio_format_detail *sc_afd, *p_afd; 
    312313    pjmedia_port *port; 
    313314    pj_status_t status; 
     
    320321 
    321322    /* 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); 
    323324 
    324325    /* options is unused for now */ 
    325326    PJ_UNUSED_ARG(options); 
     327 
     328    sc_afd = pjmedia_format_get_audio_format_detail(&splitcomb->info.fmt, 1); 
    326329 
    327330    /* Create the port */ 
     
    333336    port = &rport->base; 
    334337    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); 
    339344 
    340345    /* ... and the callbacks */ 
     
    348353        buf_cnt = MAX_BUF_CNT; 
    349354 
    350     ptime = port->info.samples_per_frame * 1000 / port->info.clock_rate / 
    351             port->info.channel_count; 
    352  
    353355    rport->max_burst = MAX_BURST; 
    354356    rport->max_null_frames = MAX_NULL_FRAMES; 
     
    356358    /* Create downstream/put buffers */ 
    357359    status = pjmedia_delay_buf_create(pool, "scombdb-dn", 
    358                                       port->info.clock_rate, 
    359                                       port->info.samples_per_frame, 
    360                                       port->info.channel_count, 
    361                                       buf_cnt * ptime, 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); 
    363365    if (status != PJ_SUCCESS) { 
    364366        return status; 
     
    367369    /* Create upstream/get buffers */ 
    368370    status = pjmedia_delay_buf_create(pool, "scombdb-up", 
    369                                       port->info.clock_rate, 
    370                                       port->info.samples_per_frame, 
    371                                       port->info.channel_count, 
    372                                       buf_cnt * ptime, 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); 
    374376    if (status != PJ_SUCCESS) { 
    375377        pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf); 
     
    379381    /* And temporary upstream/get buffer */ 
    380382    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)); 
    382385 
    383386    /* Save port in the splitcomb */ 
     
    437440 
    438441    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); 
    440443    } 
    441444 
     
    485488 */ 
    486489static pj_status_t put_frame(pjmedia_port *this_port,  
    487                              const pjmedia_frame *frame) 
     490                             pjmedia_frame *frame) 
    488491{ 
    489492    struct splitcomb *sc = (struct splitcomb*) this_port; 
     
    492495    /* Handle null frame */ 
    493496    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) { 
    495498            pjmedia_port *port = sc->port_desc[ch].port; 
    496499 
     
    534537                /* Generate zero frame. */ 
    535538                pjmedia_zero_samples(sc->put_buf,  
    536                                      this_port->info.samples_per_frame); 
     539                                     PJMEDIA_PIA_SPF(&this_port->info)); 
    537540 
    538541                /* Put frame to delay buffer */ 
     
    548551     * it for now. 
    549552     */ 
    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), 
    551554                     PJ_EINVAL); 
    552555 
     
    554557     * Write mono frame into each channels  
    555558     */ 
    556     for (ch=0; ch < this_port->info.channel_count; ++ch) { 
     559    for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) { 
    557560        pjmedia_port *port = sc->port_desc[ch].port; 
    558561 
     
    562565        /* Extract the mono frame to temporary buffer */ 
    563566        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), 
    565568                           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)); 
    568571 
    569572        if (!sc->port_desc[ch].reversed) { 
     
    572575 
    573576            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); 
    575578            mono_frame.type = frame->type; 
    576579            mono_frame.timestamp.u64 = frame->timestamp.u64; 
     
    613616 
    614617    /* 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) { 
    616619        pjmedia_port *port = sc->port_desc[ch].port; 
    617620        pjmedia_frame mono_frame; 
     
    620623        if (!port) { 
    621624            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)); 
    624627 
    625628        } else if (sc->port_desc[ch].reversed == PJ_FALSE) { 
    626629            /* Read from normal port */ 
    627630            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); 
    629632            mono_frame.timestamp.u64 = frame->timestamp.u64; 
    630633 
     
    634637            { 
    635638                pjmedia_zero_samples(sc->get_buf,  
    636                                      port->info.samples_per_frame); 
     639                                     PJMEDIA_PIA_SPF(&port->info)); 
    637640            } 
    638641 
     
    652655            } else { 
    653656                pjmedia_zero_samples(sc->get_buf,  
    654                                      port->info.samples_per_frame); 
     657                                     PJMEDIA_PIA_SPF(&port->info)); 
    655658            } 
    656659 
     
    661664        store_mono_frame(sc->get_buf,  
    662665                         (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)); 
    666669 
    667670        has_frame = PJ_TRUE; 
     
    671674    if (has_frame) { 
    672675        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); 
    674677    } else 
    675678        frame->type = PJMEDIA_FRAME_TYPE_NONE; 
     
    695698 */ 
    696699static pj_status_t rport_put_frame(pjmedia_port *this_port,  
    697                                    const pjmedia_frame *frame) 
     700                                   pjmedia_frame *frame) 
    698701{ 
    699702    struct reverse_port *rport = (struct reverse_port*) this_port; 
    700703 
    701     pj_assert(frame->size <= rport->base.info.bytes_per_frame); 
     704    pj_assert(frame->size <= PJMEDIA_PIA_AVG_FSZ(&rport->base.info)); 
    702705 
    703706    /* Handle NULL frame */ 
     
    731734        /* Generate zero frame. */ 
    732735        pjmedia_zero_samples(rport->tmp_up_buf,  
    733                              this_port->info.samples_per_frame); 
     736                             PJMEDIA_PIA_SPF(&this_port->info)); 
    734737 
    735738        /* Put frame to delay buffer */ 
     
    739742 
    740743    /* 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), 
    742745                     PJ_EINVAL); 
    743746 
     
    756759     */ 
    757760    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)); 
    759762 
    760763    /* Put frame to delay buffer */ 
     
    784787 
    785788    /* Get frame from delay buffer */ 
    786     frame->size = this_port->info.bytes_per_frame; 
     789    frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info); 
    787790    frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    788791    frame->timestamp.u64 = rport->buf[DIR_DOWNSTREAM].ts.u64; 
Note: See TracChangeset for help on using the changeset viewer.