- Timestamp:
- Feb 24, 2011 7:47:55 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h
r3392 r3420 23 23 24 24 /** 25 * @file codec.h26 * @brief Codec framework.25 * @file vid_codec.h 26 * @brief Video codec framework. 27 27 */ 28 28 … … 46 46 pjmedia_format_id fmt_id; /**< Encoded format ID */ 47 47 pj_str_t encoding_name; /**< Encoding name */ 48 unsigned pt; /**< Payload type (may be 255 for 49 dynamic payload type) */ 50 unsigned clock_rate; /**< Clock rate */ 48 51 pjmedia_dir dir; /**< Direction */ 49 unsigned pt; /**< Payload type (may be 0 for 50 dynamic payload type) */ 51 unsigned clock_rate; /**< (?) Clock rate */ 52 unsigned dec_fmt_id_cnt; 52 unsigned dec_fmt_id_cnt; /**< # of supported encoding source 53 format IDs */ 53 54 pjmedia_format_id dec_fmt_id[PJMEDIA_VID_CODEC_MAX_DEC_FMT_CNT]; 54 55 /**< Supported encoding source 55 56 format IDs */ 56 unsigned fps_cnt; /**< zero if support any fps */57 pjmedia_ratio fps[PJMEDIA_VID_CODEC_MAX_FPS_CNT]; 58 /**< (?) supported FPSes,59 ffmpeg has this*/57 unsigned fps_cnt; /**< # of supported frame-rates, can be 58 zero (support any frame-rate) */ 59 pjmedia_ratio fps[PJMEDIA_VID_CODEC_MAX_FPS_CNT]; 60 /**< Supported frame-rates */ 60 61 } pjmedia_vid_codec_info; 62 61 63 62 64 /** … … 80 82 81 83 unsigned enc_mtu; /**< MTU or max payload size setting*/ 82 unsigned pt; /**< Payload type. */83 84 } pjmedia_vid_codec_param; 84 85 85 86 86 87 /* 88 * Forward declaration for pjmedia_vid_codec. 87 /** 88 * Enumeration of video codec events. 89 */ 90 typedef enum pjmedia_vid_codec_event 91 { 92 /** 93 * Format changed event. The decoder output format is not really 94 * configurable, so that the output format setting configured in the 95 * initialization may be changed. Application can catch this event 96 * by checking the bit_info field of the pjmedia_frame of the decoder 97 * output frame. 98 */ 99 PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED = 1, 100 101 } pjmedia_vid_codec_event; 102 103 104 /** 105 * Forward declaration for video codec. 89 106 */ 90 107 typedef struct pjmedia_vid_codec pjmedia_vid_codec; … … 112 129 * Open the codec and initialize with the specified parameter. 113 130 * Upon successful initialization, the codec may modify the parameter 114 * and fills in the unspecified values (such as enc_ptime, when 115 * encoder ptime is different than decoder ptime). 131 * and fills in the unspecified values (such as size or frame rate of 132 * the encoder format, as it may need to be negotiated with remote 133 * preferences via SDP fmtp). 116 134 * 117 135 * @param codec The codec instance. … … 139 157 * non-PJ_SUCCESS, and the original parameters will not be changed. 140 158 * 141 * Application can expect changing trivial codec settings such as142 * changing VAD setting to succeed.143 *144 159 * @param codec The codec instance. 145 160 * @param param The new codec parameter. … … 148 163 */ 149 164 pj_status_t (*modify)(pjmedia_vid_codec *codec, 150 const pjmedia_vid_codec_param *param ); 165 const pjmedia_vid_codec_param *param); 166 167 /** 168 * Get the codec parameter after the codec is opened. 169 * 170 * @param codec The codec instance. 171 * @param param The codec parameter. 172 * 173 * @return PJ_SUCCESS on success. 174 */ 175 pj_status_t (*get_param)(pjmedia_vid_codec *codec, 176 pjmedia_vid_codec_param *param); 151 177 152 178 /** 153 * Instruct the codec to inspect the specified payload/packet and 154 * split the packet into individual base frames. Each output frames will 155 * have ptime that is equal to basic frame ptime (i.e. the value of 156 * info.frm_ptime in #pjmedia_vid_codec_param). 179 * Instruct the codec to generate a payload/packet from a picture 180 * bitstream to be sent (via network). The maximum payload size or 181 * MTU is configurable via enc_mtu field of #pjmedia_vid_codec_param. 182 * For a long bitstream, application usually need to call this function 183 * multiple times until the whole bitstream is sent. Note that, for 184 * performance reason, the packetization will be done in-place, so the 185 * original bitstream may be modified by this function. 186 * 187 * @param codec The codec instance 188 * @param bits The picture bitstream. 189 * @param bits_len The length of the bitstream. 190 * @param bits_pos On input, the start position of the bitstream 191 * to be packetized. On output, the next position for 192 * next packet. 193 * @param pkt The pointer of the generated payload. 194 * @param pkt_len The payload length. 195 * 196 * @return PJ_SUCCESS on success. 197 */ 198 pj_status_t (*packetize) (pjmedia_vid_codec *codec, 199 pj_uint8_t *bits, 200 pj_size_t bits_len, 201 unsigned *bits_pos, 202 const pj_uint8_t **pkt, 203 pj_size_t *pkt_len); 204 205 /** 206 * Instruct the codec to parse a payload and append it into a picture 207 * bitstream. A picture bitstreams may need to be reconstructed from 208 * one or more payloads. Note that this function will not provide the 209 * detection of picture boundary, so application should manage the 210 * picture boundary detection by itself, e.g: for RTP delivery, payloads 211 * belong to the same picture will share the same RTP timestamp and also 212 * there is marker bit in the RTP header that is usually reserved for 213 * end-of-picture flag. 157 214 * 158 215 * @param codec The codec instance … … 168 225 * @return PJ_SUCCESS on success. 169 226 */ 170 pj_status_t (*packetize) (pjmedia_vid_codec *codec,171 pj_uint8_t *buf,172 pj_size_t buf_len,173 unsigned *pos,174 const pj_uint8_t **payload,175 pj_size_t *payload_len);176 177 /**178 * Instruct the codec to inspect the specified payload/packet and179 * split the packet into individual base frames. Each output frames will180 * have ptime that is equal to basic frame ptime (i.e. the value of181 * info.frm_ptime in #pjmedia_vid_codec_param).182 *183 * @param codec The codec instance184 * @param pkt The input packet.185 * @param pkt_size Size of the packet.186 * @param timestamp The timestamp of the first sample in the packet.187 * @param frame_cnt On input, specifies the maximum number of frames188 * in the array. On output, the codec must fill189 * with number of frames detected in the packet.190 * @param frames On output, specifies the frames that have been191 * detected in the packet.192 *193 * @return PJ_SUCCESS on success.194 */195 227 pj_status_t (*unpacketize)(pjmedia_vid_codec *codec, 196 228 const pj_uint8_t *payload, 197 229 pj_size_t payload_len, 198 pj_uint8_t *b uf,199 pj_size_t *b uf_len);230 pj_uint8_t *bits, 231 pj_size_t *bits_len); 200 232 201 233 /** 202 234 * Instruct the codec to encode the specified input frame. The input 203 * PCM samples MUST have ptime that is multiplication of base frame204 * ptime (i.e. the value of info.frm_ptime in #pjmedia_vid_codec_param).235 * MUST contain only one picture with appropriate format as specified 236 * in opening the codec. 205 237 * 206 238 * @param codec The codec instance. … … 218 250 /** 219 251 * Instruct the codec to decode the specified input frame. The input 220 * frame MUST have ptime that is exactly equal to base frame 221 * ptime (i.e. the value of info.frm_ptime in #pjmedia_vid_codec_param). 222 * Application can achieve this by parsing the packet into base 223 * frames before decoding each frame. 252 * frame MUST contain exactly one picture. Note that the decoded picture 253 * format may different to the current setting, e.g: the format specified 254 * in the #pjmedia_vid_codec_param when opening the codec, in this case the 255 * PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED flag will be set in the bit_info 256 * field of the output frame and application can query the new format 257 * using #get_param(). 224 258 * 225 259 * @param codec The codec instance. … … 248 282 unsigned out_size, 249 283 pjmedia_frame *output); 284 250 285 } pjmedia_vid_codec_op; 251 286 … … 259 294 260 295 /** 261 * This structure describes a codec instance.296 * This structure describes a video codec instance. 262 297 */ 263 298 struct pjmedia_vid_codec … … 267 302 268 303 /** Codec's private data. */ 269 void 304 void *codec_data; 270 305 271 306 /** Codec factory where this codec was allocated. */ … … 273 308 274 309 /** Operations to codec. */ 275 pjmedia_vid_codec_op 310 pjmedia_vid_codec_op *op; 276 311 }; 277 312 … … 377 412 378 413 /** 414 * Opaque declaration for codec manager. 415 */ 416 typedef struct pjmedia_vid_codec_mgr pjmedia_vid_codec_mgr; 417 418 /** 379 419 * Declare maximum codecs 380 420 */ … … 382 422 383 423 384 /** 385 * Codec manager maintains array of these structs for each supported 386 * codec. 387 */ 388 typedef struct pjmedia_vid_codec_desc 389 { 390 pjmedia_vid_codec_info info; /**< Codec info. */ 391 pjmedia_codec_id id; /**< Fully qualified name */ 392 pjmedia_codec_priority prio; /**< Priority. */ 393 pjmedia_vid_codec_factory *factory; /**< The factory. */ 394 pjmedia_vid_codec_param *def_param; /**< Default codecs 395 parameters. */ 396 } pjmedia_vid_codec_desc; 397 398 399 /** 400 * The declaration for codec manager. Application doesn't normally need 401 * to see this declaration, but nevertheless this declaration is needed 402 * by media endpoint to instantiate the codec manager. 403 */ 404 typedef struct pjmedia_vid_codec_mgr 405 { 406 /** Codec manager mutex. */ 407 pj_mutex_t *mutex; 408 409 /** List of codec factories registered to codec manager. */ 410 pjmedia_vid_codec_factory factory_list; 411 412 /** Number of supported codecs. */ 413 unsigned codec_cnt; 414 415 /** Array of codec descriptor. */ 416 pjmedia_vid_codec_desc codec_desc[PJMEDIA_CODEC_MGR_MAX_CODECS]; 417 418 } pjmedia_vid_codec_mgr; 419 420 421 422 /** 423 * Initialize codec manager. Normally this function is called by pjmedia 424 425 /** 426 * Initialize codec manager. If there is no the default video codec manager, 427 * this function will automatically set the default video codec manager to 428 * the new codec manager instance. Normally this function is called by pjmedia 424 429 * endpoint's initialization code. 425 430 * 426 * @param mgr Codec managerinstance.427 * @param pf Pool factoryinstance.431 * @param pool The pool instance. 432 * @param mgr The pointer to the new codec manager instance. 428 433 * 429 434 * @return PJ_SUCCESS on success. … … 437 442 * endpoint's deinitialization code. 438 443 * 439 * @param mgr Codec manager instance. 444 * @param mgr Codec manager instance. If NULL, it is the default codec 445 * manager instance will be destroyed. 440 446 * 441 447 * @return PJ_SUCCESS on success. … … 443 449 PJ_DECL(pj_status_t) pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr *mgr); 444 450 451 452 /** 453 * Get the default codec manager instance. 454 * 455 * @return The default codec manager instance or NULL if none. 456 */ 445 457 PJ_DECL(pjmedia_vid_codec_mgr*) pjmedia_vid_codec_mgr_instance(void); 458 459 460 /** 461 * Set the default codec manager instance. 462 * 463 * @param mgr The codec manager instance. 464 */ 446 465 PJ_DECL(void) pjmedia_vid_codec_mgr_set_instance(pjmedia_vid_codec_mgr* mgr); 447 466 … … 451 470 * all supported codecs in the factory to the codec manager. 452 471 * 453 * @param mgr The codec manager instance. Application can get the454 * instance by calling #pjmedia_endpt_get_codec_mgr().472 * @param mgr The codec manager instance. If NULL, the default codec 473 * manager instance will be used. 455 474 * @param factory The codec factory to be registered. 456 475 * … … 466 485 * codec manager's list of supported codecs. 467 486 * 468 * @param mgr The codec manager instance. Application can get the469 * instance by calling #pjmedia_endpt_get_codec_mgr().487 * @param mgr The codec manager instance. If NULL, the default codec 488 * manager instance will be used. 470 489 * @param factory The codec factory to be unregistered. 471 490 * … … 480 499 * codec manager by codec factories. 481 500 * 482 * @param mgr The codec manager instance. Application can get the483 * instance by calling #pjmedia_endpt_get_codec_mgr().501 * @param mgr The codec manager instance. If NULL, the default codec 502 * manager instance will be used. 484 503 * @param count On input, specifies the number of elements in 485 504 * the array. On output, the value will be set to … … 501 520 * Get codec info for the specified static payload type. 502 521 * 503 * @param mgr The codec manager instance. Application can get the504 * instance by calling #pjmedia_endpt_get_codec_mgr().522 * @param mgr The codec manager instance. If NULL, the default codec 523 * manager instance will be used. 505 524 * @param pt Static payload type/number. 506 * @param inf Pointer to receive codec info.525 * @param info Pointer to receive codec info. 507 526 * 508 527 * @return PJ_SUCCESS on success. … … 511 530 pjmedia_vid_codec_mgr_get_codec_info( pjmedia_vid_codec_mgr *mgr, 512 531 unsigned pt, 513 const pjmedia_vid_codec_info **inf );532 const pjmedia_vid_codec_info **info); 514 533 515 534 /** 516 535 * Convert codec info struct into a unique codec identifier. 517 * A codec identifier looks something like " L16/44100/2".536 * A codec identifier looks something like "H263/90000". 518 537 * 519 538 * @param info The codec info … … 532 551 * Find codecs by the unique codec identifier. This function will find 533 552 * all codecs that match the codec identifier prefix. For example, if 534 * " L16" is specified, then it will find "L16/8000/1", "L16/16000/1",553 * "H26" is specified, then it will find "H263/90000", "H264/90000", 535 554 * and so on, up to the maximum count specified in the argument. 536 555 * 537 * @param mgr The codec manager instance. Application can get the538 * instance by calling #pjmedia_endpt_get_codec_mgr().556 * @param mgr The codec manager instance. If NULL, the default codec 557 * manager instance will be used. 539 558 * @param codec_id The full codec ID or codec ID prefix. If an empty 540 559 * string is given, it will match all codecs. … … 549 568 */ 550 569 PJ_DECL(pj_status_t) 551 pjmedia_vid_codec_mgr_find_codecs_by_id( 552 553 554 555 570 pjmedia_vid_codec_mgr_find_codecs_by_id(pjmedia_vid_codec_mgr *mgr, 571 const pj_str_t *codec_id, 572 unsigned *count, 573 const pjmedia_vid_codec_info *p_info[], 574 unsigned prio[]); 556 575 557 576 … … 562 581 * priorities of all those codecs. 563 582 * 564 * @param mgr The codec manager instance. Application can get the565 * instance by calling #pjmedia_endpt_get_codec_mgr().583 * @param mgr The codec manager instance. If NULL, the default codec 584 * manager instance will be used. 566 585 * @param codec_id The full codec ID or codec ID prefix. If an empty 567 586 * string is given, it will match all codecs. … … 574 593 PJ_DECL(pj_status_t) 575 594 pjmedia_vid_codec_mgr_set_codec_priority(pjmedia_vid_codec_mgr *mgr, 576 577 595 const pj_str_t *codec_id, 596 pj_uint8_t prio); 578 597 579 598 … … 581 600 * Get default codec param for the specified codec info. 582 601 * 583 * @param mgr The codec manager instance. Application can get the584 * instance by calling #pjmedia_endpt_get_codec_mgr().602 * @param mgr The codec manager instance. If NULL, the default codec 603 * manager instance will be used. 585 604 * @param info The codec info, which default parameter's is being 586 605 * queried. … … 591 610 */ 592 611 PJ_DECL(pj_status_t) 593 pjmedia_vid_codec_mgr_get_default_param( 594 595 pjmedia_vid_codec_param *param);612 pjmedia_vid_codec_mgr_get_default_param(pjmedia_vid_codec_mgr *mgr, 613 const pjmedia_vid_codec_info *info, 614 pjmedia_vid_codec_param *param); 596 615 597 616 … … 599 618 * Set default codec param for the specified codec info. 600 619 * 601 * @param mgr The codec manager instance. Application can get the 602 * instance by calling #pjmedia_endpt_get_codec_mgr(). 620 * @param mgr The codec manager instance. If NULL, the default codec 621 * manager instance will be used. 622 * @param pool The pool instance. 603 623 * @param info The codec info, which default parameter's is being 604 624 * updated. … … 620 640 * until it finds factory that is able to create the specified codec. 621 641 * 622 * @param mgr The codec manager instance. Application can get the623 * instance by calling #pjmedia_endpt_get_codec_mgr().642 * @param mgr The codec manager instance. If NULL, the default codec 643 * manager instance will be used. 624 644 * @param info The information about the codec to be created. 625 645 * @param p_codec Pointer to receive the codec instance. … … 636 656 * the instance of the codec back to its factory. 637 657 * 638 * @param mgr The codec manager instance. Application can get the639 * instance by calling #pjmedia_endpt_get_codec_mgr().658 * @param mgr The codec manager instance. If NULL, the default codec 659 * manager instance will be used. 640 660 * @param codec The codec instance. 641 661 * … … 655 675 656 676 /** 657 * @defgroup PJMEDIA_CODEC_ CODECS Supportedcodecs677 * @defgroup PJMEDIA_CODEC_VID_CODECS Supported video codecs 658 678 * @ingroup PJMEDIA_CODEC 659 * @brief Documentation about individual codec supported by PJMEDIA679 * @brief Documentation about individual video codec supported by PJMEDIA 660 680 * @{ 661 681 * Please see the APIs provided by the individual codecs below.
Note: See TracChangeset
for help on using the changeset viewer.