Changeset 440


Ignore:
Timestamp:
May 14, 2006 10:54:44 AM (18 years ago)
Author:
bennylp
Message:

Fixed bug with multiple frames handling in RTP stream

File:
1 edited

Legend:

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

    r438 r440  
    428428 
    429429        for (ts=0; ts<ts_len; ts += samples_per_frame) { 
    430             pjmedia_frame tmp_frame; 
    431             unsigned max_size; 
    432  
    433             tmp_frame.buf = ((char*)frame_out.buf) + frame_out.size; 
     430            pjmedia_frame tmp_out_frame, tmp_in_frame; 
     431            unsigned bytes_per_sample, max_size; 
     432 
     433            bytes_per_sample = stream->codec_param.info.pcm_bits_per_sample/8; 
     434 
     435            tmp_in_frame.buf = ((char*)frame->buf) + ts * bytes_per_sample; 
     436            tmp_in_frame.size = samples_per_frame * bytes_per_sample; 
     437            tmp_in_frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 
     438 
     439            tmp_out_frame.buf = ((char*)frame_out.buf) + frame_out.size; 
    434440 
    435441            max_size = channel->out_pkt_size - sizeof(pjmedia_rtp_hdr) - 
    436442                       frame_out.size; 
    437443 
    438             status = stream->codec->op->encode( stream->codec, frame,  
    439                                                 max_size,  
    440                                                 &tmp_frame); 
     444            status = stream->codec->op->encode( stream->codec, &tmp_in_frame,  
     445                                                max_size, &tmp_out_frame); 
    441446            if (status != PJ_SUCCESS) { 
    442447                LOGERR_((stream->port.info.name.ptr,  
     
    445450            } 
    446451 
    447             frame_out.size += tmp_frame.size; 
     452            frame_out.size += tmp_out_frame.size; 
    448453        } 
    449454 
     
    712717            enum { MAX = 16 }; 
    713718            pj_timestamp ts; 
    714             unsigned i, count; 
     719            unsigned i, count = MAX; 
     720            unsigned samples_per_frame; 
    715721            pjmedia_frame frames[MAX]; 
    716722 
     
    733739 
    734740            /* Put each frame to jitter buffer. */ 
     741            samples_per_frame = stream->codec_param.info.frm_ptime *  
     742                                stream->codec_param.info.clock_rate * 
     743                                stream->codec_param.info.channel_cnt / 
     744                                1000; 
     745                                 
    735746            for (i=0; i<count; ++i) { 
    736747                unsigned ext_seq; 
    737748 
    738749                ext_seq = (unsigned)(frames[i].timestamp.u64 / 
    739                                      stream->port.info.samples_per_frame); 
     750                                     samples_per_frame); 
    740751                pjmedia_jbuf_put_frame(stream->jb, frames[i].buf,  
    741752                                       frames[i].size, ext_seq); 
Note: See TracChangeset for help on using the changeset viewer.