Changeset 1983 for pjproject/trunk/pjmedia/src/pjmedia/stream.c
- Timestamp:
- Jun 5, 2008 10:50:40 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r1961 r1983 230 230 char frame_type; 231 231 pj_size_t frame_size; 232 pj_uint32_t bit_info; 232 233 233 234 /* Get frame from jitter buffer. */ 234 235 pjmedia_jbuf_get_frame2(stream->jb, channel->out_pkt, &frame_size, 235 &frame_type );236 &frame_type, &bit_info); 236 237 237 238 if (frame_type == PJMEDIA_JB_MISSING_FRAME) { … … 365 366 frame_in.buf = channel->out_pkt; 366 367 frame_in.size = frame_size; 368 frame_in.bit_info = bit_info; 367 369 frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO; /* ignored */ 368 370 … … 678 680 frame->buf != NULL) 679 681 { 680 unsigned ts, codec_samples_per_frame; 681 682 /* Repeatedly call encode if there are multiple frames to be 683 * sent. 684 */ 685 codec_samples_per_frame = stream->codec_param.info.enc_ptime * 686 stream->codec_param.info.clock_rate / 687 1000; 688 if (codec_samples_per_frame == 0) { 689 codec_samples_per_frame = stream->codec_param.info.frm_ptime * 690 stream->codec_param.info.clock_rate / 691 1000; 692 } 693 694 for (ts=0; ts<ts_len; ts += codec_samples_per_frame) { 695 pjmedia_frame tmp_out_frame, tmp_in_frame; 696 unsigned bytes_per_sample, max_size; 697 698 /* Nb of bytes in PCM sample */ 699 bytes_per_sample = stream->codec_param.info.pcm_bits_per_sample/8; 700 701 /* Split original PCM input frame into base frame size */ 702 tmp_in_frame.timestamp.u64 = frame->timestamp.u64 + ts; 703 tmp_in_frame.buf = ((char*)frame->buf) + ts * bytes_per_sample; 704 tmp_in_frame.size = codec_samples_per_frame * bytes_per_sample; 705 tmp_in_frame.type = PJMEDIA_FRAME_TYPE_AUDIO; 706 707 /* Set output frame position */ 708 tmp_out_frame.buf = ((char*)frame_out.buf) + frame_out.size; 709 710 max_size = channel->out_pkt_size - sizeof(pjmedia_rtp_hdr) - 711 frame_out.size; 712 713 /* Encode! */ 714 status = stream->codec->op->encode( stream->codec, &tmp_in_frame, 715 max_size, &tmp_out_frame); 716 if (status != PJ_SUCCESS) { 717 LOGERR_((stream->port.info.name.ptr, 718 "Codec encode() error", status)); 719 return status; 720 } 721 722 /* tmp_out_frame.size may be zero for silence frame. */ 723 frame_out.size += tmp_out_frame.size; 724 725 /* Stop processing next PCM frame when encode() returns either 726 * CNG frame or NULL frame. 727 */ 728 if (tmp_out_frame.type!=PJMEDIA_FRAME_TYPE_AUDIO || 729 tmp_out_frame.size==0) 730 { 731 break; 732 } 733 682 /* Encode! */ 683 status = stream->codec->op->encode( stream->codec, frame, 684 channel->out_pkt_size - 685 sizeof(pjmedia_rtp_hdr), 686 &frame_out); 687 if (status != PJ_SUCCESS) { 688 LOGERR_((stream->port.info.name.ptr, 689 "Codec encode() error", status)); 690 return status; 734 691 } 735 692 … … 1218 1175 ext_seq = (unsigned)(frames[i].timestamp.u64 / ts_span); 1219 1176 pjmedia_jbuf_put_frame2(stream->jb, frames[i].buf, frames[i].size, 1220 ext_seq, &discarded);1177 frames[i].bit_info, ext_seq, &discarded); 1221 1178 if (discarded) 1222 1179 pkt_discarded = PJ_TRUE;
Note: See TracChangeset
for help on using the changeset viewer.