- Timestamp:
- Jul 15, 2011 10:19:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/codec.h
r3662 r3663 28 28 29 29 #include <pjmedia/port.h> 30 #include <pj/errno.h> 30 31 #include <pj/list.h> 31 32 #include <pj/pool.h> … … 324 325 * Initialize codec using the specified attribute. 325 326 * 327 * Application should call #pjmedia_codec_init() instead of 328 * calling this function directly. 329 * 326 330 * @param codec The codec instance. 327 331 * @param pool Pool to use when the codec needs to allocate … … 339 343 * encoder ptime is different than decoder ptime). 340 344 * 345 * Application should call #pjmedia_codec_open() instead of 346 * calling this function directly. 347 * 341 348 * @param codec The codec instance. 342 349 * @param param Codec initialization parameter. … … 350 357 * Close and shutdown codec, releasing all resources allocated by 351 358 * this codec, if any. 359 * 360 * Application should call #pjmedia_codec_close() instead of 361 * calling this function directly. 352 362 * 353 363 * @param codec The codec instance. … … 366 376 * changing VAD setting to succeed. 367 377 * 378 * Application should call #pjmedia_codec_modify() instead of 379 * calling this function directly. 380 * 368 381 * @param codec The codec instance. 369 382 * @param param The new codec parameter. … … 379 392 * have ptime that is equal to basic frame ptime (i.e. the value of 380 393 * info.frm_ptime in #pjmedia_codec_param). 394 * 395 * Application should call #pjmedia_codec_parse() instead of 396 * calling this function directly. 381 397 * 382 398 * @param codec The codec instance … … 404 420 * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param). 405 421 * 422 * Application should call #pjmedia_codec_encode() instead of 423 * calling this function directly. 424 * 406 425 * @param codec The codec instance. 407 426 * @param input The input frame. … … 423 442 * frames before decoding each frame. 424 443 * 444 * Application should call #pjmedia_codec_decode() instead of 445 * calling this function directly. 446 * 425 447 * @param codec The codec instance. 426 448 * @param input The input frame. … … 437 459 /** 438 460 * Instruct the codec to recover a missing frame. 461 * 462 * Application should call #pjmedia_codec_recover() instead of 463 * calling this function directly. 439 464 * 440 465 * @param codec The codec instance. … … 913 938 914 939 940 /** 941 * Initialize codec using the specified attribute. 942 * 943 * @param codec The codec instance. 944 * @param pool Pool to use when the codec needs to allocate some memory. 945 * 946 * @return PJ_SUCCESS on success. 947 */ 948 PJ_INLINE(pj_status_t) pjmedia_codec_init( pjmedia_codec *codec, 949 pj_pool_t *pool ) 950 { 951 return (*codec->op->init)(codec, pool); 952 } 953 954 955 /** 956 * Open the codec and initialize with the specified parameter. 957 * Upon successful initialization, the codec may modify the parameter 958 * and fills in the unspecified values (such as enc_ptime, when 959 * encoder ptime is different than decoder ptime). 960 * 961 * @param codec The codec instance. 962 * @param param Codec initialization parameter. 963 * 964 * @return PJ_SUCCESS on success. 965 */ 966 PJ_INLINE(pj_status_t) pjmedia_codec_open( pjmedia_codec *codec, 967 pjmedia_codec_param *param ) 968 { 969 return (*codec->op->open)(codec, param); 970 } 971 972 973 /** 974 * Close and shutdown codec, releasing all resources allocated by 975 * this codec, if any. 976 * 977 * @param codec The codec instance. 978 * 979 * @return PJ_SUCCESS on success. 980 */ 981 PJ_INLINE(pj_status_t) pjmedia_codec_close( pjmedia_codec *codec ) 982 { 983 return (*codec->op->close)(codec); 984 } 985 986 987 /** 988 * Modify the codec parameter after the codec is open. 989 * Note that not all codec parameters can be modified during run-time. 990 * When the parameter cannot be changed, this function will return 991 * non-PJ_SUCCESS, and the original parameters will not be changed. 992 * 993 * Application can expect changing trivial codec settings such as 994 * changing VAD setting to succeed. 995 * 996 * @param codec The codec instance. 997 * @param param The new codec parameter. 998 * 999 * @return PJ_SUCCESS on success. 1000 */ 1001 PJ_INLINE(pj_status_t) pjmedia_codec_modify(pjmedia_codec *codec, 1002 const pjmedia_codec_param *param) 1003 { 1004 return (*codec->op->modify)(codec, param); 1005 } 1006 1007 1008 /** 1009 * Instruct the codec to inspect the specified payload/packet and 1010 * split the packet into individual base frames. Each output frames will 1011 * have ptime that is equal to basic frame ptime (i.e. the value of 1012 * info.frm_ptime in #pjmedia_codec_param). 1013 * 1014 * @param codec The codec instance 1015 * @param pkt The input packet. 1016 * @param pkt_size Size of the packet. 1017 * @param timestamp The timestamp of the first sample in the packet. 1018 * @param frame_cnt On input, specifies the maximum number of frames 1019 * in the array. On output, the codec must fill 1020 * with number of frames detected in the packet. 1021 * @param frames On output, specifies the frames that have been 1022 * detected in the packet. 1023 * 1024 * @return PJ_SUCCESS on success. 1025 */ 1026 PJ_INLINE(pj_status_t) pjmedia_codec_parse( pjmedia_codec *codec, 1027 void *pkt, 1028 pj_size_t pkt_size, 1029 const pj_timestamp *timestamp, 1030 unsigned *frame_cnt, 1031 pjmedia_frame frames[] ) 1032 { 1033 return (*codec->op->parse)(codec, pkt, pkt_size, timestamp, 1034 frame_cnt, frames); 1035 } 1036 1037 1038 /** 1039 * Instruct the codec to encode the specified input frame. The input 1040 * PCM samples MUST have ptime that is multiplication of base frame 1041 * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param). 1042 * 1043 * @param codec The codec instance. 1044 * @param input The input frame. 1045 * @param out_size The length of buffer in the output frame. 1046 * @param output The output frame. 1047 * 1048 * @return PJ_SUCCESS on success; 1049 */ 1050 PJ_INLINE(pj_status_t) pjmedia_codec_encode( 1051 pjmedia_codec *codec, 1052 const struct pjmedia_frame *input, 1053 unsigned out_size, 1054 struct pjmedia_frame *output ) 1055 { 1056 return (*codec->op->encode)(codec, input, out_size, output); 1057 } 1058 1059 1060 /** 1061 * Instruct the codec to decode the specified input frame. The input 1062 * frame MUST have ptime that is exactly equal to base frame 1063 * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param). 1064 * Application can achieve this by parsing the packet into base 1065 * frames before decoding each frame. 1066 * 1067 * @param codec The codec instance. 1068 * @param input The input frame. 1069 * @param out_size The length of buffer in the output frame. 1070 * @param output The output frame. 1071 * 1072 * @return PJ_SUCCESS on success; 1073 */ 1074 PJ_INLINE(pj_status_t) pjmedia_codec_decode( 1075 pjmedia_codec *codec, 1076 const struct pjmedia_frame *input, 1077 unsigned out_size, 1078 struct pjmedia_frame *output ) 1079 { 1080 return (*codec->op->decode)(codec, input, out_size, output); 1081 } 1082 1083 1084 /** 1085 * Instruct the codec to recover a missing frame. 1086 * 1087 * @param codec The codec instance. 1088 * @param out_size The length of buffer in the output frame. 1089 * @param output The output frame where generated signal 1090 * will be placed. 1091 * 1092 * @return PJ_SUCCESS on success; 1093 */ 1094 PJ_INLINE(pj_status_t) pjmedia_codec_recover( pjmedia_codec *codec, 1095 unsigned out_size, 1096 struct pjmedia_frame *output ) 1097 { 1098 if (codec->op && codec->op->recover) 1099 return (*codec->op->recover)(codec, out_size, output); 1100 else 1101 return PJ_ENOTSUP; 1102 } 915 1103 916 1104
Note: See TracChangeset
for help on using the changeset viewer.