Ignore:
Timestamp:
Mar 31, 2011 5:29:54 PM (13 years ago)
Author:
nanang
Message:

Re #1219:

  • Initial version of H264 implementation (codec & packetization).
  • Added vid_codec_util.h/c for video codec utilities (e.g: fmtp parser).
  • Updated video RTP packetizations to be configurable and have internal state (to be more resilient to packet lost, etc).
  • Fixed wrong SPF calculation in PJMEDIA_SPF2.
  • Updated vid_codec_test.c to also have RTP packetization test.
  • Updated sdp_neg.c to verify H.264 capability match.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c

    r3461 r3493  
    769769        LOGERR_((channel->port.info.name.ptr,  
    770770                "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); 
    771775        return status; 
    772776    } 
     
    789793            LOGERR_((channel->port.info.name.ptr,  
    790794                    "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); 
    791799            return status; 
    792800        } 
     
    867875     */ 
    868876    { 
    869         pj_uint8_t *p, *data; 
    870         char ptype; 
    871         pj_size_t psize, data_len; 
    872         pj_uint32_t ts; 
    873         int seq; 
    874877        pj_bool_t got_frame; 
    875         unsigned i; 
     878        unsigned cnt; 
    876879 
    877880        channel->buf_len = 0; 
     
    881884        pj_mutex_lock( stream->jb_mutex ); 
    882885 
    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); 
    887895            if (ptype == PJMEDIA_JB_NORMAL_FRAME) { 
    888896                if (last_ts == 0) { 
     
    890898                    frm_first_seq = seq; 
    891899                } 
    892  
    893900                if (ts != last_ts) { 
    894901                    got_frame = PJ_TRUE; 
    895                     pjmedia_jbuf_remove_frame(stream->jb, i); 
    896902                    break; 
    897903                } 
    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; 
    905904                frm_last_seq = seq; 
    906905            } else if (ptype == PJMEDIA_JB_ZERO_EMPTY_FRAME) { 
     
    908907                break; 
    909908            } 
     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); 
    910947        } 
    911948 
Note: See TracChangeset for help on using the changeset viewer.