Ignore:
Timestamp:
Feb 4, 2014 10:13:56 AM (10 years ago)
Author:
bennylp
Message:

Misc (re #1630): Fixing warnings about variable set but not used with recent gcc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r4613 r4728  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020#include <pjmedia/stream.h> 
     
    185185     */ 
    186186    pj_bool_t                has_g722_mpeg_bug; 
    187                                             /**< Flag to specify whether  
    188                                                  normalization process  
     187                                            /**< Flag to specify whether 
     188                                                 normalization process 
    189189                                                 is needed                  */ 
    190190    unsigned                 rtp_tx_ts_len_per_pkt; 
    191191                                            /**< Normalized ts length per packet 
    192                                                  transmitted according to  
     192                                                 transmitted according to 
    193193                                                 'erroneous' definition     */ 
    194194    unsigned                 rtp_rx_ts_len_per_frame; 
    195195                                            /**< Normalized ts length per frame 
    196                                                  received according to  
     196                                                 received according to 
    197197                                                 'erroneous' definition     */ 
    198198    unsigned                 rtp_rx_last_cnt;/**< Nb of frames in last pkt  */ 
     
    203203 
    204204#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 
    205     pj_uint32_t              rtcp_xr_last_tx;  /**< RTCP XR tx time  
     205    pj_uint32_t              rtcp_xr_last_tx;  /**< RTCP XR tx time 
    206206                                                    in timestamp.           */ 
    207207    pj_uint32_t              rtcp_xr_interval; /**< Interval, in timestamp. */ 
    208     pj_sockaddr              rtcp_xr_dest;     /**< Additional remote RTCP XR  
    209                                                     dest. If sin_family is  
     208    pj_sockaddr              rtcp_xr_dest;     /**< Additional remote RTCP XR 
     209                                                    dest. If sin_family is 
    210210                                                    zero, it will be ignored*/ 
    211211    unsigned                 rtcp_xr_dest_len; /**< Length of RTCP XR dest 
     
    231231 
    232232/* RFC 2833 digit */ 
    233 static const char digitmap[16] = { '0', '1', '2', '3',  
    234                                    '4', '5', '6', '7',  
     233static const char digitmap[16] = { '0', '1', '2', '3', 
     234                                   '4', '5', '6', '7', 
    235235                                   '8', '9', '*', '#', 
    236236                                   'A', 'B', 'C', 'D'}; 
     
    285285} 
    286286 
    287 PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream,  
     287PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream, 
    288288                                    char **buf, pj_ssize_t len) 
    289289{ 
     
    460460 
    461461#else 
    462      
     462 
    463463    PJ_UNUSED_ARG(stream); 
    464464 
     
    498498    samples_per_frame = stream->codec_param.info.frm_ptime * 
    499499                        stream->codec_param.info.clock_rate * 
    500                         stream->codec_param.info.channel_cnt /  
     500                        stream->codec_param.info.channel_cnt / 
    501501                        1000; 
    502502    p_out_samp = (pj_int16_t*) frame->buf; 
    503503 
    504     for (samples_count=0; samples_count < samples_required;  
    505          samples_count += samples_per_frame)  
     504    for (samples_count=0; samples_count < samples_required; 
     505         samples_count += samples_per_frame) 
    506506    { 
    507507        char frame_type; 
     
    518518 
    519519        if (frame_type == PJMEDIA_JB_MISSING_FRAME) { 
    520              
     520 
    521521            /* Activate PLC */ 
    522             if (stream->codec->op->recover &&  
     522            if (stream->codec->op->recover && 
    523523                stream->codec_param.setting.plc && 
    524                 stream->plc_cnt < stream->max_plc_cnt)  
     524                stream->plc_cnt < stream->max_plc_cnt) 
    525525            { 
    526526                pjmedia_frame frame_out; 
     
    561561            /* Jitter buffer is empty. If this is the first "empty" state, 
    562562             * activate PLC to smoothen the fade-out, otherwise zero 
    563              * the frame.  
     563             * the frame. 
    564564             */ 
    565565            //Using this "if" will only invoke PLC for the first packet 
     
    568568            if (1) { 
    569569                /* Activate PLC to smoothen the missing frame */ 
    570                 if (stream->codec->op->recover &&  
     570                if (stream->codec->op->recover && 
    571571                    stream->codec_param.setting.plc && 
    572                     stream->plc_cnt < stream->max_plc_cnt)  
     572                    stream->plc_cnt < stream->max_plc_cnt) 
    573573                { 
    574574                    pjmedia_frame frame_out; 
     
    590590 
    591591                    with_plc = ", plc invoked"; 
    592                 }  
     592                } 
    593593            } 
    594594 
     
    604604                /* Report changing frame type event */ 
    605605                pjmedia_jbuf_get_state(stream->jb, &jb_state); 
    606                 PJ_LOG(5,(stream->port.info.name.ptr,  
    607                           "Jitter buffer empty (prefetch=%d)%s",  
     606                PJ_LOG(5,(stream->port.info.name.ptr, 
     607                          "Jitter buffer empty (prefetch=%d)%s", 
    608608                          jb_state.prefetch, with_plc)); 
    609609 
     
    623623 
    624624            /* Always activate PLC when it's available.. */ 
    625             if (stream->codec->op->recover &&  
     625            if (stream->codec->op->recover && 
    626626                stream->codec_param.setting.plc && 
    627                 stream->plc_cnt < stream->max_plc_cnt)  
     627                stream->plc_cnt < stream->max_plc_cnt) 
    628628            { 
    629629                pjmedia_frame frame_out; 
     
    645645 
    646646                with_plc = ", plc invoked"; 
    647             }  
     647            } 
    648648 
    649649            if (samples_count < samples_required) { 
     
    658658                /* Report changing frame type event */ 
    659659                pjmedia_jbuf_get_state(stream->jb, &jb_state); 
    660                 PJ_LOG(5,(stream->port.info.name.ptr,  
    661                           "Jitter buffer is bufferring (prefetch=%d)%s",  
     660                PJ_LOG(5,(stream->port.info.name.ptr, 
     661                          "Jitter buffer is bufferring (prefetch=%d)%s", 
    662662                          jb_state.prefetch, with_plc)); 
    663663 
     
    684684            frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE; 
    685685            status = pjmedia_codec_decode( stream->codec, &frame_in, 
    686                                            (unsigned)frame_out.size,  
     686                                           (unsigned)frame_out.size, 
    687687                                           &frame_out); 
    688688            if (status != 0) { 
    689                 LOGERR_((port->info.name.ptr, "codec decode() error",  
     689                LOGERR_((port->info.name.ptr, "codec decode() error", 
    690690                         status)); 
    691691 
    692                 pjmedia_zero_samples(p_out_samp + samples_count,  
     692                pjmedia_zero_samples(p_out_samp + samples_count, 
    693693                                     samples_per_frame); 
    694694            } 
     
    696696            if (stream->jb_last_frm != frame_type) { 
    697697                /* Report changing frame type event */ 
    698                 PJ_LOG(5,(stream->port.info.name.ptr,  
     698                PJ_LOG(5,(stream->port.info.name.ptr, 
    699699                          "Jitter buffer starts returning normal frames " 
    700700                          "(after %d empty/lost)", 
     
    753753    samples_per_frame = stream->codec_param.info.frm_ptime * 
    754754                        stream->codec_param.info.clock_rate * 
    755                         stream->codec_param.info.channel_cnt /  
     755                        stream->codec_param.info.channel_cnt / 
    756756                        1000; 
    757757 
     
    774774        trace_jb_get(stream, frame_type, frame_size); 
    775775#endif 
    776          
     776 
    777777        /* Unlock jitter buffer mutex. */ 
    778778        pj_mutex_unlock( stream->jb_mutex ); 
     
    791791                                           0, frame); 
    792792            if (status != PJ_SUCCESS) { 
    793                 LOGERR_((port->info.name.ptr, "codec decode() error",  
     793                LOGERR_((port->info.name.ptr, "codec decode() error", 
    794794                         status)); 
    795795                pjmedia_frame_ext_append_subframe(f, NULL, 0, 
     
    799799            if (stream->jb_last_frm != frame_type) { 
    800800                /* Report changing frame type event */ 
    801                 PJ_LOG(5,(stream->port.info.name.ptr,  
     801                PJ_LOG(5,(stream->port.info.name.ptr, 
    802802                          "Jitter buffer starts returning normal frames " 
    803803                          "(after %d empty/lost)", 
     
    817817                status = pjmedia_codec_recover(stream->codec, 0, frame); 
    818818            } 
    819              
     819 
    820820            /* No PLC or PLC failed */ 
    821821            if (!stream->codec->op->recover || status != PJ_SUCCESS) { 
     
    840840                    /* Report changing frame type event */ 
    841841                    pjmedia_jbuf_get_state(stream->jb, &jb_state); 
    842                     PJ_LOG(5,(stream->port.info.name.ptr,  
    843                               "Jitter buffer empty (prefetch=%d)",  
     842                    PJ_LOG(5,(stream->port.info.name.ptr, 
     843                              "Jitter buffer empty (prefetch=%d)", 
    844844                              jb_state.prefetch)); 
    845845 
     
    859859                    /* Report changing frame type event */ 
    860860                    pjmedia_jbuf_get_state(stream->jb, &jb_state); 
    861                     PJ_LOG(5,(stream->port.info.name.ptr,  
     861                    PJ_LOG(5,(stream->port.info.name.ptr, 
    862862                              "Jitter buffer is bufferring (prefetch=%d)", 
    863863                              jb_state.prefetch)); 
     
    879879 * Transmit DTMF 
    880880 */ 
    881 static void create_dtmf_payload(pjmedia_stream *stream,  
     881static void create_dtmf_payload(pjmedia_stream *stream, 
    882882                                struct pjmedia_frame *frame_out, 
    883883                                int forced_last, int *first, int *last) 
     
    885885    pjmedia_rtp_dtmf_event *event; 
    886886    struct dtmf *digit = &stream->tx_dtmf_buf[0]; 
    887     pj_uint32_t cur_ts; 
    888887 
    889888    pj_assert(sizeof(pjmedia_rtp_dtmf_event) == 4); 
     
    892891 
    893892    event = (pjmedia_rtp_dtmf_event*) frame_out->buf; 
    894     cur_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts); 
    895893 
    896894    if (digit->duration == 0) { 
    897         PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c",  
     895        PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c", 
    898896                  digitmap[digit->event])); 
    899897        *first = 1; 
     
    988986        /* Update RTCP XR with current JB states */ 
    989987        pjmedia_jbuf_get_state(stream->jb, &jb_state); 
    990              
     988 
    991989        i = jb_state.avg_delay; 
    992         status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     990        status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    993991                                             PJMEDIA_RTCP_XR_INFO_JB_NOM, i); 
    994992        pj_assert(status == PJ_SUCCESS); 
    995993 
    996994        i = jb_state.max_delay; 
    997         status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     995        status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    998996                                             PJMEDIA_RTCP_XR_INFO_JB_MAX, i); 
    999997        pj_assert(status == PJ_SUCCESS); 
     
    10081006            /* Send the RTCP XR to third-party destination if specified */ 
    10091007            if (stream->rtcp_xr_dest_len) { 
    1010                 pjmedia_transport_send_rtcp2(stream->transport,  
     1008                pjmedia_transport_send_rtcp2(stream->transport, 
    10111009                                             &stream->rtcp_xr_dest, 
    1012                                              stream->rtcp_xr_dest_len,  
     1010                                             stream->rtcp_xr_dest_len, 
    10131011                                             xr_pkt, xr_len); 
    10141012            } 
     
    10501048static void check_tx_rtcp(pjmedia_stream *stream, pj_uint32_t timestamp) 
    10511049{ 
    1052     /* Note that timestamp may represent local or remote timestamp,  
     1050    /* Note that timestamp may represent local or remote timestamp, 
    10531051     * depending on whether this function is called from put_frame() 
    10541052     * or get_frame(). 
     
    10561054 
    10571055    if (stream->rtcp_last_tx == 0) { 
    1058          
     1056 
    10591057        stream->rtcp_last_tx = timestamp; 
    10601058 
     
    10671065            if (stream->rtcp_xr_last_tx == 0) { 
    10681066                stream->rtcp_xr_last_tx = timestamp; 
    1069             } else if (timestamp - stream->rtcp_xr_last_tx >=  
     1067            } else if (timestamp - stream->rtcp_xr_last_tx >= 
    10701068                       stream->rtcp_xr_interval) 
    10711069            { 
     
    11311129 
    11321130    /* How many samples are needed */ 
    1133     count = stream->codec_param.info.enc_ptime *  
     1131    count = stream->codec_param.info.enc_ptime * 
    11341132            PJMEDIA_PIA_SRATE(&stream->port.info) / 1000; 
    11351133 
     
    11541152 * put_frame_imp() 
    11551153 */ 
    1156 static pj_status_t put_frame_imp( pjmedia_port *port,  
     1154static pj_status_t put_frame_imp( pjmedia_port *port, 
    11571155                                  pjmedia_frame *frame ) 
    11581156{ 
     
    11751173        pj_uint32_t dtx_duration; 
    11761174 
    1177         dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent,  
     1175        dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent, 
    11781176                                           &frame->timestamp); 
    11791177        if (dtx_duration > 
     
    11941192    /* Number of samples in the frame */ 
    11951193    if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) 
    1196         ts_len = ((unsigned)frame->size >> 1) /  
     1194        ts_len = ((unsigned)frame->size >> 1) / 
    11971195                 stream->codec_param.info.channel_cnt; 
    11981196    else if (frame->type == PJMEDIA_FRAME_TYPE_EXTENDED) 
     
    12061204 
    12071205#if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0) 
    1208     /* Handle special case for audio codec with RTP timestamp inconsistence  
     1206    /* Handle special case for audio codec with RTP timestamp inconsistence 
    12091207     * e.g: G722, MPEG audio. 
    12101208     */ 
     
    12251223 
    12261224 
    1227     /* If we have DTMF digits in the queue, transmit the digits.  
     1225    /* If we have DTMF digits in the queue, transmit the digits. 
    12281226     * Otherwise encode the PCM buffer. 
    12291227     */ 
     
    12351233        /* Encapsulate into RTP packet. Note that: 
    12361234         *  - RTP marker should be set on the beginning of a new event 
    1237          *  - RTP timestamp is constant for the same packet.  
     1235         *  - RTP timestamp is constant for the same packet. 
    12381236         */ 
    1239         status = pjmedia_rtp_encode_rtp( &channel->rtp,  
    1240                                          stream->tx_event_pt, first,  
     1237        status = pjmedia_rtp_encode_rtp( &channel->rtp, 
     1238                                         stream->tx_event_pt, first, 
    12411239                                         (int)frame_out.size, 
    1242                                          (first ? rtp_ts_len : 0),  
    1243                                          (const void**)&rtphdr,  
     1240                                         (first ? rtp_ts_len : 0), 
     1241                                         (const void**)&rtphdr, 
    12441242                                         &rtphdrlen); 
    12451243 
    12461244        if (last) { 
    1247             /* This is the last packet for the event.  
     1245            /* This is the last packet for the event. 
    12481246             * Increment the RTP timestamp of the RTP session, for next 
    12491247             * RTP packets. 
     
    12721270               stream->codec_param.info.channel_cnt * 
    12731271               stream->codec_param.info.clock_rate/1000 < 
    1274                   PJ_ARRAY_SIZE(zero_frame))  
     1272                  PJ_ARRAY_SIZE(zero_frame)) 
    12751273    { 
    12761274        pjmedia_frame silence_frame; 
     
    12831281        silence_frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
    12841282        silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts); 
    1285          
     1283 
    12861284        /* Encode! */ 
    12871285        status = pjmedia_codec_encode( stream->codec, &silence_frame, 
    1288                                        channel->out_pkt_size -  
     1286                                       channel->out_pkt_size - 
    12891287                                       sizeof(pjmedia_rtp_hdr), 
    12901288                                       &frame_out); 
    12911289        if (status != PJ_SUCCESS) { 
    1292             LOGERR_((stream->port.info.name.ptr,  
     1290            LOGERR_((stream->port.info.name.ptr, 
    12931291                    "Codec encode() error", status)); 
    12941292            return status; 
     
    12961294 
    12971295        /* Encapsulate. */ 
    1298         status = pjmedia_rtp_encode_rtp( &channel->rtp,  
    1299                                          channel->pt, 0,  
    1300                                          (int)frame_out.size, rtp_ts_len,  
    1301                                          (const void**)&rtphdr,  
     1296        status = pjmedia_rtp_encode_rtp( &channel->rtp, 
     1297                                         channel->pt, 0, 
     1298                                         (int)frame_out.size, rtp_ts_len, 
     1299                                         (const void**)&rtphdr, 
    13021300                                         &rtphdrlen); 
    13031301 
     
    13091307    { 
    13101308        /* Encode! */ 
    1311         status = pjmedia_codec_encode( stream->codec, frame,  
    1312                                        channel->out_pkt_size -  
     1309        status = pjmedia_codec_encode( stream->codec, frame, 
     1310                                       channel->out_pkt_size - 
    13131311                                       sizeof(pjmedia_rtp_hdr), 
    13141312                                       &frame_out); 
    13151313        if (status != PJ_SUCCESS) { 
    1316             LOGERR_((stream->port.info.name.ptr,  
     1314            LOGERR_((stream->port.info.name.ptr, 
    13171315                    "Codec encode() error", status)); 
    13181316            return status; 
     
    13201318 
    13211319        /* Encapsulate. */ 
    1322         status = pjmedia_rtp_encode_rtp( &channel->rtp,  
    1323                                          channel->pt, 0,  
    1324                                          (int)frame_out.size, rtp_ts_len,  
    1325                                          (const void**)&rtphdr,  
     1320        status = pjmedia_rtp_encode_rtp( &channel->rtp, 
     1321                                         channel->pt, 0, 
     1322                                         (int)frame_out.size, rtp_ts_len, 
     1323                                         (const void**)&rtphdr, 
    13261324                                         &rtphdrlen); 
    13271325 
     
    13291327 
    13301328        /* Just update RTP session's timestamp. */ 
    1331         status = pjmedia_rtp_encode_rtp( &channel->rtp,  
    1332                                          0, 0,  
    1333                                          0, rtp_ts_len,  
    1334                                          (const void**)&rtphdr,  
     1329        status = pjmedia_rtp_encode_rtp( &channel->rtp, 
     1330                                         0, 0, 
     1331                                         0, rtp_ts_len, 
     1332                                         (const void**)&rtphdr, 
    13351333                                         &rtphdrlen); 
    13361334 
     
    13381336 
    13391337    if (status != PJ_SUCCESS) { 
    1340         LOGERR_((stream->port.info.name.ptr,  
     1338        LOGERR_((stream->port.info.name.ptr, 
    13411339                "RTP encode_rtp() error", status)); 
    13421340        return status; 
    13431341    } 
    13441342 
    1345     /* Check if now is the time to transmit RTCP SR/RR report.  
     1343    /* Check if now is the time to transmit RTCP SR/RR report. 
    13461344     * We only do this when stream direction is not "decoding only", because 
    13471345     * when it is, check_tx_rtcp() will be handled by get_frame(). 
     
    14141412 * RTP packet, and transmit to peer. 
    14151413 */ 
    1416 static pj_status_t put_frame( pjmedia_port *port,  
     1414static pj_status_t put_frame( pjmedia_port *port, 
    14171415                              pjmedia_frame *frame ) 
    14181416{ 
     
    14621460     */ 
    14631461    if (stream->vad_enabled != stream->codec_param.setting.vad && 
    1464         (stream->tx_duration - stream->ts_vad_disabled) >  
     1462        (stream->tx_duration - stream->ts_vad_disabled) > 
    14651463           PJMEDIA_PIA_SRATE(&stream->port.info) * 
    14661464          PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000) 
     
    14791477        pj_status_t status = PJ_SUCCESS; 
    14801478 
    1481         /* Copy original frame to temporary frame since we need  
     1479        /* Copy original frame to temporary frame since we need 
    14821480         * to modify it. 
    14831481         */ 
     
    15461544 * Handle incoming DTMF digits. 
    15471545 */ 
    1548 static void handle_incoming_dtmf( pjmedia_stream *stream,  
     1546static void handle_incoming_dtmf( pjmedia_stream *stream, 
    15491547                                  const void *payload, unsigned payloadlen) 
    15501548{ 
     
    15721570    /* Ignore unknown event. */ 
    15731571    if (event->event > 15) { 
    1574         PJ_LOG(5,(stream->port.info.name.ptr,  
     1572        PJ_LOG(5,(stream->port.info.name.ptr, 
    15751573                  "Ignored RTP pkt with bad DTMF event %d", 
    15761574                  event->event)); 
     
    15911589    if (stream->dtmf_cb) { 
    15921590 
    1593         stream->dtmf_cb(stream, stream->dtmf_cb_user_data,  
     1591        stream->dtmf_cb(stream, stream->dtmf_cb_user_data, 
    15941592                        digitmap[event->event]); 
    15951593 
     
    16011599        if (stream->rx_dtmf_count >= PJ_ARRAY_SIZE(stream->rx_dtmf_buf)) { 
    16021600            /* DTMF digits overflow.  Discard the oldest digit. */ 
    1603             pj_array_erase(stream->rx_dtmf_buf,  
     1601            pj_array_erase(stream->rx_dtmf_buf, 
    16041602                           sizeof(stream->rx_dtmf_buf[0]), 
    16051603                           stream->rx_dtmf_count, 0); 
     
    16141612/* 
    16151613 * This callback is called by stream transport on receipt of packets 
    1616  * in the RTP socket.  
    1617  */ 
    1618 static void on_rx_rtp( void *data,  
     1614 * in the RTP socket. 
     1615 */ 
     1616static void on_rx_rtp( void *data, 
    16191617                       void *pkt, 
    16201618                       pj_ssize_t bytes_read) 
     
    16321630    /* Check for errors */ 
    16331631    if (bytes_read < 0) { 
    1634         LOGERR_((stream->port.info.name.ptr, "RTP recv() error",  
     1632        LOGERR_((stream->port.info.name.ptr, "RTP recv() error", 
    16351633                (pj_status_t)-bytes_read)); 
    16361634        return; 
     
    16601658                                hdr->pt != stream->rx_event_pt); 
    16611659    if (seq_st.status.value) { 
    1662         TRC_  ((stream->port.info.name.ptr,  
     1660        TRC_  ((stream->port.info.name.ptr, 
    16631661                "RTP status: badpt=%d, badssrc=%d, dup=%d, " 
    1664                 "outorder=%d, probation=%d, restart=%d",  
     1662                "outorder=%d, probation=%d, restart=%d", 
    16651663                seq_st.status.flag.badpt, 
    16661664                seq_st.status.flag.badssrc, 
     
    17371735                                     payloadlen, &ts, &count, frames); 
    17381736        if (status != PJ_SUCCESS) { 
    1739             LOGERR_((stream->port.info.name.ptr,  
    1740                      "Codec parse() error",  
     1737            LOGERR_((stream->port.info.name.ptr, 
     1738                     "Codec parse() error", 
    17411739                     status)); 
    17421740            count = 0; 
     
    17461744        /* This code is used to learn the samples per frame value that is put 
    17471745         * by remote endpoint, for codecs with inconsistent clock rate such 
    1748          * as G.722 or MPEG audio. We need to learn the samples per frame  
     1746         * as G.722 or MPEG audio. We need to learn the samples per frame 
    17491747         * value as it is used as divider when inserting frames into the 
    17501748         * jitter buffer. 
     
    17521750        if (stream->has_g722_mpeg_bug) { 
    17531751            if (stream->rtp_rx_check_cnt) { 
    1754                 /* Make sure the detection performed only on two consecutive  
     1752                /* Make sure the detection performed only on two consecutive 
    17551753                 * packets with valid RTP sequence and no wrapped timestamp. 
    17561754                 */ 
    1757                 if (seq_st.diff == 1 && stream->rtp_rx_last_ts &&  
    1758                     ts.u64 > stream->rtp_rx_last_ts &&  
     1755                if (seq_st.diff == 1 && stream->rtp_rx_last_ts && 
     1756                    ts.u64 > stream->rtp_rx_last_ts && 
    17591757                    stream->rtp_rx_last_cnt > 0) 
    17601758                { 
     
    17681766 
    17691767                    /* Get remote frame timestamp span */ 
    1770                     peer_frm_ts_diff =  
    1771                         ((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) /  
     1768                    peer_frm_ts_diff = 
     1769                        ((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) / 
    17721770                        stream->rtp_rx_last_cnt; 
    17731771 
     
    17781776                     */ 
    17791777                    if (stream->codec_param.info.pt == PJMEDIA_RTP_PT_G722 && 
    1780                         (peer_frm_ts_diff == frm_ts_span ||  
     1778                        (peer_frm_ts_diff == frm_ts_span || 
    17811779                         peer_frm_ts_diff == (frm_ts_span>>1))) 
    17821780                    { 
     
    17901788                        if (--stream->rtp_rx_check_cnt == 0) { 
    17911789                            PJ_LOG(4, (THIS_FILE, "G722 codec used, remote" 
    1792                                        " samples per frame detected = %d",  
     1790                                       " samples per frame detected = %d", 
    17931791                                       stream->rtp_rx_ts_len_per_frame)); 
    1794                              
     1792 
    17951793                            /* Reset jitter buffer once detection done */ 
    17961794                            pjmedia_jbuf_reset(stream->jb); 
     
    18111809 
    18121810        } else { 
    1813             ts_span = stream->codec_param.info.frm_ptime *  
     1811            ts_span = stream->codec_param.info.frm_ptime * 
    18141812                      stream->codec_param.info.clock_rate / 
    18151813                      1000; 
    18161814        } 
    18171815#else 
    1818         ts_span = stream->codec_param.info.frm_ptime *  
     1816        ts_span = stream->codec_param.info.frm_ptime * 
    18191817                  stream->codec_param.info.clock_rate / 
    18201818                  1000; 
     
    18421840 
    18431841    /* Check if now is the time to transmit RTCP SR/RR report. 
    1844      * We only do this when stream direction is "decoding only",  
     1842     * We only do this when stream direction is "decoding only", 
    18451843     * because otherwise check_tx_rtcp() will be handled by put_frame() 
    18461844     */ 
     
    18501848 
    18511849    if (status != 0) { 
    1852         LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error",  
     1850        LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error", 
    18531851                status)); 
    18541852        pkt_discarded = PJ_TRUE; 
     
    18801878/* 
    18811879 * This callback is called by stream transport on receipt of packets 
    1882  * in the RTCP socket.  
     1880 * in the RTCP socket. 
    18831881 */ 
    18841882static void on_rx_rtcp( void *data, 
    1885                         void *pkt,  
     1883                        void *pkt, 
    18861884                        pj_ssize_t bytes_read) 
    18871885{ 
     
    18901888    /* Check for errors */ 
    18911889    if (bytes_read < 0) { 
    1892         LOGERR_((stream->port.info.name.ptr, "RTCP recv() error",  
     1890        LOGERR_((stream->port.info.name.ptr, "RTCP recv() error", 
    18931891                (pj_status_t)-bytes_read)); 
    18941892        return; 
     
    19111909    pjmedia_channel *channel; 
    19121910    pj_status_t status; 
    1913      
     1911 
    19141912    /* Allocate memory for channel descriptor */ 
    19151913 
     
    19241922    channel->pt = pt; 
    19251923 
    1926      
     1924 
    19271925    /* Allocate buffer for outgoing packet. */ 
    19281926 
    19291927    if (param->type == PJMEDIA_TYPE_AUDIO) { 
    1930         channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) +  
    1931                                 stream->codec_param.info.max_bps *  
    1932                                 PJMEDIA_MAX_FRAME_DURATION_MS /  
     1928        channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) + 
     1929                                stream->codec_param.info.max_bps * 
     1930                                PJMEDIA_MAX_FRAME_DURATION_MS / 
    19331931                                8 / 1000; 
    19341932        if (channel->out_pkt_size > PJMEDIA_MAX_MTU - 
     
    20782076        stream->codec_param = *info->param; 
    20792077    else { 
    2080         status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr,  
    2081                                                      &info->fmt,  
     2078        status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr, 
     2079                                                     &info->fmt, 
    20822080                                                     &stream->codec_param); 
    20832081        if (status != PJ_SUCCESS) 
     
    21372135    /* If encoder and decoder's ptime are asymmetric, then we need to 
    21382136     * create buffer on the encoder side. This could happen for example 
    2139      * with iLBC  
     2137     * with iLBC 
    21402138     */ 
    21412139    if (stream->codec_param.info.enc_ptime!=0 && 
     
    21852183        stream->frame_size = stream->codec_param.info.max_rx_frame_size; 
    21862184    } else { 
    2187         stream->frame_size = stream->codec_param.info.max_bps *  
     2185        stream->frame_size = stream->codec_param.info.max_bps * 
    21882186                             stream->codec_param.info.frm_ptime / 8 / 1000; 
    21892187        if ((stream->codec_param.info.max_bps * 
     
    22182216    /* Init jitter buffer parameters: */ 
    22192217    if (info->jb_max >= stream->codec_param.info.frm_ptime) 
    2220         jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) /  
     2218        jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) / 
    22212219                 stream->codec_param.info.frm_ptime; 
    22222220    else 
     
    22432241    /* Create jitter buffer */ 
    22442242    status = pjmedia_jbuf_create(pool, &stream->port.info.name, 
    2245                                  stream->frame_size,  
     2243                                 stream->frame_size, 
    22462244                                 stream->codec_param.info.frm_ptime, 
    22472245                                 jb_max, &stream->jb); 
     
    22552253    /* Create decoder channel: */ 
    22562254 
    2257     status = create_channel( pool, stream, PJMEDIA_DIR_DECODING,  
     2255    status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 
    22582256                             info->rx_pt, info, &stream->dec); 
    22592257    if (status != PJ_SUCCESS) 
     
    22632261    /* Create encoder channel: */ 
    22642262 
    2265     status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING,  
     2263    status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING, 
    22662264                             info->tx_pt, info, &stream->enc); 
    22672265    if (status != PJ_SUCCESS) 
     
    23162314 
    23172315    /* Only attach transport when stream is ready. */ 
    2318     status = pjmedia_transport_attach(tp, stream, &info->rem_addr,  
    2319                                       &info->rem_rtcp,  
    2320                                       pj_sockaddr_get_len(&info->rem_addr),  
     2316    status = pjmedia_transport_attach(tp, stream, &info->rem_addr, 
     2317                                      &info->rem_rtcp, 
     2318                                      pj_sockaddr_get_len(&info->rem_addr), 
    23212319                                      &on_rx_rtp, &on_rx_rtcp); 
    23222320    if (status != PJ_SUCCESS) 
     
    23362334            stream->rtcp_xr_interval = info->rtcp_xr_interval; 
    23372335        else 
    2338             stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL +  
    2339                                        (pj_rand() % 8000)) *  
     2336            stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL + 
     2337                                       (pj_rand() % 8000)) * 
    23402338                                       info->fmt.clock_rate / 1000; 
    23412339 
     
    23492347        /* jitter buffer adaptive info */ 
    23502348        i = PJMEDIA_RTCP_XR_JB_ADAPTIVE; 
    2351         pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     2349        pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    23522350                                    PJMEDIA_RTCP_XR_INFO_CONF_JBA, 
    23532351                                    i); 
     
    23552353        /* Jitter buffer aggressiveness info (estimated) */ 
    23562354        i = 7; 
    2357         pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     2355        pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    23582356                                    PJMEDIA_RTCP_XR_INFO_CONF_JBR, 
    23592357                                    i); 
     
    23612359        /* Jitter buffer absolute maximum delay */ 
    23622360        i = jb_max * stream->codec_param.info.frm_ptime; 
    2363         pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     2361        pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    23642362                                    PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX, 
    23652363                                    i); 
     
    23742372            i = PJMEDIA_RTCP_XR_PLC_DIS; 
    23752373#endif 
    2376         pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,  
     2374        pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
    23772375                                    PJMEDIA_RTCP_XR_INFO_CONF_PLC, 
    23782376                                    i); 
     
    23962394        pj_ssize_t len; 
    23972395 
    2398         pj_ansi_snprintf(trace_name, sizeof(trace_name),  
     2396        pj_ansi_snprintf(trace_name, sizeof(trace_name), 
    23992397                         TRACE_JB_PATH_PREFIX "%s.csv", 
    24002398                         stream->port.info.name.ptr); 
     
    24022400        if (status != PJ_SUCCESS) { 
    24032401            stream->trace_jb_fd = TRACE_JB_INVALID_FD; 
    2404             PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'",  
     2402            PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'", 
    24052403                      trace_name)); 
    24062404        } else { 
     
    24902488    } 
    24912489 
    2492     /* Detach from transport  
     2490    /* Detach from transport 
    24932491     * MUST NOT hold stream mutex while detaching from transport, as 
    24942492     * it may cause deadlock. See ticket #460 for the details. 
     
    25132511 
    25142512    /* Free mutex */ 
    2515      
     2513 
    25162514    if (stream->jb_mutex) { 
    25172515        pj_mutex_destroy(stream->jb_mutex); 
     
    27242722        return PJMEDIA_RTP_EREMNORFC2833; 
    27252723    } 
    2726      
     2724 
    27272725    pj_mutex_lock(stream->jb_mutex); 
    2728      
     2726 
    27292727    if (stream->tx_dtmf_count+digit_char->slen >= 
    27302728        (long)PJ_ARRAY_SIZE(stream->tx_dtmf_buf)) 
     
    27352733 
    27362734        /* convert ASCII digits into payload type first, to make sure 
    2737          * that all digits are valid.  
     2735         * that all digits are valid. 
    27382736         */ 
    27392737        for (i=0; i<digit_char->slen; ++i) { 
     
    27442742            { 
    27452743                pt = dig - '0'; 
    2746             }  
     2744            } 
    27472745            else if (dig >= 'a' && dig <= 'd') 
    27482746            { 
     
    28302828 */ 
    28312829PJ_DEF(pj_status_t) pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream, 
    2832                                  void (*cb)(pjmedia_stream*,  
    2833                                             void *user_data,  
    2834                                             int digit),  
     2830                                 void (*cb)(pjmedia_stream*, 
     2831                                            void *user_data, 
     2832                                            int digit), 
    28352833                                 void *user_data) 
    28362834{ 
Note: See TracChangeset for help on using the changeset viewer.