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/stereo_port.c

    r2394 r3392  
    4040 
    4141static pj_status_t stereo_put_frame(pjmedia_port *this_port, 
    42                                     const pjmedia_frame *frame); 
     42                                    pjmedia_frame *frame); 
    4343static pj_status_t stereo_get_frame(pjmedia_port *this_port,  
    4444                                    pjmedia_frame *frame); 
     
    6161 
    6262    /* Only supports 16bit samples per frame */ 
    63     PJ_ASSERT_RETURN(dn_port->info.bits_per_sample == 16, PJMEDIA_ENCBITS); 
     63    PJ_ASSERT_RETURN(PJMEDIA_PIA_BITS(&dn_port->info) == 16, 
     64                     PJMEDIA_ENCBITS); 
    6465 
    6566    /* Validate channel counts */ 
    66     PJ_ASSERT_RETURN(((dn_port->info.channel_count>1 && channel_count==1) || 
    67                       (dn_port->info.channel_count==1 && channel_count>1)), 
     67    PJ_ASSERT_RETURN(((PJMEDIA_PIA_CCNT(&dn_port->info)>1 && 
     68                              channel_count==1) || 
     69                      (PJMEDIA_PIA_CCNT(&dn_port->info)==1 && 
     70                              channel_count>1)), 
    6871                      PJ_EINVAL); 
    6972 
     
    7275    PJ_ASSERT_RETURN(sport != NULL, PJ_ENOMEM); 
    7376 
    74     samples_per_frame = dn_port->info.samples_per_frame * channel_count / 
    75                         dn_port->info.channel_count; 
     77    samples_per_frame = PJMEDIA_PIA_SPF(&dn_port->info) * channel_count / 
     78                          PJMEDIA_PIA_CCNT(&dn_port->info); 
    7679 
    7780    pjmedia_port_info_init(&sport->base.info, &name, SIGNATURE,  
    78                            dn_port->info.clock_rate, 
     81                           PJMEDIA_PIA_SRATE(&dn_port->info), 
    7982                           channel_count,  
    80                            dn_port->info.bits_per_sample,  
     83                           PJMEDIA_PIA_BITS(&dn_port->info), 
    8184                           samples_per_frame); 
    8285 
     
    8689    /* We always need buffer for put_frame */ 
    8790    sport->put_buf = (pj_int16_t*) 
    88                      pj_pool_alloc(pool, dn_port->info.bytes_per_frame); 
     91                     pj_pool_alloc(pool, 
     92                                   PJMEDIA_PIA_AVG_FSZ(&dn_port->info)); 
    8993 
    9094    /* See if we need buffer for get_frame */ 
    91     if (dn_port->info.channel_count > channel_count) { 
     95    if (PJMEDIA_PIA_CCNT(&dn_port->info) > channel_count) { 
    9296        sport->get_buf = (pj_int16_t*) 
    93                          pj_pool_alloc(pool, dn_port->info.bytes_per_frame); 
     97                         pj_pool_alloc(pool, 
     98                                       PJMEDIA_PIA_AVG_FSZ(&dn_port->info)); 
    9499    } 
    95100 
     
    107112 
    108113static pj_status_t stereo_put_frame(pjmedia_port *this_port, 
    109                                     const pjmedia_frame *frame) 
     114                                    pjmedia_frame *frame) 
    110115{ 
    111116    struct stereo_port *sport = (struct stereo_port*) this_port; 
     117    const pjmedia_audio_format_detail *s_afd, *dn_afd; 
    112118    pjmedia_frame tmp_frame; 
    113119 
     
    117123    } 
    118124 
     125    s_afd = pjmedia_format_get_audio_format_detail(&this_port->info.fmt, 1); 
     126    dn_afd = pjmedia_format_get_audio_format_detail(&sport->dn_port->info.fmt, 
     127                                                    1); 
     128 
    119129    if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) { 
    120130        tmp_frame.buf = sport->put_buf; 
    121         if (sport->dn_port->info.channel_count == 1) { 
     131        if (dn_afd->channel_count == 1) { 
    122132            pjmedia_convert_channel_nto1((pj_int16_t*)tmp_frame.buf,  
    123133                                         (const pj_int16_t*)frame->buf, 
    124                                          sport->base.info.channel_count,  
    125                                          sport->base.info.samples_per_frame,  
     134                                         s_afd->channel_count, 
     135                                         PJMEDIA_AFD_SPF(s_afd), 
    126136                                         (sport->options & PJMEDIA_STEREO_MIX), 
    127137                                         0); 
     
    129139            pjmedia_convert_channel_1ton((pj_int16_t*)tmp_frame.buf,  
    130140                                         (const pj_int16_t*)frame->buf, 
    131                                          sport->dn_port->info.channel_count,  
    132                                          sport->base.info.samples_per_frame, 
     141                                         dn_afd->channel_count, 
     142                                         PJMEDIA_AFD_SPF(s_afd), 
    133143                                         sport->options); 
    134144        } 
    135         tmp_frame.size = sport->dn_port->info.bytes_per_frame; 
     145        tmp_frame.size = PJMEDIA_AFD_AVG_FSZ(dn_afd); 
    136146    } else { 
    137147        tmp_frame.buf = frame->buf; 
     
    151161{ 
    152162    struct stereo_port *sport = (struct stereo_port*) this_port; 
     163    const pjmedia_audio_format_detail *s_afd, *dn_afd; 
    153164    pjmedia_frame tmp_frame; 
    154165    pj_status_t status; 
     
    160171    } 
    161172 
     173    s_afd = pjmedia_format_get_audio_format_detail(&this_port->info.fmt, 1); 
     174    dn_afd = pjmedia_format_get_audio_format_detail(&sport->dn_port->info.fmt, 
     175                                                    1); 
     176 
    162177    tmp_frame.buf = sport->get_buf? sport->get_buf : frame->buf; 
    163     tmp_frame.size = sport->dn_port->info.bytes_per_frame; 
     178    tmp_frame.size = PJMEDIA_PIA_AVG_FSZ(&sport->dn_port->info); 
    164179    tmp_frame.timestamp.u64 = frame->timestamp.u64; 
    165180    tmp_frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
     
    178193    } 
    179194 
    180     if (sport->base.info.channel_count == 1) { 
     195    if (s_afd->channel_count == 1) { 
    181196        pjmedia_convert_channel_nto1((pj_int16_t*)frame->buf,  
    182197                                     (const pj_int16_t*)tmp_frame.buf, 
    183                                      sport->dn_port->info.channel_count,  
    184                                      sport->dn_port->info.samples_per_frame,  
     198                                     dn_afd->channel_count, 
     199                                     PJMEDIA_AFD_SPF(s_afd), 
    185200                                     (sport->options & PJMEDIA_STEREO_MIX), 0); 
    186201    } else { 
    187202        pjmedia_convert_channel_1ton((pj_int16_t*)frame->buf,  
    188203                                     (const pj_int16_t*)tmp_frame.buf, 
    189                                      sport->base.info.channel_count,  
    190                                      sport->dn_port->info.samples_per_frame, 
     204                                     s_afd->channel_count, 
     205                                     PJMEDIA_AFD_SPF(dn_afd), 
    191206                                     sport->options); 
    192207    } 
    193208 
    194     frame->size = sport->base.info.bytes_per_frame; 
     209    frame->size = PJMEDIA_AFD_AVG_FSZ(s_afd); 
    195210    frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    196211 
Note: See TracChangeset for help on using the changeset viewer.