- Timestamp:
- Mar 31, 2011 5:29:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c
r3461 r3493 769 769 LOGERR_((channel->port.info.name.ptr, 770 770 "Codec encode() error", status)); 771 772 /* Update RTP timestamp */ 773 pjmedia_rtp_encode_rtp(&channel->rtp, channel->pt, 1, 0, 774 rtp_ts_len, &rtphdr, &rtphdrlen); 771 775 return status; 772 776 } … … 789 793 LOGERR_((channel->port.info.name.ptr, 790 794 "Codec pack() error", status)); 795 796 /* Update RTP timestamp */ 797 pjmedia_rtp_encode_rtp(&channel->rtp, channel->pt, 1, 0, 798 rtp_ts_len, &rtphdr, &rtphdrlen); 791 799 return status; 792 800 } … … 867 875 */ 868 876 { 869 pj_uint8_t *p, *data;870 char ptype;871 pj_size_t psize, data_len;872 pj_uint32_t ts;873 int seq;874 877 pj_bool_t got_frame; 875 unsigned i;878 unsigned cnt; 876 879 877 880 channel->buf_len = 0; … … 881 884 pj_mutex_lock( stream->jb_mutex ); 882 885 883 for (i=0; ; ++i) { 884 /* Get frame from jitter buffer. */ 885 pjmedia_jbuf_peek_frame(stream->jb, i, (const void**)&p, 886 &psize, &ptype, NULL, &ts, &seq); 886 /* Check if we got a decodable frame */ 887 for (cnt=0; ; ++cnt) { 888 char ptype; 889 pj_uint32_t ts; 890 int seq; 891 892 /* Peek frame from jitter buffer. */ 893 pjmedia_jbuf_peek_frame(stream->jb, cnt, NULL, NULL, 894 &ptype, NULL, &ts, &seq); 887 895 if (ptype == PJMEDIA_JB_NORMAL_FRAME) { 888 896 if (last_ts == 0) { … … 890 898 frm_first_seq = seq; 891 899 } 892 893 900 if (ts != last_ts) { 894 901 got_frame = PJ_TRUE; 895 pjmedia_jbuf_remove_frame(stream->jb, i);896 902 break; 897 903 } 898 899 data = (pj_uint8_t*)channel->buf + channel->buf_len;900 data_len = channel->buf_size - channel->buf_len;901 status = (*stream->codec->op->unpacketize)(stream->codec,902 p, psize,903 data, &data_len);904 channel->buf_len += data_len;905 904 frm_last_seq = seq; 906 905 } else if (ptype == PJMEDIA_JB_ZERO_EMPTY_FRAME) { … … 908 907 break; 909 908 } 909 } 910 911 if (got_frame) { 912 unsigned i; 913 914 /* Generate frame bitstream from the payload */ 915 channel->buf_len = 0; 916 for (i = 0; i < cnt; ++i) { 917 const pj_uint8_t *p; 918 pj_size_t psize; 919 char ptype; 920 921 /* We use jbuf_peek_frame() as it will returns the pointer of 922 * the payload (no buffer and memcpy needed), just as we need. 923 */ 924 pjmedia_jbuf_peek_frame(stream->jb, i, &p, 925 &psize, &ptype, NULL, NULL, NULL); 926 927 if (ptype != PJMEDIA_JB_NORMAL_FRAME) { 928 /* Packet lost, must set payload to NULL and keep going */ 929 p = NULL; 930 psize = 0; 931 } 932 933 status = (*stream->codec->op->unpacketize)( 934 stream->codec, 935 p, psize, 936 (pj_uint8_t*)channel->buf, 937 channel->buf_size, 938 &channel->buf_len); 939 if (status != PJ_SUCCESS) { 940 LOGERR_((channel->port.info.name.ptr, 941 "Codec unpack() error", status)); 942 /* Just ignore this unpack error */ 943 } 944 } 945 946 pjmedia_jbuf_remove_frame(stream->jb, cnt); 910 947 } 911 948
Note: See TracChangeset
for help on using the changeset viewer.