Changeset 3663 for pjproject


Ignore:
Timestamp:
Jul 15, 2011 10:19:59 AM (13 years ago)
Author:
nanang
Message:

Fix #1295: Added thin wrapper for audio and video codec operations.

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  
    2828 
    2929#include <pjmedia/port.h> 
     30#include <pj/errno.h> 
    3031#include <pj/list.h> 
    3132#include <pj/pool.h> 
     
    324325     * Initialize codec using the specified attribute. 
    325326     * 
     327     * Application should call #pjmedia_codec_init() instead of  
     328     * calling this function directly. 
     329     * 
    326330     * @param codec     The codec instance. 
    327331     * @param pool      Pool to use when the codec needs to allocate 
     
    339343     * encoder ptime is different than decoder ptime). 
    340344     * 
     345     * Application should call #pjmedia_codec_open() instead of  
     346     * calling this function directly. 
     347     * 
    341348     * @param codec     The codec instance. 
    342349     * @param param     Codec initialization parameter. 
     
    350357     * Close and shutdown codec, releasing all resources allocated by 
    351358     * this codec, if any. 
     359     * 
     360     * Application should call #pjmedia_codec_close() instead of  
     361     * calling this function directly. 
    352362     * 
    353363     * @param codec     The codec instance. 
     
    366376     * changing VAD setting to succeed. 
    367377     * 
     378     * Application should call #pjmedia_codec_modify() instead of  
     379     * calling this function directly. 
     380     * 
    368381     * @param codec     The codec instance. 
    369382     * @param param     The new codec parameter. 
     
    379392     * have ptime that is equal to basic frame ptime (i.e. the value of 
    380393     * info.frm_ptime in #pjmedia_codec_param). 
     394     * 
     395     * Application should call #pjmedia_codec_parse() instead of  
     396     * calling this function directly. 
    381397     * 
    382398     * @param codec     The codec instance 
     
    404420     * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param). 
    405421     * 
     422     * Application should call #pjmedia_codec_encode() instead of  
     423     * calling this function directly. 
     424     * 
    406425     * @param codec     The codec instance. 
    407426     * @param input     The input frame. 
     
    423442     * frames before decoding each frame. 
    424443     * 
     444     * Application should call #pjmedia_codec_decode() instead of  
     445     * calling this function directly. 
     446     * 
    425447     * @param codec     The codec instance. 
    426448     * @param input     The input frame. 
     
    437459    /** 
    438460     * Instruct the codec to recover a missing frame. 
     461     * 
     462     * Application should call #pjmedia_codec_recover() instead of  
     463     * calling this function directly. 
    439464     * 
    440465     * @param codec     The codec instance. 
     
    913938 
    914939 
     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 */ 
     948PJ_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 */ 
     966PJ_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 */ 
     981PJ_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 */ 
     1001PJ_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 */ 
     1026PJ_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 */ 
     1050PJ_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 */ 
     1074PJ_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 */ 
     1094PJ_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} 
    9151103 
    9161104 
  • pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h

    r3640 r3663  
    114114     * Initialize codec using the specified attribute. 
    115115     * 
     116     * Application should call #pjmedia_vid_codec_init() instead of  
     117     * calling this function directly. 
     118     * 
    116119     * @param codec     The codec instance. 
    117120     * @param pool      Pool to use when the codec needs to allocate 
     
    130133     * preferences via SDP fmtp). 
    131134     * 
     135     * Application should call #pjmedia_vid_codec_open() instead of  
     136     * calling this function directly. 
     137     * 
    132138     * @param codec     The codec instance. 
    133139     * @param param     Codec initialization parameter. 
     
    141147     * Close and shutdown codec, releasing all resources allocated by 
    142148     * this codec, if any. 
     149     * 
     150     * Application should call #pjmedia_vid_codec_close() instead of  
     151     * calling this function directly. 
    143152     * 
    144153     * @param codec     The codec instance. 
     
    154163     * non-PJ_SUCCESS, and the original parameters will not be changed. 
    155164     * 
     165     * Application should call #pjmedia_vid_codec_modify() instead of  
     166     * calling this function directly. 
     167     * 
    156168     * @param codec     The codec instance. 
    157169     * @param param     The new codec parameter. 
     
    164176    /**  
    165177     * 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. 
    166181     * 
    167182     * @param codec     The codec instance. 
     
    181196     * performance reason, the packetization will be done in-place, so the 
    182197     * original bitstream may be modified by this function. 
     198     * 
     199     * Application should call #pjmedia_vid_codec_packetize() instead of  
     200     * calling this function directly. 
    183201     * 
    184202     * @param codec     The codec instance 
     
    212230     * set to NULL, as the packetizer need to update its internal state. 
    213231     * 
     232     * Application should call #pjmedia_vid_codec_unpacketize() instead of  
     233     * calling this function directly. 
     234     * 
    214235     * @param codec     The codec instance 
    215236     * @param pkt       The input packet. 
     
    236257     * in opening the codec. 
    237258     * 
     259     * Application should call #pjmedia_vid_codec_encode() instead of  
     260     * calling this function directly. 
     261     * 
    238262     * @param codec     The codec instance. 
    239263     * @param input     The input frame. 
     
    257281     * using #get_param(). 
    258282     * 
     283     * Application should call #pjmedia_vid_codec_decode() instead of  
     284     * calling this function directly. 
     285     * 
    259286     * @param codec     The codec instance. 
    260287     * @param input     The input frame. 
     
    271298    /** 
    272299     * Instruct the codec to recover a missing frame. 
     300     * 
     301     * Application should call #pjmedia_vid_codec_recover() instead of  
     302     * calling this function directly. 
    273303     * 
    274304     * @param codec     The codec instance. 
     
    433463 * @param sig       Codec's object signature (see signatures.h) 
    434464 */ 
    435 PJ_DECL(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec, 
    436                                      pjmedia_obj_sig sig); 
     465PJ_DECL(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec, 
     466                                      pjmedia_obj_sig sig); 
    437467 
    438468/** 
     
    700730 
    701731 
     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 */ 
     741PJ_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 */ 
     760PJ_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 */ 
     776PJ_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 */ 
     793PJ_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 */ 
     809PJ_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 */ 
     837PJ_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 */ 
     874PJ_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 */ 
     899PJ_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 */ 
     925PJ_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 */ 
     945PJ_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} 
    702955 
    703956 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c

    r3640 r3663  
    887887        goto on_error; 
    888888    } 
    889     pjmedia_vid_codec_init(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG); 
     889    pjmedia_vid_codec_reset(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG); 
    890890    codec->op = &ffmpeg_op; 
    891891    codec->factory = factory; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stream.c

    r3640 r3663  
    516516                frame_out.buf = p_out_samp + samples_count; 
    517517                frame_out.size = frame->size - samples_count*2; 
    518                 status = (*stream->codec->op->recover)(stream->codec, 
    519                                                        frame_out.size, 
    520                                                        &frame_out); 
     518                status = pjmedia_codec_recover(stream->codec, 
     519                                               frame_out.size, 
     520                                               &frame_out); 
    521521 
    522522                ++stream->plc_cnt; 
     
    565565                        frame_out.buf = p_out_samp + samples_count; 
    566566                        frame_out.size = frame->size - samples_count*2; 
    567                         status = (*stream->codec->op->recover)(stream->codec, 
    568                                                                frame_out.size, 
    569                                                                &frame_out); 
     567                        status = pjmedia_codec_recover(stream->codec, 
     568                                                       frame_out.size, 
     569                                                       &frame_out); 
    570570                        if (status != PJ_SUCCESS) 
    571571                            break; 
     
    620620                    frame_out.buf = p_out_samp + samples_count; 
    621621                    frame_out.size = frame->size - samples_count*2; 
    622                     status = (*stream->codec->op->recover)(stream->codec, 
    623                                                            frame_out.size, 
    624                                                            &frame_out); 
     622                    status = pjmedia_codec_recover(stream->codec, 
     623                                                   frame_out.size, 
     624                                                   &frame_out); 
    625625                    if (status != PJ_SUCCESS) 
    626626                        break; 
     
    671671            frame_out.buf = p_out_samp + samples_count; 
    672672            frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE; 
    673             status = stream->codec->op->decode( stream->codec, &frame_in, 
    674                                                 frame_out.size, &frame_out); 
     673            status = pjmedia_codec_decode( stream->codec, &frame_in, 
     674                                           frame_out.size, &frame_out); 
    675675            if (status != 0) { 
    676676                LOGERR_((port->info.name.ptr, "codec decode() error",  
     
    775775            frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO; 
    776776 
    777             status = stream->codec->op->decode( stream->codec, &frame_in, 
    778                                                 0, frame); 
     777            status = pjmedia_codec_decode( stream->codec, &frame_in, 
     778                                           0, frame); 
    779779            if (status != PJ_SUCCESS) { 
    780780                LOGERR_((port->info.name.ptr, "codec decode() error",  
     
    802802            status = PJ_SUCCESS; 
    803803            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); 
    806805            } 
    807806             
     
    12491248         
    12501249        /* Encode! */ 
    1251         status = stream->codec->op->encode( stream->codec, &silence_frame, 
    1252                                             channel->out_pkt_size -  
    1253                                             sizeof(pjmedia_rtp_hdr), 
    1254                                             &frame_out); 
     1250        status = pjmedia_codec_encode( stream->codec, &silence_frame, 
     1251                                       channel->out_pkt_size -  
     1252                                       sizeof(pjmedia_rtp_hdr), 
     1253                                       &frame_out); 
    12551254        if (status != PJ_SUCCESS) { 
    12561255            LOGERR_((stream->port.info.name.ptr,  
     
    12731272    { 
    12741273        /* Encode! */ 
    1275         status = stream->codec->op->encode( stream->codec, frame,  
    1276                                             channel->out_pkt_size -  
    1277                                             sizeof(pjmedia_rtp_hdr), 
    1278                                             &frame_out); 
     1274        status = pjmedia_codec_encode( stream->codec, frame,  
     1275                                       channel->out_pkt_size -  
     1276                                       sizeof(pjmedia_rtp_hdr), 
     1277                                       &frame_out); 
    12791278        if (status != PJ_SUCCESS) { 
    12801279            LOGERR_((stream->port.info.name.ptr,  
     
    14261425    { 
    14271426        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); 
    14291428        PJ_LOG(4,(stream->port.info.name.ptr,"VAD re-enabled")); 
    14301429    } 
     
    16921691 
    16931692        /* 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); 
    17001695        if (status != PJ_SUCCESS) { 
    17011696            LOGERR_((stream->port.info.name.ptr,  
     
    20592054 
    20602055    /* Open the codec. */ 
    2061     status = stream->codec->op->open(stream->codec, &stream->codec_param); 
     2056    status = pjmedia_codec_open(stream->codec, &stream->codec_param); 
    20622057    if (status != PJ_SUCCESS) 
    20632058        goto err_cleanup; 
     
    21382133        stream->codec_param.setting.vad = 0; 
    21392134        stream->ts_vad_disabled = 0; 
    2140         stream->codec->op->modify(stream->codec, &stream->codec_param); 
     2135        pjmedia_codec_modify(stream->codec, &stream->codec_param); 
    21412136        PJ_LOG(4,(stream->port.info.name.ptr,"VAD temporarily disabled")); 
    21422137    } 
     
    24412436 
    24422437    if (stream->codec) { 
    2443         stream->codec->op->close(stream->codec); 
     2438        pjmedia_codec_close(stream->codec); 
    24442439        pjmedia_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec); 
    24452440        stream->codec = NULL; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c

    r3640 r3663  
    7070 * Initialize pjmedia_vid_codec structure with default values. 
    7171 */ 
    72 PJ_DEF(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec, 
     72PJ_DEF(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec, 
    7373                                    pjmedia_obj_sig sig) 
    7474{ 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c

    r3641 r3663  
    336336        case PJMEDIA_EVENT_FMT_CHANGED: 
    337337            /* 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); 
    339339 
    340340            /* Update decoding channel port info */ 
     
    764764 
    765765    /* Encode! */ 
    766     status = (*stream->codec->op->encode)(stream->codec, frame,  
    767                                           channel->buf_size -  
    768                                           sizeof(pjmedia_rtp_hdr), 
    769                                           &frame_out); 
     766    status = pjmedia_vid_codec_encode(stream->codec, frame,  
     767                                      channel->buf_size -  
     768                                      sizeof(pjmedia_rtp_hdr), 
     769                                      &frame_out); 
    770770    if (status != PJ_SUCCESS) { 
    771771        LOGERR_((channel->port.info.name.ptr,  
     
    785785 
    786786        /* 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); 
    794793        if (status != PJ_SUCCESS) { 
    795794            LOGERR_((channel->port.info.name.ptr,  
     
    933932                } 
    934933 
    935                 status = (*stream->codec->op->unpacketize)( 
     934                status = pjmedia_vid_codec_unpacketize( 
    936935                                                stream->codec, 
    937936                                                p, psize, 
     
    966965    frame_in.timestamp.u64 = last_ts; 
    967966 
    968     status = stream->codec->op->decode(stream->codec, &frame_in, 
    969                                        frame->size, frame); 
     967    status = pjmedia_vid_codec_decode(stream->codec, &frame_in, 
     968                                      frame->size, frame); 
    970969    if (status != PJ_SUCCESS) { 
    971970        LOGERR_((port->info.name.ptr, "codec decode() error",  
     
    12401239 
    12411240    /* Init and open the codec. */ 
    1242     status = stream->codec->op->init(stream->codec, pool); 
     1241    status = pjmedia_vid_codec_init(stream->codec, pool); 
    12431242    if (status != PJ_SUCCESS) 
    12441243        return status; 
    1245     status = stream->codec->op->open(stream->codec, info->codec_param); 
     1244    status = pjmedia_vid_codec_open(stream->codec, info->codec_param); 
    12461245    if (status != PJ_SUCCESS) 
    12471246        return status; 
     
    14461445    /* Free codec. */ 
    14471446    if (stream->codec) { 
    1448         stream->codec->op->close(stream->codec); 
     1447        pjmedia_vid_codec_close(stream->codec); 
    14491448        pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec); 
    14501449        stream->codec = NULL; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/codec_vectors.c

    r2675 r3663  
    7474    codec_param.setting.vad = 0; 
    7575 
    76     status = codec->op->init(codec, pool); 
     76    status = pjmedia_codec_init(codec, pool); 
    7777    if (status != PJ_SUCCESS) { 
    7878        rc = -60; 
     
    8080    } 
    8181 
    82     status = codec->op->open(codec, &codec_param); 
     82    status = pjmedia_codec_open(codec, &codec_param); 
    8383    if (status != PJ_SUCCESS) { 
    8484        rc = -70; 
     
    118118 
    119119        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, 
    121121                                   &out_frame); 
    122122        if (status != PJ_SUCCESS) { 
     
    189189 
    190190    if (codec) { 
    191         codec->op->close(codec); 
     191        pjmedia_codec_close(codec); 
    192192        pjmedia_codec_mgr_dealloc_codec(mgr, codec); 
    193193    } 
     
    327327    codec_param.setting.vad = 0; 
    328328 
    329     status = codec->op->init(codec, pool); 
     329    status = pjmedia_codec_init(codec, pool); 
    330330    if (status != PJ_SUCCESS) { 
    331331        rc = -60; 
     
    333333    } 
    334334 
    335     status = codec->op->open(codec, &codec_param); 
     335    status = pjmedia_codec_open(codec, &codec_param); 
    336336    if (status != PJ_SUCCESS) { 
    337337        rc = -70; 
     
    388388        if (has_frame) { 
    389389            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)  
    392392            { 
    393393                rc = -100; 
     
    400400            } 
    401401 
    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)  
    404404            { 
    405405                rc = -120; 
     
    407407            } 
    408408        } 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) 
    411411            { 
    412412                rc = -125; 
     
    484484 
    485485    if (codec) { 
    486         codec->op->close(codec); 
     486        pjmedia_codec_close(codec); 
    487487        pjmedia_codec_mgr_dealloc_codec(mgr, codec); 
    488488    } 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/mips_test.c

    r3392 r3663  
    693693    out_frame.buf = cp->pkt; 
    694694    out_frame.size = sizeof(cp->pkt); 
    695     status = cp->codec->op->encode(cp->codec, frame, sizeof(cp->pkt), 
    696                                    &out_frame); 
     695    status = pjmedia_codec_encode(cp->codec, frame, sizeof(cp->pkt), 
     696                                  &out_frame); 
    697697    pj_assert(status == PJ_SUCCESS); 
    698698 
     
    702702        unsigned i; 
    703703 
    704         status = cp->codec->op->parse(cp->codec, out_frame.buf,  
    705                                       out_frame.size, &out_frame.timestamp, 
    706                                       &frame_cnt, parsed_frm); 
     704        status = pjmedia_codec_parse(cp->codec, out_frame.buf,  
     705                                     out_frame.size, &out_frame.timestamp, 
     706                                     &frame_cnt, parsed_frm); 
    707707        pj_assert(status == PJ_SUCCESS); 
    708708         
     
    710710            pcm_frm.buf = cp->pcm; 
    711711            pcm_frm.size = sizeof(cp->pkt); 
    712             status = cp->codec->op->decode(cp->codec, &parsed_frm[i],  
    713                                            sizeof(cp->pcm), &pcm_frm); 
     712            status = pjmedia_codec_decode(cp->codec, &parsed_frm[i],  
     713                                          sizeof(cp->pcm), &pcm_frm); 
    714714            pj_assert(status == PJ_SUCCESS); 
    715715        } 
     
    723723    struct codec_port *cp = (struct codec_port*)this_port; 
    724724 
    725     cp->codec->op->close(cp->codec); 
     725    pjmedia_codec_close(cp->codec); 
    726726    pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt), 
    727727                                    cp->codec); 
     
    783783        return NULL; 
    784784 
    785     status = (*cp->codec->op->init)(cp->codec, pool); 
     785    status = pjmedia_codec_init(cp->codec, pool); 
    786786    if (status != PJ_SUCCESS) 
    787787        return NULL; 
    788788 
    789     status = cp->codec->op->open(cp->codec, &codec_param); 
     789    status = pjmedia_codec_open(cp->codec, &codec_param); 
    790790    if (status != PJ_SUCCESS) 
    791791        return NULL; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c

    r3622 r3663  
    4141        ++event->proc_cnt; 
    4242 
    43         status = codec->op->get_param(codec, &codec_param); 
     43        status = pjmedia_vid_codec_get_param(codec, &codec_param); 
    4444        if (status != PJ_SUCCESS) 
    4545            return status; 
     
    7070        enc_frame.size = port_data->enc_buf_size; 
    7171 
    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); 
    7374        if (status != PJ_SUCCESS) goto on_error; 
    7475 
     
    8384                pj_size_t payload_len; 
    8485 
    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); 
    9092                if (status == PJ_ENOTSUP) 
    9193                    break; 
     
    9395                    goto on_error; 
    9496 
    95                 status = codec->op->unpacketize(codec, payload, payload_len, 
     97                status = pjmedia_vid_codec_unpacketize( 
     98                                                codec, payload, payload_len, 
    9699                                                port_data->pack_buf, 
    97100                                                port_data->pack_buf_size, 
     
    113116#endif 
    114117 
    115         status = codec->op->decode(codec, &enc_frame, frame->size, frame); 
     118        status = pjmedia_vid_codec_decode(codec, &enc_frame, 
     119                                          frame->size, frame); 
    116120        if (status != PJ_SUCCESS) goto on_error; 
    117121    } 
     
    277281        } 
    278282 
    279         status = codec->op->init(codec, pool); 
     283        status = pjmedia_vid_codec_init(codec, pool); 
    280284        if (status != PJ_SUCCESS) { 
    281285            rc = 251; goto on_return; 
    282286        } 
    283287 
    284         status = codec->op->open(codec, &codec_param); 
     288        status = pjmedia_vid_codec_open(codec, &codec_param); 
    285289        if (status != PJ_SUCCESS) { 
    286290            rc = 252; goto on_return; 
     
    415419    } 
    416420    if (codec) { 
    417         codec->op->close(codec); 
     421        pjmedia_vid_codec_close(codec); 
    418422        pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec); 
    419423    } 
  • pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c

    r3658 r3663  
    151151        if (status != PJ_SUCCESS) goto on_error; 
    152152         
    153         status = codec->op->decode(codec, frame, frame->size, &enc_frame); 
     153        status = pjmedia_vid_codec_decode(codec, frame, frame->size, &enc_frame); 
    154154        if (status != PJ_SUCCESS) goto on_error; 
    155155         
     
    164164    if (status != PJ_SUCCESS) goto on_error; 
    165165     
    166     status = codec->op->decode(codec, &enc_frame, frame->size, frame); 
     166    status = pjmedia_vid_codec_decode(codec, &enc_frame, frame->size, frame); 
    167167    if (status != PJ_SUCCESS) goto on_error; 
    168168     
     
    283283            } 
    284284             
    285             status = codec->op->init(codec, pool); 
     285            status = pjmedia_vid_codec_init(codec, pool); 
    286286            if (status != PJ_SUCCESS) { 
    287287                rc = 251; goto on_return; 
     
    290290            pjmedia_format_copy(&codec_param.dec_fmt, &param.vidparam.fmt); 
    291291             
    292             status = codec->op->open(codec, &codec_param); 
     292            status = pjmedia_vid_codec_open(codec, &codec_param); 
    293293            if (status != PJ_SUCCESS) { 
    294294                rc = 252; goto on_return; 
     
    439439        pjmedia_port_destroy(vid_port); 
    440440    if (codec) { 
    441         codec->op->close(codec); 
     441        pjmedia_vid_codec_close(codec); 
    442442        pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec); 
    443443    } 
  • pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/encdec.c

    r3661 r3663  
    138138    /* Alloc codec */ 
    139139    CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) ); 
    140     CHECK( codec->op->init(codec, pool) ); 
    141     CHECK( codec->op->open(codec, &param) ); 
     140    CHECK( pjmedia_codec_init(codec, pool) ); 
     141    CHECK( pjmedia_codec_open(codec, &param) ); 
    142142     
    143143    for (;;) { 
     
    163163        frm_bit.buf = bitstream; 
    164164        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)); 
    166167 
    167168        /* On DTX, write zero frame to wavout to maintain duration */ 
     
    181182        ts.u64 = 0; 
    182183        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) ); 
    185186        CHECK( (cnt==1 ? PJ_SUCCESS : -1) ); 
    186187 
     
    191192        if ((pj_rand() % 100) < (int)lost_pct) { 
    192193            /* Simulate loss */ 
    193             CHECK( codec->op->recover(codec, sizeof(pcmbuf), &out_frm) ); 
     194            CHECK( pjmedia_codec_recover(codec, sizeof(pcmbuf), &out_frm) ); 
    194195            TRACE_((THIS_FILE, "%d.%03d Packet lost", T)); 
    195196        } else { 
    196197            /* Decode */ 
    197             CHECK( codec->op->decode(codec, &frames[0], sizeof(pcmbuf),  
     198            CHECK( pjmedia_codec_decode(codec, &frames[0], sizeof(pcmbuf),  
    198199                                     &out_frm) ); 
    199200        } 
     
    211212 
    212213    /* Close codec */ 
    213     codec->op->close(codec); 
     214    pjmedia_codec_close(codec); 
    214215    pjmedia_codec_mgr_dealloc_codec(cm, codec); 
    215216 
  • pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/pcaputil.c

    r3661 r3663  
    9999    if (app.codec) { 
    100100        pjmedia_codec_mgr *cmgr; 
    101         app.codec->op->close(app.codec); 
     101        pjmedia_codec_close(app.codec); 
    102102        cmgr = pjmedia_endpt_get_codec_mgr(app.mept); 
    103103        pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec); 
     
    260260    /* Alloc and init codec */ 
    261261    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, &param) ); 
     262    T( pjmedia_codec_init(app.codec, app.pool) ); 
     263    T( pjmedia_codec_open(app.codec, &param) ); 
    264264 
    265265    /* Open WAV file */ 
     
    285285        ts.u64 = 0; 
    286286        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,  
    288288                                &ts, &frame_cnt, frames) ); 
    289289 
     
    296296            pcm_frame.size = samples_per_frame * 2; 
    297297 
    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,  
    299299                                     &pcm_frame) ); 
    300300            T( pjmedia_port_put_frame(app.wav, &pcm_frame) ); 
     
    315315 
    316316            if (app.codec->op->recover) { 
    317                 T( app.codec->op->recover(app.codec, pcm_frame.size,  
    318                                           &pcm_frame) ); 
     317                T( pjmedia_codec_recover(app.codec, pcm_frame.size,  
     318                                         &pcm_frame) ); 
    319319            } else { 
    320320                pj_bzero(pcm_frame.buf, pcm_frame.size); 
Note: See TracChangeset for help on using the changeset viewer.