Changeset 3663
- Timestamp:
- Jul 15, 2011 10:19:59 AM (12 years ago)
- Location:
- pjproject/branches/projects/2.0-dev
- Files:
-
- 12 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 -
pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h
r3640 r3663 114 114 * Initialize codec using the specified attribute. 115 115 * 116 * Application should call #pjmedia_vid_codec_init() instead of 117 * calling this function directly. 118 * 116 119 * @param codec The codec instance. 117 120 * @param pool Pool to use when the codec needs to allocate … … 130 133 * preferences via SDP fmtp). 131 134 * 135 * Application should call #pjmedia_vid_codec_open() instead of 136 * calling this function directly. 137 * 132 138 * @param codec The codec instance. 133 139 * @param param Codec initialization parameter. … … 141 147 * Close and shutdown codec, releasing all resources allocated by 142 148 * this codec, if any. 149 * 150 * Application should call #pjmedia_vid_codec_close() instead of 151 * calling this function directly. 143 152 * 144 153 * @param codec The codec instance. … … 154 163 * non-PJ_SUCCESS, and the original parameters will not be changed. 155 164 * 165 * Application should call #pjmedia_vid_codec_modify() instead of 166 * calling this function directly. 167 * 156 168 * @param codec The codec instance. 157 169 * @param param The new codec parameter. … … 164 176 /** 165 177 * Get the codec parameter after the codec is opened. 178 * 179 * Application should call #pjmedia_vid_codec_get_param() instead of 180 * calling this function directly. 166 181 * 167 182 * @param codec The codec instance. … … 181 196 * performance reason, the packetization will be done in-place, so the 182 197 * original bitstream may be modified by this function. 198 * 199 * Application should call #pjmedia_vid_codec_packetize() instead of 200 * calling this function directly. 183 201 * 184 202 * @param codec The codec instance … … 212 230 * set to NULL, as the packetizer need to update its internal state. 213 231 * 232 * Application should call #pjmedia_vid_codec_unpacketize() instead of 233 * calling this function directly. 234 * 214 235 * @param codec The codec instance 215 236 * @param pkt The input packet. … … 236 257 * in opening the codec. 237 258 * 259 * Application should call #pjmedia_vid_codec_encode() instead of 260 * calling this function directly. 261 * 238 262 * @param codec The codec instance. 239 263 * @param input The input frame. … … 257 281 * using #get_param(). 258 282 * 283 * Application should call #pjmedia_vid_codec_decode() instead of 284 * calling this function directly. 285 * 259 286 * @param codec The codec instance. 260 287 * @param input The input frame. … … 271 298 /** 272 299 * Instruct the codec to recover a missing frame. 300 * 301 * Application should call #pjmedia_vid_codec_recover() instead of 302 * calling this function directly. 273 303 * 274 304 * @param codec The codec instance. … … 433 463 * @param sig Codec's object signature (see signatures.h) 434 464 */ 435 PJ_DECL(void) pjmedia_vid_codec_ init(pjmedia_vid_codec *codec,436 pjmedia_obj_sig sig);465 PJ_DECL(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec, 466 pjmedia_obj_sig sig); 437 467 438 468 /** … … 700 730 701 731 732 /** 733 * Initialize codec using the specified attribute. 734 * 735 * @param codec The codec instance. 736 * @param pool Pool to use when the codec needs to allocate 737 * some memory. 738 * 739 * @return PJ_SUCCESS on success. 740 */ 741 PJ_INLINE(pj_status_t) pjmedia_vid_codec_init( pjmedia_vid_codec *codec, 742 pj_pool_t *pool ) 743 { 744 return (*codec->op->init)(codec, pool); 745 } 746 747 748 /** 749 * Open the codec and initialize with the specified parameter. 750 * Upon successful initialization, the codec may modify the parameter 751 * and fills in the unspecified values (such as size or frame rate of 752 * the encoder format, as it may need to be negotiated with remote 753 * preferences via SDP fmtp). 754 * 755 * @param codec The codec instance. 756 * @param param Codec initialization parameter. 757 * 758 * @return PJ_SUCCESS on success. 759 */ 760 PJ_INLINE(pj_status_t) pjmedia_vid_codec_open( 761 pjmedia_vid_codec *codec, 762 pjmedia_vid_codec_param *param ) 763 { 764 return (*codec->op->open)(codec, param); 765 } 766 767 768 /** 769 * Close and shutdown codec, releasing all resources allocated by 770 * this codec, if any. 771 * 772 * @param codec The codec instance. 773 * 774 * @return PJ_SUCCESS on success. 775 */ 776 PJ_INLINE(pj_status_t) pjmedia_vid_codec_close( pjmedia_vid_codec *codec ) 777 { 778 return (*codec->op->close)(codec); 779 } 780 781 782 /** 783 * Modify the codec parameter after the codec is open. 784 * Note that not all codec parameters can be modified during run-time. 785 * When the parameter cannot be changed, this function will return 786 * non-PJ_SUCCESS, and the original parameters will not be changed. 787 * 788 * @param codec The codec instance. 789 * @param param The new codec parameter. 790 * 791 * @return PJ_SUCCESS on success. 792 */ 793 PJ_INLINE(pj_status_t) pjmedia_vid_codec_modify( 794 pjmedia_vid_codec *codec, 795 const pjmedia_vid_codec_param *param) 796 { 797 return (*codec->op->modify)(codec, param); 798 } 799 800 801 /** 802 * Get the codec parameter after the codec is opened. 803 * 804 * @param codec The codec instance. 805 * @param param The codec parameter. 806 * 807 * @return PJ_SUCCESS on success. 808 */ 809 PJ_INLINE(pj_status_t) pjmedia_vid_codec_get_param( 810 pjmedia_vid_codec *codec, 811 pjmedia_vid_codec_param *param) 812 { 813 return (*codec->op->get_param)(codec, param); 814 } 815 816 817 /** 818 * Instruct the codec to generate a payload/packet from a picture 819 * bitstream to be sent (via network). The maximum payload size or 820 * MTU is configurable via enc_mtu field of #pjmedia_vid_codec_param. 821 * For a long bitstream, application usually need to call this function 822 * multiple times until the whole bitstream is sent. Note that, for 823 * performance reason, the packetization will be done in-place, so the 824 * original bitstream may be modified by this function. 825 * 826 * @param codec The codec instance 827 * @param bits The picture bitstream. 828 * @param bits_len The length of the bitstream. 829 * @param bits_pos On input, the start position of the bitstream 830 * to be packetized. On output, the next position for 831 * next packet. 832 * @param pkt The pointer of the generated payload. 833 * @param pkt_len The payload length. 834 * 835 * @return PJ_SUCCESS on success. 836 */ 837 PJ_INLINE(pj_status_t) pjmedia_vid_codec_packetize( 838 pjmedia_vid_codec *codec, 839 pj_uint8_t *bits, 840 pj_size_t bits_len, 841 unsigned *bits_pos, 842 const pj_uint8_t **pkt, 843 pj_size_t *pkt_len ) 844 { 845 return (*codec->op->packetize)(codec, bits, bits_len, bits_pos, 846 pkt, pkt_len); 847 } 848 849 850 /** 851 * Instruct the codec to parse a payload and append it into a picture 852 * bitstream. A picture bitstreams may need to be reconstructed from 853 * one or more payloads. Note that this function will not provide the 854 * detection of picture boundary, so application should manage the 855 * picture boundary detection by itself, e.g: for RTP delivery, payloads 856 * belong to the same picture will share the same RTP timestamp and also 857 * there is marker bit in the RTP header that is usually reserved for 858 * end-of-picture flag. Also note that in case of noticing packet lost, 859 * application should keep calling this function with payload pointer 860 * set to NULL, as the packetizer need to update its internal state. 861 * 862 * @param codec The codec instance 863 * @param pkt The input packet. 864 * @param pkt_size Size of the packet. 865 * @param timestamp The timestamp of the first sample in the packet. 866 * @param frame_cnt On input, specifies the maximum number of frames 867 * in the array. On output, the codec must fill 868 * with number of frames detected in the packet. 869 * @param frames On output, specifies the frames that have been 870 * detected in the packet. 871 * 872 * @return PJ_SUCCESS on success. 873 */ 874 PJ_INLINE(pj_status_t) pjmedia_vid_codec_unpacketize( 875 pjmedia_vid_codec *codec, 876 const pj_uint8_t *payload, 877 pj_size_t payload_len, 878 pj_uint8_t *bits, 879 pj_size_t bits_len, 880 unsigned *bits_pos ) 881 { 882 return (*codec->op->unpacketize)(codec, payload, payload_len, bits, 883 bits_len, bits_pos); 884 } 885 886 887 /** 888 * Instruct the codec to encode the specified input frame. The input 889 * MUST contain only one picture with appropriate format as specified 890 * in opening the codec. 891 * 892 * @param codec The codec instance. 893 * @param input The input frame. 894 * @param out_size The length of buffer in the output frame. 895 * @param output The output frame. 896 * 897 * @return PJ_SUCCESS on success; 898 */ 899 PJ_INLINE(pj_status_t) pjmedia_vid_codec_encode( 900 pjmedia_vid_codec *codec, 901 const pjmedia_frame *input, 902 unsigned out_size, 903 pjmedia_frame *output) 904 { 905 return (*codec->op->encode)(codec, input, out_size, output); 906 } 907 908 909 /** 910 * Instruct the codec to decode the specified input frame. The input 911 * frame MUST contain exactly one picture. Note that the decoded picture 912 * format may different to the current setting, e.g: the format specified 913 * in the #pjmedia_vid_codec_param when opening the codec, in this case the 914 * PJMEDIA_EVENT_FMT_CHANGED event will be emitted by the codec. The codec 915 * parameter will also be updated, and application can query the format by 916 * using #get_param(). 917 * 918 * @param codec The codec instance. 919 * @param input The input frame. 920 * @param out_size The length of buffer in the output frame. 921 * @param output The output frame. 922 * 923 * @return PJ_SUCCESS on success; 924 */ 925 PJ_INLINE(pj_status_t) pjmedia_vid_codec_decode( 926 pjmedia_vid_codec *codec, 927 const pjmedia_frame *input, 928 unsigned out_size, 929 pjmedia_frame *output) 930 { 931 return (*codec->op->decode)(codec, input, out_size, output); 932 } 933 934 935 /** 936 * Instruct the codec to recover a missing frame. 937 * 938 * @param codec The codec instance. 939 * @param out_size The length of buffer in the output frame. 940 * @param output The output frame where generated signal 941 * will be placed. 942 * 943 * @return PJ_SUCCESS on success; 944 */ 945 PJ_INLINE(pj_status_t) pjmedia_vid_codec_recover( 946 pjmedia_vid_codec *codec, 947 unsigned out_size, 948 pjmedia_frame *output) 949 { 950 if (codec->op && codec->op->recover) 951 return (*codec->op->recover)(codec, out_size, output); 952 else 953 return PJ_ENOTSUP; 954 } 702 955 703 956 -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c
r3640 r3663 887 887 goto on_error; 888 888 } 889 pjmedia_vid_codec_ init(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG);889 pjmedia_vid_codec_reset(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG); 890 890 codec->op = &ffmpeg_op; 891 891 codec->factory = factory; -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stream.c
r3640 r3663 516 516 frame_out.buf = p_out_samp + samples_count; 517 517 frame_out.size = frame->size - samples_count*2; 518 status = (*stream->codec->op->recover)(stream->codec,519 520 518 status = pjmedia_codec_recover(stream->codec, 519 frame_out.size, 520 &frame_out); 521 521 522 522 ++stream->plc_cnt; … … 565 565 frame_out.buf = p_out_samp + samples_count; 566 566 frame_out.size = frame->size - samples_count*2; 567 status = (*stream->codec->op->recover)(stream->codec,568 569 567 status = pjmedia_codec_recover(stream->codec, 568 frame_out.size, 569 &frame_out); 570 570 if (status != PJ_SUCCESS) 571 571 break; … … 620 620 frame_out.buf = p_out_samp + samples_count; 621 621 frame_out.size = frame->size - samples_count*2; 622 status = (*stream->codec->op->recover)(stream->codec,623 624 622 status = pjmedia_codec_recover(stream->codec, 623 frame_out.size, 624 &frame_out); 625 625 if (status != PJ_SUCCESS) 626 626 break; … … 671 671 frame_out.buf = p_out_samp + samples_count; 672 672 frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE; 673 status = stream->codec->op->decode( stream->codec, &frame_in,674 673 status = pjmedia_codec_decode( stream->codec, &frame_in, 674 frame_out.size, &frame_out); 675 675 if (status != 0) { 676 676 LOGERR_((port->info.name.ptr, "codec decode() error", … … 775 775 frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO; 776 776 777 status = stream->codec->op->decode( stream->codec, &frame_in,778 777 status = pjmedia_codec_decode( stream->codec, &frame_in, 778 0, frame); 779 779 if (status != PJ_SUCCESS) { 780 780 LOGERR_((port->info.name.ptr, "codec decode() error", … … 802 802 status = PJ_SUCCESS; 803 803 if (stream->codec->op->recover) { 804 status = (*stream->codec->op->recover)(stream->codec, 805 0, frame); 804 status = pjmedia_codec_recover(stream->codec, 0, frame); 806 805 } 807 806 … … 1249 1248 1250 1249 /* Encode! */ 1251 status = stream->codec->op->encode( stream->codec, &silence_frame,1252 1253 1254 1250 status = pjmedia_codec_encode( stream->codec, &silence_frame, 1251 channel->out_pkt_size - 1252 sizeof(pjmedia_rtp_hdr), 1253 &frame_out); 1255 1254 if (status != PJ_SUCCESS) { 1256 1255 LOGERR_((stream->port.info.name.ptr, … … 1273 1272 { 1274 1273 /* Encode! */ 1275 status = stream->codec->op->encode( stream->codec, frame,1276 1277 1278 1274 status = pjmedia_codec_encode( stream->codec, frame, 1275 channel->out_pkt_size - 1276 sizeof(pjmedia_rtp_hdr), 1277 &frame_out); 1279 1278 if (status != PJ_SUCCESS) { 1280 1279 LOGERR_((stream->port.info.name.ptr, … … 1426 1425 { 1427 1426 stream->codec_param.setting.vad = stream->vad_enabled; 1428 stream->codec->op->modify(stream->codec, &stream->codec_param);1427 pjmedia_codec_modify(stream->codec, &stream->codec_param); 1429 1428 PJ_LOG(4,(stream->port.info.name.ptr,"VAD re-enabled")); 1430 1429 } … … 1692 1691 1693 1692 /* Parse the payload. */ 1694 status = (*stream->codec->op->parse)(stream->codec, 1695 (void*)payload, 1696 payloadlen, 1697 &ts, 1698 &count, 1699 frames); 1693 status = pjmedia_codec_parse(stream->codec, (void*)payload, 1694 payloadlen, &ts, &count, frames); 1700 1695 if (status != PJ_SUCCESS) { 1701 1696 LOGERR_((stream->port.info.name.ptr, … … 2059 2054 2060 2055 /* Open the codec. */ 2061 status = stream->codec->op->open(stream->codec, &stream->codec_param);2056 status = pjmedia_codec_open(stream->codec, &stream->codec_param); 2062 2057 if (status != PJ_SUCCESS) 2063 2058 goto err_cleanup; … … 2138 2133 stream->codec_param.setting.vad = 0; 2139 2134 stream->ts_vad_disabled = 0; 2140 stream->codec->op->modify(stream->codec, &stream->codec_param);2135 pjmedia_codec_modify(stream->codec, &stream->codec_param); 2141 2136 PJ_LOG(4,(stream->port.info.name.ptr,"VAD temporarily disabled")); 2142 2137 } … … 2441 2436 2442 2437 if (stream->codec) { 2443 stream->codec->op->close(stream->codec);2438 pjmedia_codec_close(stream->codec); 2444 2439 pjmedia_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec); 2445 2440 stream->codec = NULL; -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c
r3640 r3663 70 70 * Initialize pjmedia_vid_codec structure with default values. 71 71 */ 72 PJ_DEF(void) pjmedia_vid_codec_ init(pjmedia_vid_codec *codec,72 PJ_DEF(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec, 73 73 pjmedia_obj_sig sig) 74 74 { -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c
r3641 r3663 336 336 case PJMEDIA_EVENT_FMT_CHANGED: 337 337 /* Update param from codec */ 338 stream->codec->op->get_param(stream->codec, stream->info.codec_param);338 pjmedia_vid_codec_get_param(stream->codec, stream->info.codec_param); 339 339 340 340 /* Update decoding channel port info */ … … 764 764 765 765 /* Encode! */ 766 status = (*stream->codec->op->encode)(stream->codec, frame,767 768 769 766 status = pjmedia_vid_codec_encode(stream->codec, frame, 767 channel->buf_size - 768 sizeof(pjmedia_rtp_hdr), 769 &frame_out); 770 770 if (status != PJ_SUCCESS) { 771 771 LOGERR_((channel->port.info.name.ptr, … … 785 785 786 786 /* Generate RTP payload */ 787 status = (*stream->codec->op->packetize)( 788 stream->codec, 789 (pj_uint8_t*)frame_out.buf, 790 frame_out.size, 791 &processed, 792 (const pj_uint8_t**)&payload, 793 &payload_len); 787 status = pjmedia_vid_codec_packetize(stream->codec, 788 (pj_uint8_t*)frame_out.buf, 789 frame_out.size, 790 &processed, 791 (const pj_uint8_t**)&payload, 792 &payload_len); 794 793 if (status != PJ_SUCCESS) { 795 794 LOGERR_((channel->port.info.name.ptr, … … 933 932 } 934 933 935 status = (*stream->codec->op->unpacketize)(934 status = pjmedia_vid_codec_unpacketize( 936 935 stream->codec, 937 936 p, psize, … … 966 965 frame_in.timestamp.u64 = last_ts; 967 966 968 status = stream->codec->op->decode(stream->codec, &frame_in,969 967 status = pjmedia_vid_codec_decode(stream->codec, &frame_in, 968 frame->size, frame); 970 969 if (status != PJ_SUCCESS) { 971 970 LOGERR_((port->info.name.ptr, "codec decode() error", … … 1240 1239 1241 1240 /* Init and open the codec. */ 1242 status = stream->codec->op->init(stream->codec, pool);1241 status = pjmedia_vid_codec_init(stream->codec, pool); 1243 1242 if (status != PJ_SUCCESS) 1244 1243 return status; 1245 status = stream->codec->op->open(stream->codec, info->codec_param);1244 status = pjmedia_vid_codec_open(stream->codec, info->codec_param); 1246 1245 if (status != PJ_SUCCESS) 1247 1246 return status; … … 1446 1445 /* Free codec. */ 1447 1446 if (stream->codec) { 1448 stream->codec->op->close(stream->codec);1447 pjmedia_vid_codec_close(stream->codec); 1449 1448 pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec); 1450 1449 stream->codec = NULL; -
pjproject/branches/projects/2.0-dev/pjmedia/src/test/codec_vectors.c
r2675 r3663 74 74 codec_param.setting.vad = 0; 75 75 76 status = codec->op->init(codec, pool);76 status = pjmedia_codec_init(codec, pool); 77 77 if (status != PJ_SUCCESS) { 78 78 rc = -60; … … 80 80 } 81 81 82 status = codec->op->open(codec, &codec_param);82 status = pjmedia_codec_open(codec, &codec_param); 83 83 if (status != PJ_SUCCESS) { 84 84 rc = -70; … … 118 118 119 119 out_frame.size = samples_per_frame; 120 status = codec->op->encode(codec, &in_frame, samples_per_frame,120 status = pjmedia_codec_encode(codec, &in_frame, samples_per_frame, 121 121 &out_frame); 122 122 if (status != PJ_SUCCESS) { … … 189 189 190 190 if (codec) { 191 codec->op->close(codec);191 pjmedia_codec_close(codec); 192 192 pjmedia_codec_mgr_dealloc_codec(mgr, codec); 193 193 } … … 327 327 codec_param.setting.vad = 0; 328 328 329 status = codec->op->init(codec, pool);329 status = pjmedia_codec_init(codec, pool); 330 330 if (status != PJ_SUCCESS) { 331 331 rc = -60; … … 333 333 } 334 334 335 status = codec->op->open(codec, &codec_param);335 status = pjmedia_codec_open(codec, &codec_param); 336 336 if (status != PJ_SUCCESS) { 337 337 rc = -70; … … 388 388 if (has_frame) { 389 389 count = 2; 390 if ( codec->op->parse(codec, pkt, encoded_len, &ts,391 &count, in_frame) != PJ_SUCCESS)390 if (pjmedia_codec_parse(codec, pkt, encoded_len, &ts, 391 &count, in_frame) != PJ_SUCCESS) 392 392 { 393 393 rc = -100; … … 400 400 } 401 401 402 if ( codec->op->decode(codec, &in_frame[0], samples_per_frame*2,403 &out_frame) != PJ_SUCCESS)402 if (pjmedia_codec_decode(codec, &in_frame[0], samples_per_frame*2, 403 &out_frame) != PJ_SUCCESS) 404 404 { 405 405 rc = -120; … … 407 407 } 408 408 } else { 409 if ( codec->op->recover(codec, samples_per_frame*2,410 &out_frame) != PJ_SUCCESS)409 if (pjmedia_codec_recover(codec, samples_per_frame*2, 410 &out_frame) != PJ_SUCCESS) 411 411 { 412 412 rc = -125; … … 484 484 485 485 if (codec) { 486 codec->op->close(codec);486 pjmedia_codec_close(codec); 487 487 pjmedia_codec_mgr_dealloc_codec(mgr, codec); 488 488 } -
pjproject/branches/projects/2.0-dev/pjmedia/src/test/mips_test.c
r3392 r3663 693 693 out_frame.buf = cp->pkt; 694 694 out_frame.size = sizeof(cp->pkt); 695 status = cp->codec->op->encode(cp->codec, frame, sizeof(cp->pkt),696 695 status = pjmedia_codec_encode(cp->codec, frame, sizeof(cp->pkt), 696 &out_frame); 697 697 pj_assert(status == PJ_SUCCESS); 698 698 … … 702 702 unsigned i; 703 703 704 status = cp->codec->op->parse(cp->codec, out_frame.buf,705 706 704 status = pjmedia_codec_parse(cp->codec, out_frame.buf, 705 out_frame.size, &out_frame.timestamp, 706 &frame_cnt, parsed_frm); 707 707 pj_assert(status == PJ_SUCCESS); 708 708 … … 710 710 pcm_frm.buf = cp->pcm; 711 711 pcm_frm.size = sizeof(cp->pkt); 712 status = cp->codec->op->decode(cp->codec, &parsed_frm[i],713 712 status = pjmedia_codec_decode(cp->codec, &parsed_frm[i], 713 sizeof(cp->pcm), &pcm_frm); 714 714 pj_assert(status == PJ_SUCCESS); 715 715 } … … 723 723 struct codec_port *cp = (struct codec_port*)this_port; 724 724 725 cp->codec->op->close(cp->codec);725 pjmedia_codec_close(cp->codec); 726 726 pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt), 727 727 cp->codec); … … 783 783 return NULL; 784 784 785 status = (*cp->codec->op->init)(cp->codec, pool);785 status = pjmedia_codec_init(cp->codec, pool); 786 786 if (status != PJ_SUCCESS) 787 787 return NULL; 788 788 789 status = cp->codec->op->open(cp->codec, &codec_param);789 status = pjmedia_codec_open(cp->codec, &codec_param); 790 790 if (status != PJ_SUCCESS) 791 791 return NULL; -
pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c
r3622 r3663 41 41 ++event->proc_cnt; 42 42 43 status = codec->op->get_param(codec, &codec_param);43 status = pjmedia_vid_codec_get_param(codec, &codec_param); 44 44 if (status != PJ_SUCCESS) 45 45 return status; … … 70 70 enc_frame.size = port_data->enc_buf_size; 71 71 72 status = codec->op->encode(codec, frame, enc_frame.size, &enc_frame); 72 status = pjmedia_vid_codec_encode(codec, frame, enc_frame.size, 73 &enc_frame); 73 74 if (status != PJ_SUCCESS) goto on_error; 74 75 … … 83 84 pj_size_t payload_len; 84 85 85 status = codec->op->packetize(codec, 86 (pj_uint8_t*)enc_frame.buf, 87 enc_frame.size, &pos, 88 (const pj_uint8_t**)&payload, 89 &payload_len); 86 status = pjmedia_vid_codec_packetize( 87 codec, 88 (pj_uint8_t*)enc_frame.buf, 89 enc_frame.size, &pos, 90 (const pj_uint8_t**)&payload, 91 &payload_len); 90 92 if (status == PJ_ENOTSUP) 91 93 break; … … 93 95 goto on_error; 94 96 95 status = codec->op->unpacketize(codec, payload, payload_len, 97 status = pjmedia_vid_codec_unpacketize( 98 codec, payload, payload_len, 96 99 port_data->pack_buf, 97 100 port_data->pack_buf_size, … … 113 116 #endif 114 117 115 status = codec->op->decode(codec, &enc_frame, frame->size, frame); 118 status = pjmedia_vid_codec_decode(codec, &enc_frame, 119 frame->size, frame); 116 120 if (status != PJ_SUCCESS) goto on_error; 117 121 } … … 277 281 } 278 282 279 status = codec->op->init(codec, pool);283 status = pjmedia_vid_codec_init(codec, pool); 280 284 if (status != PJ_SUCCESS) { 281 285 rc = 251; goto on_return; 282 286 } 283 287 284 status = codec->op->open(codec, &codec_param);288 status = pjmedia_vid_codec_open(codec, &codec_param); 285 289 if (status != PJ_SUCCESS) { 286 290 rc = 252; goto on_return; … … 415 419 } 416 420 if (codec) { 417 codec->op->close(codec);421 pjmedia_vid_codec_close(codec); 418 422 pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec); 419 423 } -
pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c
r3658 r3663 151 151 if (status != PJ_SUCCESS) goto on_error; 152 152 153 status = codec->op->decode(codec, frame, frame->size, &enc_frame);153 status = pjmedia_vid_codec_decode(codec, frame, frame->size, &enc_frame); 154 154 if (status != PJ_SUCCESS) goto on_error; 155 155 … … 164 164 if (status != PJ_SUCCESS) goto on_error; 165 165 166 status = codec->op->decode(codec, &enc_frame, frame->size, frame);166 status = pjmedia_vid_codec_decode(codec, &enc_frame, frame->size, frame); 167 167 if (status != PJ_SUCCESS) goto on_error; 168 168 … … 283 283 } 284 284 285 status = codec->op->init(codec, pool);285 status = pjmedia_vid_codec_init(codec, pool); 286 286 if (status != PJ_SUCCESS) { 287 287 rc = 251; goto on_return; … … 290 290 pjmedia_format_copy(&codec_param.dec_fmt, ¶m.vidparam.fmt); 291 291 292 status = codec->op->open(codec, &codec_param);292 status = pjmedia_vid_codec_open(codec, &codec_param); 293 293 if (status != PJ_SUCCESS) { 294 294 rc = 252; goto on_return; … … 439 439 pjmedia_port_destroy(vid_port); 440 440 if (codec) { 441 codec->op->close(codec);441 pjmedia_vid_codec_close(codec); 442 442 pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec); 443 443 } -
pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/encdec.c
r3661 r3663 138 138 /* Alloc codec */ 139 139 CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) ); 140 CHECK( codec->op->init(codec, pool) );141 CHECK( codec->op->open(codec, ¶m) );140 CHECK( pjmedia_codec_init(codec, pool) ); 141 CHECK( pjmedia_codec_open(codec, ¶m) ); 142 142 143 143 for (;;) { … … 163 163 frm_bit.buf = bitstream; 164 164 frm_bit.size = sizeof(bitstream); 165 CHECK(codec->op->encode(codec, &frm_pcm, sizeof(bitstream), &frm_bit)); 165 CHECK(pjmedia_codec_encode(codec, &frm_pcm, sizeof(bitstream), 166 &frm_bit)); 166 167 167 168 /* On DTX, write zero frame to wavout to maintain duration */ … … 181 182 ts.u64 = 0; 182 183 cnt = PJ_ARRAY_SIZE(frames); 183 CHECK( codec->op->parse(codec, bitstream, frm_bit.size, &ts, &cnt,184 frames) );184 CHECK( pjmedia_codec_parse(codec, bitstream, frm_bit.size, &ts, &cnt, 185 frames) ); 185 186 CHECK( (cnt==1 ? PJ_SUCCESS : -1) ); 186 187 … … 191 192 if ((pj_rand() % 100) < (int)lost_pct) { 192 193 /* Simulate loss */ 193 CHECK( codec->op->recover(codec, sizeof(pcmbuf), &out_frm) );194 CHECK( pjmedia_codec_recover(codec, sizeof(pcmbuf), &out_frm) ); 194 195 TRACE_((THIS_FILE, "%d.%03d Packet lost", T)); 195 196 } else { 196 197 /* Decode */ 197 CHECK( codec->op->decode(codec, &frames[0], sizeof(pcmbuf),198 CHECK( pjmedia_codec_decode(codec, &frames[0], sizeof(pcmbuf), 198 199 &out_frm) ); 199 200 } … … 211 212 212 213 /* Close codec */ 213 codec->op->close(codec);214 pjmedia_codec_close(codec); 214 215 pjmedia_codec_mgr_dealloc_codec(cm, codec); 215 216 -
pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/pcaputil.c
r3661 r3663 99 99 if (app.codec) { 100 100 pjmedia_codec_mgr *cmgr; 101 app.codec->op->close(app.codec);101 pjmedia_codec_close(app.codec); 102 102 cmgr = pjmedia_endpt_get_codec_mgr(app.mept); 103 103 pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec); … … 260 260 /* Alloc and init codec */ 261 261 T( pjmedia_codec_mgr_alloc_codec(cmgr, ci, &app.codec) ); 262 T( app.codec->op->init(app.codec, app.pool) );263 T( app.codec->op->open(app.codec, ¶m) );262 T( pjmedia_codec_init(app.codec, app.pool) ); 263 T( pjmedia_codec_open(app.codec, ¶m) ); 264 264 265 265 /* Open WAV file */ … … 285 285 ts.u64 = 0; 286 286 frame_cnt = PJ_ARRAY_SIZE(frames); 287 T( app.codec->op->parse(app.codec, pkt0.payload, pkt0.payload_len,287 T( pjmedia_codec_parse(app.codec, pkt0.payload, pkt0.payload_len, 288 288 &ts, &frame_cnt, frames) ); 289 289 … … 296 296 pcm_frame.size = samples_per_frame * 2; 297 297 298 T( app.codec->op->decode(app.codec, &frames[i], pcm_frame.size,298 T( pjmedia_codec_decode(app.codec, &frames[i], pcm_frame.size, 299 299 &pcm_frame) ); 300 300 T( pjmedia_port_put_frame(app.wav, &pcm_frame) ); … … 315 315 316 316 if (app.codec->op->recover) { 317 T( app.codec->op->recover(app.codec, pcm_frame.size,318 317 T( pjmedia_codec_recover(app.codec, pcm_frame.size, 318 &pcm_frame) ); 319 319 } else { 320 320 pj_bzero(pcm_frame.buf, pcm_frame.size);
Note: See TracChangeset
for help on using the changeset viewer.