- Timestamp:
- Feb 10, 2006 3:57:08 PM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 35 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/pjmedia.dsw
r129 r176 61 61 ############################################################################### 62 62 63 Project: "pjmedia_codec"=.\pjmedia_codec.dsp - Package Owner=<4> 64 65 Package=<5> 66 {{{ 67 }}} 68 69 Package=<4> 70 {{{ 71 }}} 72 73 ############################################################################### 74 63 75 Project: "pjmedia_test"=.\pjmedia_test.dsp - Package Owner=<4> 64 76 -
pjproject/trunk/pjmedia/include/pjmedia/codec.h
r171 r176 183 183 184 184 185 /** 186 * Instruct the codec to inspect the specified payload/packet and 187 * split the packet info individual frames. 188 * 189 * @param codec The codec instance 190 * @param pkt The input packet. 191 * @param pkt_size Size of the packet. 192 * @param frame_cnt On input, specifies the maximum number of frames 193 * in the array. On output, the codec must fill 194 * with number of frames detected in the packet. 195 * @param frames On output, specifies the frames that have been 196 * detected in the packet. 197 * 198 * @return PJ_SUCCESS on success. 199 */ 200 pj_status_t (*get_frames)(pjmedia_codec *codec, 201 void *pkt, 202 pj_size_t pkt_size, 203 unsigned *frame_cnt, 204 pjmedia_frame frames[]); 205 185 206 /** 186 207 * Instruct the codec to encode the specified input frame. … … 400 421 401 422 /** 423 * Get default codec param for the specified codec info. 424 * 425 * @param mgr The codec manager. 426 * @param info The codec info, which default parameter's is being 427 * queried. 428 * @param param On return, will be filled with the default codec 429 * parameter. 430 * 431 * @return PJ_SUCCESS on success. 432 */ 433 PJ_DECL(pj_status_t) pjmedia_codec_mgr_get_default_param(pjmedia_codec_mgr *mgr, 434 const pjmedia_codec_info *info, 435 pjmedia_codec_param *param ); 436 437 /** 402 438 * Request the codec manager to allocate one instance of codec with the 403 439 * specified codec info. The codec will enumerate all codec factories -
pjproject/trunk/pjmedia/include/pjmedia/endpoint.h
r159 r176 119 119 120 120 121 /** 122 * Dump media endpoint capabilities. 123 * 124 * @param endpt The media endpoint. 125 * 126 * @return PJ_SUCCESS on success. 127 */ 128 PJ_DECL(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt); 129 121 130 122 131 PJ_END_DECL -
pjproject/trunk/pjmedia/include/pjmedia/errno.h
r169 r176 249 249 */ 250 250 #define PJMEDIA_CODEC_EUNSUP (PJMEDIA_ERRNO_START+80) /* 220080 */ 251 /** 252 * @hideinitializer 253 * Unable to create codec. 254 */ 255 #define PJMEDIA_CODEC_EFAILED (PJMEDIA_ERRNO_START+81) /* 220081 */ 256 /** 257 * @hideinitializer 258 * Codec frame is too short. 259 */ 260 #define PJMEDIA_CODEC_EFRMTOOSHORT (PJMEDIA_ERRNO_START+82) /* 220082 */ 261 /** 262 * @hideinitializer 263 * PCM buffer is too short. 264 */ 265 #define PJMEDIA_CODEC_EPCMTOOSHORT (PJMEDIA_ERRNO_START+83) /* 220083 */ 251 266 252 267 … … 274 289 */ 275 290 #define PJMEDIA_EMISSINGRTPMAP (PJMEDIA_ERRNO_START+103) /* 220103 */ 291 /** 292 * @hideinitializer 293 * Invalid media type. 294 */ 295 #define PJMEDIA_EINVALIMEDIATYPE (PJMEDIA_ERRNO_START+104) /* 220104 */ 276 296 277 297 -
pjproject/trunk/pjmedia/src/pjmedia/codec.c
r159 r176 149 149 } 150 150 151 152 /* 153 * Get default codec parameter. 154 */ 155 PJ_DEF(pj_status_t) pjmedia_codec_mgr_get_default_param( pjmedia_codec_mgr *mgr, 156 const pjmedia_codec_info *info, 157 pjmedia_codec_param *param ) 158 { 159 pjmedia_codec_factory *factory; 160 pj_status_t status; 161 162 PJ_ASSERT_RETURN(mgr && info && param, PJ_EINVAL); 163 164 factory = mgr->factory_list.next; 165 while (factory != &mgr->factory_list) { 166 167 if ( (*factory->op->test_alloc)(factory, info) == PJ_SUCCESS ) { 168 169 status = (*factory->op->default_attr)(factory, info, param); 170 if (status == PJ_SUCCESS) 171 return PJ_SUCCESS; 172 173 } 174 175 factory = factory->next; 176 } 177 178 179 return PJMEDIA_CODEC_EUNSUP; 180 } 181 182 151 183 /* 152 184 * Dealloc codec. -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r162 r176 25 25 #include <pj/assert.h> 26 26 #include <pj/os.h> 27 #include <pj/log.h> 27 28 28 29 … … 270 271 } 271 272 273 274 PJ_DEF(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt) 275 { 276 277 #if PJ_LOG_MAX_LEVEL >= 3 278 unsigned i, count; 279 pjmedia_codec_info codec_info[32]; 280 281 PJ_LOG(3,(THIS_FILE, "Dumping PJMEDIA capabilities:")); 282 283 count = PJ_ARRAY_SIZE(codec_info); 284 if (pjmedia_codec_mgr_enum_codecs(&endpt->codec_mgr, 285 &count, codec_info) != PJ_SUCCESS) 286 { 287 PJ_LOG(3,(THIS_FILE, " -error: failed to enum codecs")); 288 return PJ_SUCCESS; 289 } 290 291 PJ_LOG(3,(THIS_FILE, " Total number of installed codecs: %d", count)); 292 for (i=0; i<count; ++i) { 293 const char *type; 294 pjmedia_codec_param param; 295 296 switch (codec_info[i].type) { 297 case PJMEDIA_TYPE_AUDIO: 298 type = "Audio"; break; 299 case PJMEDIA_TYPE_VIDEO: 300 type = "Video"; break; 301 default: 302 type = "Unknown type"; break; 303 } 304 305 if (pjmedia_codec_mgr_get_default_param(&endpt->codec_mgr, 306 &codec_info[i], 307 ¶m) != PJ_SUCCESS) 308 { 309 pj_memset(¶m, 0, sizeof(pjmedia_codec_param)); 310 } 311 312 PJ_LOG(3,(THIS_FILE, 313 " %s codec #%2d: pt=%d (%.*s, %d bps, ptime=%d ms, vad=%d, cng=%d)", 314 type, i, codec_info[i].pt, 315 (int)codec_info[i].encoding_name.slen, 316 codec_info[i].encoding_name.ptr, 317 param.avg_bps, param.ptime, 318 param.vad_enabled, 319 param.cng_enabled)); 320 } 321 #endif 322 323 return PJ_SUCCESS; 324 } -
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r159 r176 41 41 42 42 /* Prototypes for G711 factory */ 43 static pj_status_t g711_match_id( pjmedia_codec_factory *factory, const pjmedia_codec_info *id ); 44 static pj_status_t g711_default_attr( pjmedia_codec_factory *factory, const pjmedia_codec_info *id, pjmedia_codec_param *attr ); 45 static pj_status_t g711_enum_codecs (pjmedia_codec_factory *factory, unsigned *count, pjmedia_codec_info codecs[]); 46 static pj_status_t g711_alloc_codec( pjmedia_codec_factory *factory, const pjmedia_codec_info *id, pjmedia_codec **p_codec); 47 static pj_status_t g711_dealloc_codec( pjmedia_codec_factory *factory, pjmedia_codec *codec ); 43 static pj_status_t g711_test_alloc( pjmedia_codec_factory *factory, 44 const pjmedia_codec_info *id ); 45 static pj_status_t g711_default_attr( pjmedia_codec_factory *factory, 46 const pjmedia_codec_info *id, 47 pjmedia_codec_param *attr ); 48 static pj_status_t g711_enum_codecs (pjmedia_codec_factory *factory, 49 unsigned *count, 50 pjmedia_codec_info codecs[]); 51 static pj_status_t g711_alloc_codec( pjmedia_codec_factory *factory, 52 const pjmedia_codec_info *id, 53 pjmedia_codec **p_codec); 54 static pj_status_t g711_dealloc_codec( pjmedia_codec_factory *factory, 55 pjmedia_codec *codec ); 48 56 49 57 /* Prototypes for G711 implementation. */ 50 static pj_status_t g711_codec_default_attr (pjmedia_codec *codec, pjmedia_codec_param *attr); 51 static pj_status_t g711_init( pjmedia_codec *codec, pj_pool_t *pool ); 52 static pj_status_t g711_open( pjmedia_codec *codec, pjmedia_codec_param *attr ); 58 static pj_status_t g711_codec_default_attr (pjmedia_codec *codec, 59 pjmedia_codec_param *attr); 60 static pj_status_t g711_init( pjmedia_codec *codec, 61 pj_pool_t *pool ); 62 static pj_status_t g711_open( pjmedia_codec *codec, 63 pjmedia_codec_param *attr ); 53 64 static pj_status_t g711_close( pjmedia_codec *codec ); 54 static pj_status_t g711_encode( pjmedia_codec *codec, const struct pjmedia_frame *input, 55 unsigned output_buf_len, struct pjmedia_frame *output); 56 static pj_status_t g711_decode( pjmedia_codec *codec, const struct pjmedia_frame *input, 57 unsigned output_buf_len, struct pjmedia_frame *output); 65 static pj_status_t g711_get_frames(pjmedia_codec *codec, 66 void *pkt, 67 pj_size_t pkt_size, 68 unsigned *frame_cnt, 69 pjmedia_frame frames[]); 70 static pj_status_t g711_encode( pjmedia_codec *codec, 71 const struct pjmedia_frame *input, 72 unsigned output_buf_len, 73 struct pjmedia_frame *output); 74 static pj_status_t g711_decode( pjmedia_codec *codec, 75 const struct pjmedia_frame *input, 76 unsigned output_buf_len, 77 struct pjmedia_frame *output); 58 78 59 79 /* Definition for G711 codec operations. */ … … 64 84 &g711_open, 65 85 &g711_close, 86 &g711_get_frames, 66 87 &g711_encode, 67 88 &g711_decode … … 71 92 static pjmedia_codec_factory_op g711_factory_op = 72 93 { 73 &g711_ match_id,94 &g711_test_alloc, 74 95 &g711_default_attr, 75 96 &g711_enum_codecs, … … 129 150 } 130 151 131 static pj_status_t g711_ match_id( pjmedia_codec_factory *factory, const pjmedia_codec_info *id )152 static pj_status_t g711_test_alloc( pjmedia_codec_factory *factory, const pjmedia_codec_info *id ) 132 153 { 133 154 PJ_UNUSED_ARG(factory); … … 143 164 PJ_UNUSED_ARG(factory); 144 165 145 memset(attr, 0, sizeof(pjmedia_codec_param));166 pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 146 167 attr->sample_rate = 8000; 147 168 attr->avg_bps = G711_BPS; … … 156 177 157 178 static pj_status_t g711_enum_codecs(pjmedia_codec_factory *factory, 158 unsigned * count,179 unsigned *max_count, 159 180 pjmedia_codec_info codecs[]) 160 181 { 182 unsigned count = 0; 183 161 184 PJ_UNUSED_ARG(factory); 162 185 163 if (*count > 0) { 164 codecs[0].type = PJMEDIA_TYPE_AUDIO; 165 codecs[0].pt = PJMEDIA_RTP_PT_PCMU; 166 codecs[0].encoding_name = pj_str("PCMU"); 167 codecs[0].sample_rate = 8000; 186 if (count < *max_count) { 187 codecs[count].type = PJMEDIA_TYPE_AUDIO; 188 codecs[count].pt = PJMEDIA_RTP_PT_PCMU; 189 codecs[count].encoding_name = pj_str("PCMU"); 190 codecs[count].sample_rate = 8000; 191 ++count; 168 192 } 169 if ( *count > 1) {193 if (count < *max_count) { 170 194 codecs[1].type = PJMEDIA_TYPE_AUDIO; 171 195 codecs[1].pt = PJMEDIA_RTP_PT_PCMA; 172 196 codecs[1].encoding_name = pj_str("PCMA"); 173 197 codecs[1].sample_rate = 8000; 198 ++count; 174 199 } 175 200 176 if (*count > 0) *count=1; 177 if (*count > 1) *count=2; 201 *max_count = count; 178 202 179 203 return PJ_SUCCESS; … … 258 282 PJ_UNUSED_ARG(codec); 259 283 /* Nothing to do */ 284 return PJ_SUCCESS; 285 } 286 287 static pj_status_t g711_get_frames(pjmedia_codec *codec, 288 void *pkt, 289 pj_size_t pkt_size, 290 unsigned *frame_cnt, 291 pjmedia_frame frames[]) 292 { 293 unsigned count = 0; 294 295 PJ_UNUSED_ARG(codec); 296 PJ_ASSERT_RETURN(frame_cnt, PJ_EINVAL); 297 298 while (pkt_size >= 160 && count < *frame_cnt) { 299 frames[0].type = PJMEDIA_FRAME_TYPE_AUDIO; 300 frames[0].buf = pkt; 301 frames[0].size = 160; 302 303 pkt = ((char*)pkt) + 160; 304 pkt_size -= 160; 305 306 ++count; 307 } 308 309 *frame_cnt = count; 260 310 return PJ_SUCCESS; 261 311 }
Note: See TracChangeset
for help on using the changeset viewer.