- Timestamp:
- Mar 31, 2011 5:29:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c
r3425 r3493 7 7 #define THIS_FILE "vid_codec.c" 8 8 9 #define BYPASS_CODEC 0 9 #define BYPASS_CODEC 0 10 #define BYPASS_PACKETIZER 0 10 11 11 12 typedef struct codec_port_data_t … … 15 16 pj_uint8_t *enc_buf; 16 17 pj_size_t enc_buf_size; 18 pj_uint8_t *pack_buf; 19 pj_size_t pack_buf_size; 17 20 } codec_port_data_t; 18 21 … … 33 36 status = codec->op->encode(codec, frame, enc_frame.size, &enc_frame); 34 37 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 35 78 status = codec->op->decode(codec, &enc_frame, frame->size, frame); 36 79 if (status != PJ_SUCCESS) goto on_error; … … 78 121 79 122 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", 81 124 info[i].encoding_name.slen, info[i].encoding_name.ptr, 82 125 (info[i].dir & PJMEDIA_DIR_ENCODING? 'E' : ' '), … … 123 166 } 124 167 168 125 169 /* Lookup colorbar source */ 126 170 status = pjmedia_vid_dev_lookup("Colorbar", "Colorbar generator", &cap_idx); … … 135 179 } 136 180 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. 137 186 /* Raw format ID "not specified", lets find common format among the codec 138 187 * and the video devices … … 166 215 } 167 216 } 217 #endif 168 218 169 219 /* Prepare codec */ … … 265 315 codec_port_data.enc_buf = pj_pool_alloc(pool, 266 316 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); 267 320 268 321 codec_port.put_frame = &codec_put_frame;
Note: See TracChangeset
for help on using the changeset viewer.