Ignore:
Timestamp:
Feb 5, 2009 10:59:14 AM (15 years ago)
Author:
nanang
Message:
  • Added new API for sound & sound port to create/open sound device with extended setting, to allow opening sound device with non-PCM format and other settings.
  • Updated symbian_ua/ua.cpp to be able to reopen sound device when audio stream session is using non-PCM data/passthrough codec.
  • Updated stream.c to allow it works with non-PCM data.
  • Added PCMU/A frames processing into non-PCM play/record callbacks in symbian_audio_aps.cpp.
  • Added passthrough codec init/deinitialization in pjsua-lib.
  • Added a new pjmedia_frame_ext helper function, pjmedia_frame_ext_pop_subframes, to pop-out/remove some subframes.
  • Other minor updates/fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c

    r2437 r2438  
    997997                                           (pjmedia_frame*)f_dst); 
    998998 
    999                     /* Update TX timestamp. */ 
    1000                     pj_add_timestamp32(&cport_dst->ts_tx,  
    1001                                        cport_dst->samples_per_frame); 
    1002  
    1003999                    /* Reset TX buffer. */ 
    10041000                    f_dst->subframe_cnt = 0; 
    10051001                    f_dst->samples_cnt = 0; 
    10061002                } 
     1003 
     1004                /* Update TX timestamp. */ 
     1005                pj_add_timestamp32(&cport_dst->ts_tx,  
     1006                                   cport_dst->samples_per_frame); 
     1007 
    10071008            } 
    10081009        } 
     
    10371038                    pjmedia_port_put_frame(cport_dst->port, frm_dst); 
    10381039 
    1039                     /* Update TX timestamp. */ 
    1040                     pj_add_timestamp32(&cport_dst->ts_tx,  
    1041                                        cport_dst->samples_per_frame); 
    1042                   
    10431040                    /* Reset TX buffer. */ 
    10441041                    frm_dst->size = 0; 
    10451042                } 
     1043 
     1044                /* Update TX timestamp. */ 
     1045                pj_add_timestamp32(&cport_dst->ts_tx,  
     1046                                   cport_dst->samples_per_frame); 
    10461047            } 
    10471048        } 
     
    10631064                frm_dst->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    10641065                frm_dst->size = cport_dst->samples_per_frame << 1; 
    1065                 if (cport_dst->port) 
     1066                if (cport_dst->port) { 
    10661067                    pjmedia_port_put_frame(cport_dst->port, frm_dst); 
     1068 
     1069                    /* Reset TX buffer. */ 
     1070                    frm_dst->size = 0; 
     1071                } 
    10671072 
    10681073                /* Update TX timestamp. */ 
    10691074                pj_add_timestamp32(&cport_dst->ts_tx,  
    10701075                                   cport_dst->samples_per_frame); 
    1071  
    1072                 /* Reset TX buffer. */ 
    1073                 frm_dst->size = 0; 
    10741076            } 
    10751077        } else { 
     
    10801082                pjmedia_frame_ext_append_subframe(f_dst, NULL, 0, (pj_uint16_t) 
    10811083                                                  (cport_dst->samples_per_frame- 
    1082                                                   f_dst->samples_cnt)); 
    1083                 if (cport_dst->port) 
     1084                                                   f_dst->samples_cnt)); 
     1085                if (cport_dst->port) { 
    10841086                    pjmedia_port_put_frame(cport_dst->port, frm_dst); 
     1087 
     1088                    /* Reset TX buffer. */ 
     1089                    f_dst->subframe_cnt = 0; 
     1090                    f_dst->samples_cnt = 0; 
     1091                } 
    10851092 
    10861093                /* Update TX timestamp. */ 
    10871094                pj_add_timestamp32(&cport_dst->ts_tx,  
    10881095                                   cport_dst->samples_per_frame); 
    1089  
    1090                 /* Reset TX buffer. */ 
    1091                 f_dst->subframe_cnt = 0; 
    1092                 f_dst->samples_cnt = 0; 
    10931096            } 
    10941097        } 
     
    10961099        /* Synchronize clock. */ 
    10971100        while (pj_cmp_timestamp(&cport_dst->ts_clock,  
    1098                                 &cport_dst->ts_tx) >= 0) 
     1101                                &cport_dst->ts_tx) > 0) 
    10991102        { 
    1100             if (cport_dst->port) { 
    1101                 frm_dst->type = PJMEDIA_FRAME_TYPE_NONE; 
    1102                 frm_dst->timestamp = cport_dst->ts_tx; 
     1103            frm_dst->type = PJMEDIA_FRAME_TYPE_NONE; 
     1104            frm_dst->timestamp = cport_dst->ts_tx; 
     1105            if (cport_dst->port) 
    11031106                pjmedia_port_put_frame(cport_dst->port, frm_dst); 
    1104             } 
     1107 
     1108            /* Update TX timestamp. */ 
    11051109            pj_add_timestamp32(&cport_dst->ts_tx, cport_dst->samples_per_frame); 
    11061110        } 
     
    12351239            cport->tx_level = 0; 
    12361240 
    1237             while (pj_cmp_timestamp(&cport->ts_clock, &cport->ts_tx) >= 0) 
     1241            while (pj_cmp_timestamp(&cport->ts_clock, &cport->ts_tx) > 0) 
    12381242            { 
    12391243                if (cport->tx_setting == PJMEDIA_PORT_ENABLE) { 
     
    12651269            pj_uint16_t samples_per_subframe; 
    12661270             
     1271            if (f_src_->samples_cnt < this_cport->samples_per_frame) { 
     1272                pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 
     1273                frame->type = PJMEDIA_FRAME_TYPE_NONE; 
     1274                break; 
     1275            } 
     1276 
    12671277            f_dst->samples_cnt = 0; 
    12681278            f_dst->subframe_cnt = 0; 
     
    12701280            samples_per_subframe = f_src_->samples_cnt / f_src_->subframe_cnt; 
    12711281 
     1282 
    12721283            while (f_dst->samples_cnt < this_cport->samples_per_frame) { 
    12731284                sf = pjmedia_frame_ext_get_subframe(f_src_, i++); 
     1285                pj_assert(sf); 
    12741286                pjmedia_frame_ext_append_subframe(f_dst, sf->data, sf->bitlen, 
    12751287                                                  samples_per_subframe); 
     
    12771289 
    12781290            /* Shift left TX buffer. */ 
    1279             sf = pjmedia_frame_ext_get_subframe(f_src_, i); 
    1280             if (sf) { 
    1281                 pjmedia_frame_ext_subframe *sf_end; 
    1282                 unsigned len; 
    1283  
    1284                 sf_end = pjmedia_frame_ext_get_subframe(f_src_,  
    1285                                                     f_src_->subframe_cnt -1); 
    1286                 len = (pj_uint8_t*)sf_end - (pj_uint8_t*)sf + sf_end->bitlen/8; 
    1287                 if (sf_end->bitlen % 8 != 0) 
    1288                     ++len; 
    1289                 pj_memmove(this_cport->tx_buf + sizeof(pjmedia_frame_ext), sf, 
    1290                            len); 
     1291            pjmedia_frame_ext_pop_subframes(f_src_, i); 
     1292 
     1293        } else if (f_src->type == PJMEDIA_FRAME_TYPE_AUDIO) { 
     1294            if ((f_src->size>>1) < this_cport->samples_per_frame) { 
     1295                pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 
     1296                frame->type = PJMEDIA_FRAME_TYPE_NONE; 
     1297                break; 
    12911298            } 
    1292             f_src_->samples_cnt = f_src_->samples_cnt -  
    1293                                   (pj_uint16_t)(i * samples_per_subframe); 
    1294             f_src_->subframe_cnt = f_src_->subframe_cnt - (pj_uint16_t)i; 
    1295  
    1296         } else if (f_src->type == PJMEDIA_FRAME_TYPE_AUDIO) { 
     1299 
    12971300            pjmedia_copy_samples((pj_int16_t*)frame->buf,  
    12981301                                 (pj_int16_t*)f_src->buf,  
     
    13071310                                     this_cport->samples_per_frame, 
    13081311                                     f_src->size >> 1); 
     1312        } else { /* PJMEDIA_FRAME_TYPE_NONE */ 
     1313            /* Reset TX buffer */ 
     1314            pj_bzero(this_cport->tx_buf, sizeof(pjmedia_frame_ext)); 
     1315            frame->type = PJMEDIA_FRAME_TYPE_NONE; 
    13091316        } 
    13101317    } while (0); 
     
    13261333    unsigned j; 
    13271334    pj_int32_t level; 
    1328  
    1329     /* Check for correct size. */ 
    1330     PJ_ASSERT_RETURN( f->size == conf->samples_per_frame * 
    1331                                  conf->bits_per_sample / 8, 
    1332                       PJMEDIA_ENCSAMPLESPFRAME); 
    13331335 
    13341336    pj_add_timestamp32(&cport->ts_rx, cport->samples_per_frame); 
Note: See TracChangeset for help on using the changeset viewer.