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/test/vid_codec_test.c

    r3425 r3493  
    77#define THIS_FILE "vid_codec.c" 
    88 
    9 #define BYPASS_CODEC 0 
     9#define BYPASS_CODEC        0 
     10#define BYPASS_PACKETIZER   0 
    1011 
    1112typedef struct codec_port_data_t 
     
    1516    pj_uint8_t          *enc_buf; 
    1617    pj_size_t            enc_buf_size; 
     18    pj_uint8_t          *pack_buf; 
     19    pj_size_t            pack_buf_size; 
    1720} codec_port_data_t; 
    1821 
     
    3336        status = codec->op->encode(codec, frame, enc_frame.size, &enc_frame); 
    3437        if (status != PJ_SUCCESS) goto on_error; 
     38 
     39#if !BYPASS_PACKETIZER 
     40        if (enc_frame.size) { 
     41            unsigned pos = 0, i = 0; 
     42            pj_bool_t packetized = PJ_FALSE; 
     43            unsigned unpack_pos = 0; 
     44             
     45            while (pos < enc_frame.size) { 
     46                pj_uint8_t *payload; 
     47                pj_size_t payload_len; 
     48 
     49                status = codec->op->packetize(codec,  
     50                                              (pj_uint8_t*)enc_frame.buf, 
     51                                              enc_frame.size, &pos, 
     52                                              &payload, &payload_len); 
     53                if (status == PJ_ENOTSUP) 
     54                    break; 
     55                if (status != PJ_SUCCESS) 
     56                    goto on_error; 
     57 
     58                status = codec->op->unpacketize(codec, payload, payload_len, 
     59                                                port_data->pack_buf, 
     60                                                port_data->pack_buf_size, 
     61                                                &unpack_pos); 
     62                if (status != PJ_SUCCESS) 
     63                    goto on_error; 
     64 
     65                // what happen if the bitstream is broken? 
     66                //if (i++ != 1) unpack_pos -= 10; 
     67 
     68                packetized = PJ_TRUE; 
     69            } 
     70 
     71            if (packetized) { 
     72                enc_frame.buf  = port_data->pack_buf; 
     73                enc_frame.size = unpack_pos; 
     74            } 
     75        } 
     76#endif 
     77 
    3578        status = codec->op->decode(codec, &enc_frame, frame->size, frame); 
    3679        if (status != PJ_SUCCESS) goto on_error; 
     
    78121 
    79122    for (i = 0; i < cnt; ++i) { 
    80         PJ_LOG(3, (THIS_FILE, "  %16.*s %c%c %s", 
     123        PJ_LOG(3, (THIS_FILE, "  %-16.*s %c%c %s", 
    81124                   info[i].encoding_name.slen, info[i].encoding_name.ptr, 
    82125                   (info[i].dir & PJMEDIA_DIR_ENCODING? 'E' : ' '), 
     
    123166    } 
    124167 
     168 
    125169    /* Lookup colorbar source */ 
    126170    status = pjmedia_vid_dev_lookup("Colorbar", "Colorbar generator", &cap_idx); 
     
    135179    } 
    136180 
     181    raw_fmt_id = codec_info->dec_fmt_id[0]; 
     182    cap_idx = 0; /* Use dshow capture */ 
     183 
     184#if 0 
     185    // Now, the video port can do automatic conversion. 
    137186    /* Raw format ID "not specified", lets find common format among the codec 
    138187     * and the video devices 
     
    166215        } 
    167216    } 
     217#endif 
    168218 
    169219    /* Prepare codec */ 
     
    265315    codec_port_data.enc_buf = pj_pool_alloc(pool,  
    266316                                            codec_port_data.enc_buf_size); 
     317    codec_port_data.pack_buf_size = codec_port_data.enc_buf_size; 
     318    codec_port_data.pack_buf = pj_pool_alloc(pool,  
     319                                             codec_port_data.pack_buf_size); 
    267320 
    268321    codec_port.put_frame = &codec_put_frame; 
Note: See TracChangeset for help on using the changeset viewer.