Ignore:
Timestamp:
Mar 4, 2010 3:47:25 PM (12 years ago)
Author:
nanang
Message:

Ticket #1008:

  • Applied VAS AMR playback solution from Forum Nokia.
  • Fixed AMR playback for VAS and APS in composing DTX/NO_DATA (frame type 15) frame header.
  • Modified symbsndtest test application to support non-PCM audio.
  • Minor check fix in pjmedia_codec_mgr_destroy(), caught assertion when VAS factory init failed and media endpoint tried to destroy codec manager (codec mgr hasn't been init-ed).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp

    r2821 r3116  
    4141static unsigned rec_cnt, play_cnt; 
    4242static pj_time_val t_start; 
    43  
    44 pj_pool_t *pool; 
    45 pjmedia_delay_buf *delaybuf; 
     43static pjmedia_aud_param param; 
     44static pj_pool_t *pool; 
     45static pjmedia_delay_buf *delaybuf; 
     46static char frame_buf[256]; 
     47 
     48static void copy_frame_ext(pjmedia_frame_ext *f_dst,  
     49                           const pjmedia_frame_ext *f_src)  
     50{ 
     51    pj_bzero(f_dst, sizeof(*f_dst)); 
     52    if (f_src->subframe_cnt) { 
     53        f_dst->base.type = PJMEDIA_FRAME_TYPE_EXTENDED; 
     54        for (unsigned i = 0; i < f_src->subframe_cnt; ++i) { 
     55            pjmedia_frame_ext_subframe *sf; 
     56            sf = pjmedia_frame_ext_get_subframe(f_src, i); 
     57            pjmedia_frame_ext_append_subframe(f_dst, sf->data, sf->bitlen,  
     58                                              param.samples_per_frame); 
     59        } 
     60    } else { 
     61        f_dst->base.type = PJMEDIA_FRAME_TYPE_NONE; 
     62    } 
     63} 
    4664 
    4765/* Logging callback */ 
     
    138156    PJ_UNUSED_ARG(user_data); 
    139157 
    140     pjmedia_delay_buf_put(delaybuf, (pj_int16_t*)frame->buf); 
    141  
    142     if (frame->size != SAMPLES_PER_FRAME*2) { 
    143                 PJ_LOG(3, (THIS_FILE, "Size captured = %u", 
    144                            frame->size)); 
     158    if (param.ext_fmt.id == PJMEDIA_FORMAT_PCM) { 
     159        pjmedia_delay_buf_put(delaybuf, (pj_int16_t*)frame->buf); 
     160     
     161        if (frame->size != SAMPLES_PER_FRAME*2) { 
     162                    PJ_LOG(3, (THIS_FILE, "Size captured = %u", 
     163                               frame->size)); 
     164        } 
     165    } else { 
     166        pjmedia_frame_ext *f_src = (pjmedia_frame_ext*)frame; 
     167        pjmedia_frame_ext *f_dst = (pjmedia_frame_ext*)frame_buf; 
     168         
     169        copy_frame_ext(f_dst, f_src); 
    145170    } 
    146171 
     
    155180    PJ_UNUSED_ARG(user_data); 
    156181 
    157     pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)frame->buf); 
    158     frame->size = SAMPLES_PER_FRAME*2; 
    159     frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 
     182    if (param.ext_fmt.id == PJMEDIA_FORMAT_PCM) { 
     183        pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)frame->buf); 
     184        frame->size = SAMPLES_PER_FRAME*2; 
     185        frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 
     186    } else { 
     187        pjmedia_frame_ext *f_src = (pjmedia_frame_ext*)frame_buf; 
     188        pjmedia_frame_ext *f_dst = (pjmedia_frame_ext*)frame; 
     189 
     190        copy_frame_ext(f_dst, f_src); 
     191    } 
    160192 
    161193    ++play_cnt; 
     
    166198static pj_status_t snd_start(unsigned flag) 
    167199{ 
    168     pjmedia_aud_param param; 
    169200    pj_status_t status; 
    170201 
     
    179210    param.samples_per_frame = SAMPLES_PER_FRAME; 
    180211    param.dir = (pjmedia_dir) flag; 
     212    param.ext_fmt.id = PJMEDIA_FORMAT_AMR; 
     213    param.ext_fmt.bitrate = 12200; 
     214    param.output_route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; 
    181215 
    182216    status = pjmedia_aud_stream_create(&param, &rec_cb, &play_cb, NULL, &strm); 
Note: See TracChangeset for help on using the changeset viewer.