Changeset 2439


Ignore:
Timestamp:
Feb 5, 2009 12:28:38 PM (15 years ago)
Author:
nanang
Message:
  • Fixed pjmedia_frame_ext_pop_subframes() in calculating len.
  • Fixed symbian_sound_aps.cpp in filling silence, previously just by filling zeroes.
  • Some fixes in ua.cpp: always reopen sound device (even if PCM is in use), make sure sound device closed before quit, release application pool.
Location:
pjproject/branches/projects/aps-direct
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h

    r2438 r2439  
    382382    move_src = (pj_uint8_t*)pjmedia_frame_ext_get_subframe(frm, n); 
    383383    sf = pjmedia_frame_ext_get_subframe(frm, frm->subframe_cnt-1); 
    384     move_len = (pj_uint8_t*)sf - move_src + sf->bitlen/8; 
     384    move_len = (pj_uint8_t*)sf - move_src + sizeof(sf->bitlen) + sf->bitlen/8; 
    385385    if (sf->bitlen % 8 != 0) 
    386386        ++move_len; 
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/symbian_sound_aps.cpp

    r2438 r2439  
    759759 
    760760    switch(strm->setting.format.u32) { 
    761      
    762761    case PJMEDIA_FOURCC_G711U: 
    763762    case PJMEDIA_FOURCC_G711A: 
    764         /* Add header. */ 
    765         buf.iBuffer.Append(1); 
    766         buf.iBuffer.Append(0); 
    767  
    768         /* Assume frame size is 10ms if frame size hasn't been known. */ 
    769         if (g711_frame_len == 0) 
    770             g711_frame_len = 80; 
    771          
    772         /* Call parent stream callback to get samples to play. */ 
    773         while (samples_ready < g711_frame_len) { 
    774             if (frame->samples_cnt == 0) { 
    775                 frame->base.type = PJMEDIA_FRAME_TYPE_EXTENDED; 
    776                 strm->play_cb(strm->user_data, 0, strm->play_buf, 
    777                               strm->samples_per_frame<<1); 
     763        { 
     764            /* Add header. */ 
     765            buf.iBuffer.Append(1); 
     766            buf.iBuffer.Append(0); 
     767     
     768            /* Assume frame size is 10ms if frame size hasn't been known. */ 
     769            if (g711_frame_len == 0) 
     770                g711_frame_len = 80; 
     771             
     772            /* Call parent stream callback to get samples to play. */ 
     773            while (samples_ready < g711_frame_len) { 
     774                if (frame->samples_cnt == 0) { 
     775                    frame->base.type = PJMEDIA_FRAME_TYPE_EXTENDED; 
     776                    strm->play_cb(strm->user_data, 0, strm->play_buf, 
     777                                  strm->samples_per_frame<<1); 
     778                     
     779                    pj_assert(frame->base.type==PJMEDIA_FRAME_TYPE_EXTENDED || 
     780                              frame->base.type==PJMEDIA_FRAME_TYPE_NONE); 
     781                } 
     782     
     783                if (frame->base.type == PJMEDIA_FRAME_TYPE_EXTENDED) {  
     784                    pjmedia_frame_ext_subframe *sf; 
     785                    unsigned samples_cnt; 
     786                     
     787                    sf = pjmedia_frame_ext_get_subframe(frame, 0); 
     788                    samples_cnt = frame->samples_cnt / frame->subframe_cnt; 
     789                    if (sf->data && sf->bitlen) 
     790                        buf.iBuffer.Append((TUint8*)sf->data, sf->bitlen>>3); 
     791                    else { 
     792                        pj_uint8_t silence_code; 
     793                         
     794                        if (strm->setting.format.u32 == PJMEDIA_FOURCC_G711U) 
     795                            silence_code = pjmedia_linear2ulaw(0); 
     796                        else 
     797                            silence_code = pjmedia_linear2alaw(0); 
     798                         
     799                        buf.iBuffer.AppendFill(silence_code, samples_cnt); 
     800                    } 
     801                    samples_ready += samples_cnt; 
     802                     
     803                    pjmedia_frame_ext_pop_subframes(frame, 1); 
    778804                 
    779                 pj_assert(frame->base.type == PJMEDIA_FRAME_TYPE_EXTENDED || 
    780                           frame->base.type == PJMEDIA_FRAME_TYPE_NONE); 
    781             } 
    782  
    783             if (frame->base.type == PJMEDIA_FRAME_TYPE_EXTENDED) {  
    784                 pjmedia_frame_ext_subframe *sf; 
    785                 unsigned samples_cnt; 
    786                  
    787                 sf = pjmedia_frame_ext_get_subframe(frame, 0); 
    788                 samples_cnt = frame->samples_cnt / frame->subframe_cnt; 
    789                 if (sf->data && sf->bitlen) 
    790                     buf.iBuffer.Append((TUint8*)sf->data, sf->bitlen>>3); 
    791                 else  
    792                     buf.iBuffer.AppendFill(0, samples_cnt); 
    793                 samples_ready += samples_cnt; 
    794                  
    795                 pjmedia_frame_ext_pop_subframes(frame, 1); 
    796              
    797             } else { /* PJMEDIA_FRAME_TYPE_NONE */ 
    798                 buf.iBuffer.AppendFill(0, g711_frame_len - samples_ready); 
    799                 samples_ready = g711_frame_len; 
    800                 frame->samples_cnt = 0; 
    801                 frame->subframe_cnt = 0; 
     805                } else { /* PJMEDIA_FRAME_TYPE_NONE */ 
     806                    pj_uint8_t silence_code; 
     807                     
     808                    if (strm->setting.format.u32 == PJMEDIA_FOURCC_G711U) 
     809                        silence_code = pjmedia_linear2ulaw(0); 
     810                    else 
     811                        silence_code = pjmedia_linear2alaw(0); 
     812                     
     813                    buf.iBuffer.AppendFill(silence_code,  
     814                                           g711_frame_len - samples_ready); 
     815                    samples_ready = g711_frame_len; 
     816                    frame->samples_cnt = 0; 
     817                    frame->subframe_cnt = 0; 
     818                } 
    802819            } 
    803820        } 
     
    807824        break; 
    808825    } 
    809      
    810     unsigned tes = buf.iBuffer.Length(); 
    811826} 
    812827 
  • pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp

    r2438 r2439  
    281281        return; 
    282282 
    283     /* Don't need to reopen sound device when the session doesn't use 
    284      * PCM format.  
    285      */ 
    286     if (strm_info->param->info.format.u32 == 0 || 
    287         strm_info->param->info.format.u32 == PJMEDIA_FOURCC_L16)  
    288     { 
    289         return; 
    290     } 
    291      
    292283    pj_bzero(&setting, sizeof(setting)); 
    293284    setting.format = strm_info->param->info.format; 
     
    878869#endif 
    879870         
    880     // Let pjsua destroys app pool, since the pool may still be used by app 
    881     // until pjsua_destroy() finished. 
    882     // e.g: quitting app when there is an active call may cause sound port  
    883     // memory destroyed before sound port itself gets closed/destroyed. 
    884     /* 
     871    if (snd_port) { 
     872        pjmedia_snd_port_destroy(snd_port); 
     873        snd_port = NULL; 
     874    } 
     875 
    885876    // Release application pool 
    886877    if (app_pool) { 
     
    888879        app_pool = NULL; 
    889880    } 
    890     */ 
    891881     
    892882    // Shutdown pjsua 
Note: See TracChangeset for help on using the changeset viewer.