Changeset 411 for pjproject/trunk/pjmedia/include/pjmedia/codec.h
- Timestamp:
- Apr 27, 2006 10:36:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/codec.h
r276 r411 49 49 /** 50 50 * Standard RTP static payload types, as defined by RFC 3551. 51 * The header file <pjmedia-codec/types.h> also declares dynamic payload 52 * types that are supported by pjmedia-codec library. 51 53 */ 52 54 enum pjmedia_rtp_pt … … 92 94 unsigned pt; /**< Payload type (can be dynamic). */ 93 95 pj_str_t encoding_name; /**< Encoding name. */ 94 unsigned sample_rate; /**< Sampling rate. */ 95 }; 96 unsigned clock_rate; /**< Sampling rate. */ 97 unsigned channel_cnt; /**< Channel count. */ 98 }; 99 100 101 /** 102 * @see pjmedia_codec_info 103 */ 104 typedef struct pjmedia_codec_info pjmedia_codec_info; 96 105 97 106 … … 102 111 struct pjmedia_codec_param 103 112 { 104 pj_uint32_t sample_rate; /**< Sampling rate in Hz */ 113 unsigned clock_rate; /**< Sampling rate in Hz */ 114 unsigned channel_cnt; /**< Channel count. */ 105 115 pj_uint32_t avg_bps; /**< Average bandwidth in bits/sec */ 106 116 117 pj_uint16_t ptime; /**< Packet time in miliseconds */ 107 118 pj_uint8_t pcm_bits_per_sample;/**< Bits/sample in the PCM side */ 108 pj_uint16_t ptime; /**< Packet time in miliseconds */109 119 110 120 unsigned pt:8; /**< Payload type. */ 111 unsigned vad_enabled:1; /**< Voice Activity Detector. */ 112 unsigned cng_enabled:1; /**< Comfort Noise Generator. */ 113 unsigned lpf_enabled:1; /**< Low pass filter */ 114 unsigned hpf_enabled:1; /**< High pass filter */ 115 unsigned penh_enabled:1; /**< Perceptual Enhancement */ 116 unsigned concl_enabled:1; /**< Packet loss concealment */ 117 unsigned reserved_bit:1; /**< Reserved, must be NULL. */ 118 119 }; 121 unsigned vad:1; /**< Voice Activity Detector. */ 122 unsigned cng:1; /**< Comfort Noise Generator. */ 123 unsigned lpf:1; /**< Low pass filter */ 124 unsigned hpf:1; /**< High pass filter */ 125 unsigned penh:1; /**< Perceptual Enhancement */ 126 unsigned concl:1; /**< Packet loss concealment */ 127 unsigned reserved:1; /**< Reserved, must be NULL. */ 128 129 }; 130 131 /** 132 * @see pjmedia_codec_param 133 */ 134 typedef struct pjmedia_codec_param pjmedia_codec_param; 135 136 137 /** 138 * @see pjmedia_codec 139 */ 140 typedef struct pjmedia_codec pjmedia_codec; 120 141 121 142 … … 126 147 struct pjmedia_codec_op 127 148 { 128 /**129 * Get default attributes for this codec.130 *131 * @param codec The codec instance.132 * @param attr Pointer to receive default codec attributes.133 *134 * @return PJ_SUCCESS on success.135 */136 pj_status_t (*default_attr)(pjmedia_codec *codec,137 pjmedia_codec_param *attr);138 139 149 /** 140 150 * Initialize codec using the specified attribute. … … 226 236 227 237 /** 238 * Codec operation. 239 */ 240 typedef struct pjmedia_codec_op pjmedia_codec_op; 241 242 243 /** 244 * @see pjmedia_codec_factory 245 */ 246 typedef struct pjmedia_codec_factory pjmedia_codec_factory; 247 248 249 /** 228 250 * This structure describes a codec instance. 229 251 */ … … 234 256 235 257 /** Codec's private data. */ 236 void *codec_data;258 void *codec_data; 237 259 238 260 /** Codec factory where this codec was allocated. */ 239 pjmedia_codec_factory *factory;261 pjmedia_codec_factory *factory; 240 262 241 263 /** Operations to codec. */ 242 pjmedia_codec_op *op; 243 }; 264 pjmedia_codec_op *op; 265 }; 266 244 267 245 268 … … 274 297 */ 275 298 pj_status_t (*default_attr)(pjmedia_codec_factory *factory, 276 const pjmedia_codec_info *info,277 pjmedia_codec_param *attr );299 const pjmedia_codec_info *info, 300 pjmedia_codec_param *attr ); 278 301 279 302 /** … … 323 346 324 347 /** 348 * @see pjmedia_codec_factory_op 349 */ 350 typedef struct pjmedia_codec_factory_op pjmedia_codec_factory_op; 351 352 353 /** 325 354 * Codec factory describes a module that is able to create codec with specific 326 355 * capabilities. These capabilities can be queried by codec manager to create … … 340 369 }; 341 370 371 342 372 /** 343 373 * Declare maximum codecs … … 345 375 #define PJMEDIA_CODEC_MGR_MAX_CODECS 32 346 376 347 /** 348 * Codec manager maintains codec factory etc. 377 378 /** 379 * Specify these values to set the codec priority, by calling 380 * #pjmedia_codec_mgr_set_codec_priority(). 381 */ 382 enum pjmedia_codec_priority 383 { 384 /** 385 * This priority makes the codec the highest in the order. 386 * The last codec specified with this priority will get the 387 * highest place in the order, and will change the priority 388 * of previously highest priority codec to NEXT_HIGHER. 389 */ 390 PJMEDIA_CODEC_PRIO_HIGHEST, 391 392 /** 393 * This priority will put the codec as the next codec after 394 * codecs with this same priority. 395 */ 396 PJMEDIA_CODEC_PRIO_NEXT_HIGHER, 397 398 /** 399 * This is the initial codec priority when it is registered to 400 * codec manager by codec factory. 401 */ 402 PJMEDIA_CODEC_PRIO_NORMAL, 403 404 /** 405 * This priority makes the codec the lowest in the order. 406 * The last codec specified with this priority will be put 407 * in the last place in the order. 408 */ 409 PJMEDIA_CODEC_PRIO_LOWEST, 410 411 /** 412 * This priority will prevent the codec from being listed in the 413 * SDP created by media endpoint, thus should prevent the codec 414 * from being used in the sessions. However, the codec will still 415 * be listed by #pjmedia_codec_mgr_enum_codecs() and other codec 416 * query functions. 417 */ 418 PJMEDIA_CODEC_PRIO_DISABLED, 419 }; 420 421 422 /** 423 * @see pjmedia_codec_priority 424 */ 425 typedef enum pjmedia_codec_priority pjmedia_codec_priority; 426 427 428 /** Fully qualified codec name (e.g. "pcmu/8000/1") */ 429 typedef char pjmedia_codec_id[32]; 430 431 432 /** 433 * Codec manager maintains array of these structs for each supported 434 * codec. 435 */ 436 struct pjmedia_codec_desc 437 { 438 pjmedia_codec_info info; /**< Codec info. */ 439 pjmedia_codec_id id; /**< Fully qualified name */ 440 pjmedia_codec_priority prio; /**< Priority. */ 441 pjmedia_codec_factory *factory; /**< The factory. */ 442 }; 443 444 445 /** 446 * The declaration for codec manager. Application doesn't normally need 447 * to see this declaration, but nevertheless this declaration is needed 448 * by media endpoint to instantiate the codec manager. 349 449 */ 350 450 struct pjmedia_codec_mgr 351 451 { 352 452 /** List of codec factories registered to codec manager. */ 353 pjmedia_codec_factory 453 pjmedia_codec_factory factory_list; 354 454 355 455 /** Number of supported codesc. */ 356 unsigned codec_cnt; 357 358 /** Array of codec info. */ 359 pjmedia_codec_info codecs[PJMEDIA_CODEC_MGR_MAX_CODECS]; 360 }; 361 362 363 364 /** 365 * Initialize codec manager. 456 unsigned codec_cnt; 457 458 /** Array of codec descriptor. */ 459 struct pjmedia_codec_desc codec_desc[PJMEDIA_CODEC_MGR_MAX_CODECS]; 460 }; 461 462 463 /** 464 * @see pjmedia_codec_mgr 465 */ 466 typedef struct pjmedia_codec_mgr pjmedia_codec_mgr; 467 468 469 470 /** 471 * Initialize codec manager. Normally this function is called by pjmedia 472 * endpoint's initialization code. 366 473 * 367 474 * @param mgr Codec manager instance. … … 373 480 374 481 /** 375 * Register codec factory to codec manager. 376 * 377 * @param mgr The codec manager. 482 * Register codec factory to codec manager. This will also register 483 * all supported codecs in the factory to the codec manager. 484 * 485 * @param mgr The codec manager instance. Application can get the 486 * instance by calling #pjmedia_endpt_get_codec_mgr(). 378 487 * @param factory The codec factory to be registered. 379 488 * … … 385 494 386 495 /** 387 * Unregister codec factory from the codec manager. 388 * 389 * @param mgr The codec manager. 496 * Unregister codec factory from the codec manager. This will also 497 * remove all the codecs registered by the codec factory from the 498 * codec manager's list of supported codecs. 499 * 500 * @param mgr The codec manager instance. Application can get the 501 * instance by calling #pjmedia_endpt_get_codec_mgr(). 390 502 * @param factory The codec factory to be unregistered. 391 503 * … … 397 509 398 510 /** 399 * Enumerate all supported codec. 400 * 401 * @param mgr The codec manager. 511 * Enumerate all supported codecs that have been registered to the 512 * codec manager by codec factories. 513 * 514 * @param mgr The codec manager instance. Application can get the 515 * instance by calling #pjmedia_endpt_get_codec_mgr(). 402 516 * @param count On input, specifies the number of elements in 403 517 * the array. On output, the value will be set to … … 406 520 * @param info The codec info array, which contents will be 407 521 * initialized upon return. 522 * @param prio Optional pointer to receive array of codec priorities. 408 523 * 409 524 * @return PJ_SUCCESS on success. … … 411 526 PJ_DECL(pj_status_t) pjmedia_codec_mgr_enum_codecs( pjmedia_codec_mgr *mgr, 412 527 unsigned *count, 413 pjmedia_codec_info info[]); 414 415 /** 416 * Get codec info for the specified static payload type. 417 * 418 * @param mgr The codec manager. 528 pjmedia_codec_info info[], 529 unsigned *prio); 530 531 /** 532 * Get codec info for the specified static payload type. Note that 533 * this can only find codec with static payload types. This function can 534 * be used to find codec info for a payload type inside SDP which doesn't 535 * have the corresponding rtpmap attribute. 536 * 537 * @param mgr The codec manager instance. Application can get the 538 * instance by calling #pjmedia_endpt_get_codec_mgr(). 419 539 * @param pt Static payload type/number. 420 540 * @param inf Pointer to receive codec info. … … 422 542 * @return PJ_SUCCESS on success. 423 543 */ 424 PJ_DECL(pj_status_t) pjmedia_codec_mgr_get_codec_info(pjmedia_codec_mgr *mgr, 425 unsigned pt, 426 pjmedia_codec_info *inf); 544 PJ_DECL(pj_status_t) 545 pjmedia_codec_mgr_get_codec_info( pjmedia_codec_mgr *mgr, 546 unsigned pt, 547 const pjmedia_codec_info **inf); 548 549 /** 550 * Convert codec info struct into a unique codec identifier. 551 * A codec identifier looks something like "L16/44100/2". 552 * 553 * @param info The codec info 554 * @param id Buffer to put the codec info string. 555 * @param max_len The length of the buffer. 556 * 557 * @return The null terminated codec info string, or NULL if 558 * the buffer is not long enough. 559 */ 560 PJ_DECL(char*) pjmedia_codec_info_to_id(const pjmedia_codec_info *info, 561 char *id, unsigned max_len ); 562 563 564 /** 565 * Find codecs by the unique codec identifier. This function will find 566 * all codecs that match the codec identifier prefix. For example, if 567 * "L16" is specified, then it will find "L16/8000/1", "L16/16000/1", 568 * and so on, up to the maximum count specified in the argument. 569 * 570 * @param mgr The codec manager instance. Application can get the 571 * instance by calling #pjmedia_endpt_get_codec_mgr(). 572 * @param codec_id The full codec ID or codec ID prefix. If an empty 573 * string is given, it will match all codecs. 574 * @param count Maximum number of codecs to find. On return, it 575 * contains the actual number of codecs found. 576 * @param p_info Array of pointer to codec info to be filled. This 577 * argument may be NULL, which in this case, only 578 * codec count will be returned. 579 * @param prio Optional array of codec priorities. 580 * 581 * @return PJ_SUCCESS if at least one codec info is found. 582 */ 583 PJ_DECL(pj_status_t) 584 pjmedia_codec_mgr_find_codecs_by_id( pjmedia_codec_mgr *mgr, 585 const pj_str_t *codec_id, 586 unsigned *count, 587 const pjmedia_codec_info *p_info[], 588 unsigned prio[]); 589 590 591 /** 592 * Set codec priority. The codec priority determines the order of 593 * the codec in the SDP created by the endpoint. If more than one codecs 594 * are found with the same codec_id prefix, then the function sets the 595 * priorities of all those codecs. 596 * 597 * @param mgr The codec manager instance. Application can get the 598 * instance by calling #pjmedia_endpt_get_codec_mgr(). 599 * @param codec_id The full codec ID or codec ID prefix. If an empty 600 * string is given, it will match all codecs. 601 * @param prio Priority to be set. 602 * 603 * @return PJ_SUCCESS if at least one codec info is found. 604 */ 605 PJ_DECL(pj_status_t) 606 pjmedia_codec_mgr_set_codec_priority(pjmedia_codec_mgr *mgr, 607 const pj_str_t *codec_id, 608 pjmedia_codec_priority prio); 609 427 610 428 611 /** 429 612 * Get default codec param for the specified codec info. 430 613 * 431 * @param mgr The codec manager. 614 * @param mgr The codec manager instance. Application can get the 615 * instance by calling #pjmedia_endpt_get_codec_mgr(). 432 616 * @param info The codec info, which default parameter's is being 433 617 * queried. … … 437 621 * @return PJ_SUCCESS on success. 438 622 */ 439 PJ_DECL(pj_status_t) pjmedia_codec_mgr_get_default_param(pjmedia_codec_mgr *mgr, 440 const pjmedia_codec_info *info, 441 pjmedia_codec_param *param ); 623 PJ_DECL(pj_status_t) 624 pjmedia_codec_mgr_get_default_param( pjmedia_codec_mgr *mgr, 625 const pjmedia_codec_info *info, 626 pjmedia_codec_param *param ); 442 627 443 628 /** … … 446 631 * until it finds factory that is able to create the specified codec. 447 632 * 448 * @param mgr The codec manager. 633 * @param mgr The codec manager instance. Application can get the 634 * instance by calling #pjmedia_endpt_get_codec_mgr(). 449 635 * @param info The information about the codec to be created. 450 636 * @param p_codec Pointer to receive the codec instance. … … 452 638 * @return PJ_SUCCESS on success. 453 639 */ 454 PJ_DECL(pj_status_t) pjmedia_codec_mgr_alloc_codec(pjmedia_codec_mgr *mgr, 455 const pjmedia_codec_info *info, 456 pjmedia_codec **p_codec); 640 PJ_DECL(pj_status_t) 641 pjmedia_codec_mgr_alloc_codec( pjmedia_codec_mgr *mgr, 642 const pjmedia_codec_info *info, 643 pjmedia_codec **p_codec); 457 644 458 645 /** … … 460 647 * the instance of the codec back to its factory. 461 648 * 462 * @param mgr The codec manager. 649 * @param mgr The codec manager instance. Application can get the 650 * instance by calling #pjmedia_endpt_get_codec_mgr(). 463 651 * @param codec The codec instance. 464 652 * … … 468 656 pjmedia_codec *codec); 469 657 658 659 660 661 470 662 /** 471 663 * @}
Note: See TracChangeset
for help on using the changeset viewer.