Index: pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/codec.h
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/codec.h	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/codec.h	(revision 3663)
@@ -28,4 +28,5 @@
 
 #include <pjmedia/port.h>
+#include <pj/errno.h>
 #include <pj/list.h>
 #include <pj/pool.h>
@@ -324,4 +325,7 @@
      * Initialize codec using the specified attribute.
      *
+     * Application should call #pjmedia_codec_init() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param pool	Pool to use when the codec needs to allocate
@@ -339,4 +343,7 @@
      * encoder ptime is different than decoder ptime).
      *
+     * Application should call #pjmedia_codec_open() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param param	Codec initialization parameter.
@@ -350,4 +357,7 @@
      * Close and shutdown codec, releasing all resources allocated by
      * this codec, if any.
+     *
+     * Application should call #pjmedia_codec_close() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance.
@@ -366,4 +376,7 @@
      * changing VAD setting to succeed.
      *
+     * Application should call #pjmedia_codec_modify() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param param	The new codec parameter.
@@ -379,4 +392,7 @@
      * have ptime that is equal to basic frame ptime (i.e. the value of
      * info.frm_ptime in #pjmedia_codec_param).
+     *
+     * Application should call #pjmedia_codec_parse() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance
@@ -404,4 +420,7 @@
      * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
      *
+     * Application should call #pjmedia_codec_encode() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param input	The input frame.
@@ -423,4 +442,7 @@
      * frames before decoding each frame.
      *
+     * Application should call #pjmedia_codec_decode() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param input	The input frame.
@@ -437,4 +459,7 @@
     /**
      * Instruct the codec to recover a missing frame.
+     *
+     * Application should call #pjmedia_codec_recover() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance.
@@ -913,4 +938,167 @@
 
 
+/** 
+ * Initialize codec using the specified attribute.
+ *
+ * @param codec	    The codec instance.
+ * @param pool	    Pool to use when the codec needs to allocate some memory.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_init( pjmedia_codec *codec, 
+					   pj_pool_t *pool )
+{
+    return (*codec->op->init)(codec, pool);
+}
+
+
+/** 
+ * Open the codec and initialize with the specified parameter.
+ * Upon successful initialization, the codec may modify the parameter
+ * and fills in the unspecified values (such as enc_ptime, when
+ * encoder ptime is different than decoder ptime).
+ *
+ * @param codec	    The codec instance.
+ * @param param	    Codec initialization parameter.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_open( pjmedia_codec *codec, 
+					   pjmedia_codec_param *param )
+{
+    return (*codec->op->open)(codec, param);
+}
+
+
+/** 
+ * Close and shutdown codec, releasing all resources allocated by
+ * this codec, if any.
+ *
+ * @param codec	    The codec instance.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_close( pjmedia_codec *codec )
+{
+    return (*codec->op->close)(codec);
+}
+
+
+/** 
+ * Modify the codec parameter after the codec is open. 
+ * Note that not all codec parameters can be modified during run-time. 
+ * When the parameter cannot be changed, this function will return 
+ * non-PJ_SUCCESS, and the original parameters will not be changed.
+ *
+ * Application can expect changing trivial codec settings such as
+ * changing VAD setting to succeed.
+ *
+ * @param codec	    The codec instance.
+ * @param param	    The new codec parameter.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_modify(pjmedia_codec *codec, 
+					    const pjmedia_codec_param *param)
+{
+    return (*codec->op->modify)(codec, param);
+}
+
+
+/**
+ * Instruct the codec to inspect the specified payload/packet and
+ * split the packet into individual base frames. Each output frames will
+ * have ptime that is equal to basic frame ptime (i.e. the value of
+ * info.frm_ptime in #pjmedia_codec_param).
+ *
+ * @param codec	    The codec instance
+ * @param pkt	    The input packet.
+ * @param pkt_size  Size of the packet.
+ * @param timestamp The timestamp of the first sample in the packet.
+ * @param frame_cnt On input, specifies the maximum number of frames
+ *		    in the array. On output, the codec must fill
+ *		    with number of frames detected in the packet.
+ * @param frames    On output, specifies the frames that have been
+ *		    detected in the packet.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_parse( pjmedia_codec *codec,
+					    void *pkt,
+					    pj_size_t pkt_size,
+					    const pj_timestamp *timestamp,
+					    unsigned *frame_cnt,
+					    pjmedia_frame frames[] )
+{
+    return (*codec->op->parse)(codec, pkt, pkt_size, timestamp,
+			       frame_cnt, frames);
+}
+
+
+/** 
+ * Instruct the codec to encode the specified input frame. The input
+ * PCM samples MUST have ptime that is multiplication of base frame
+ * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
+ *
+ * @param codec		The codec instance.
+ * @param input		The input frame.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_encode( 
+					pjmedia_codec *codec, 
+					const struct pjmedia_frame *input,
+					unsigned out_size, 
+					struct pjmedia_frame *output )
+{
+    return (*codec->op->encode)(codec, input, out_size, output);
+}
+
+
+/** 
+ * Instruct the codec to decode the specified input frame. The input
+ * frame MUST have ptime that is exactly equal to base frame
+ * ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
+ * Application can achieve this by parsing the packet into base
+ * frames before decoding each frame.
+ *
+ * @param codec		The codec instance.
+ * @param input		The input frame.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_decode( 
+					pjmedia_codec *codec, 
+					const struct pjmedia_frame *input,
+					unsigned out_size, 
+					struct pjmedia_frame *output )
+{
+    return (*codec->op->decode)(codec, input, out_size, output);
+}
+
+
+/**
+ * Instruct the codec to recover a missing frame.
+ *
+ * @param codec		The codec instance.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame where generated signal
+ *			will be placed.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_codec_recover( pjmedia_codec *codec,
+					      unsigned out_size,
+					      struct pjmedia_frame *output )
+{
+    if (codec->op && codec->op->recover)
+	return (*codec->op->recover)(codec, out_size, output);
+    else
+	return PJ_ENOTSUP;
+}
 
 
Index: pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h	(revision 3663)
@@ -114,4 +114,7 @@
      * Initialize codec using the specified attribute.
      *
+     * Application should call #pjmedia_vid_codec_init() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param pool	Pool to use when the codec needs to allocate
@@ -130,4 +133,7 @@
      * preferences via SDP fmtp).
      *
+     * Application should call #pjmedia_vid_codec_open() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param param	Codec initialization parameter.
@@ -141,4 +147,7 @@
      * Close and shutdown codec, releasing all resources allocated by
      * this codec, if any.
+     *
+     * Application should call #pjmedia_vid_codec_close() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance.
@@ -154,4 +163,7 @@
      * non-PJ_SUCCESS, and the original parameters will not be changed.
      *
+     * Application should call #pjmedia_vid_codec_modify() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param param	The new codec parameter.
@@ -164,4 +176,7 @@
     /** 
      * Get the codec parameter after the codec is opened. 
+     *
+     * Application should call #pjmedia_vid_codec_get_param() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance.
@@ -181,4 +196,7 @@
      * performance reason, the packetization will be done in-place, so the
      * original bitstream may be modified by this function.
+     *
+     * Application should call #pjmedia_vid_codec_packetize() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance
@@ -212,4 +230,7 @@
      * set to NULL, as the packetizer need to update its internal state.
      *
+     * Application should call #pjmedia_vid_codec_unpacketize() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance
      * @param pkt	The input packet.
@@ -236,4 +257,7 @@
      * in opening the codec.
      *
+     * Application should call #pjmedia_vid_codec_encode() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param input	The input frame.
@@ -257,4 +281,7 @@
      * using #get_param().
      *
+     * Application should call #pjmedia_vid_codec_decode() instead of 
+     * calling this function directly.
+     *
      * @param codec	The codec instance.
      * @param input	The input frame.
@@ -271,4 +298,7 @@
     /**
      * Instruct the codec to recover a missing frame.
+     *
+     * Application should call #pjmedia_vid_codec_recover() instead of 
+     * calling this function directly.
      *
      * @param codec	The codec instance.
@@ -433,6 +463,6 @@
  * @param sig	    Codec's object signature (see signatures.h)
  */
-PJ_DECL(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec,
-                                     pjmedia_obj_sig sig);
+PJ_DECL(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec,
+                                      pjmedia_obj_sig sig);
 
 /**
@@ -700,4 +730,227 @@
 
 
+/** 
+ * Initialize codec using the specified attribute.
+ *
+ * @param codec	    The codec instance.
+ * @param pool	    Pool to use when the codec needs to allocate
+ *		    some memory.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_init( pjmedia_vid_codec *codec, 
+					       pj_pool_t *pool )
+{
+    return (*codec->op->init)(codec, pool);
+}
+
+
+/** 
+ * Open the codec and initialize with the specified parameter.
+ * Upon successful initialization, the codec may modify the parameter
+ * and fills in the unspecified values (such as size or frame rate of
+ * the encoder format, as it may need to be negotiated with remote
+ * preferences via SDP fmtp).
+ *
+ * @param codec	    The codec instance.
+ * @param param	    Codec initialization parameter.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_open(
+					    pjmedia_vid_codec *codec, 
+					    pjmedia_vid_codec_param *param )
+{
+    return (*codec->op->open)(codec, param);
+}
+
+
+/** 
+ * Close and shutdown codec, releasing all resources allocated by
+ * this codec, if any.
+ *
+ * @param codec	    The codec instance.
+ *
+ * @return	    PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_close( pjmedia_vid_codec *codec )
+{
+    return (*codec->op->close)(codec);
+}
+
+
+/** 
+ * Modify the codec parameter after the codec is open. 
+ * Note that not all codec parameters can be modified during run-time. 
+ * When the parameter cannot be changed, this function will return 
+ * non-PJ_SUCCESS, and the original parameters will not be changed.
+ *
+ * @param codec	The codec instance.
+ * @param param	The new codec parameter.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_modify(
+				    pjmedia_vid_codec *codec, 
+				    const pjmedia_vid_codec_param *param)
+{
+    return (*codec->op->modify)(codec, param);
+}
+
+
+/** 
+ * Get the codec parameter after the codec is opened. 
+ *
+ * @param codec	The codec instance.
+ * @param param	The codec parameter.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_get_param(
+				    pjmedia_vid_codec *codec, 
+				    pjmedia_vid_codec_param *param)
+{
+    return (*codec->op->get_param)(codec, param);
+}
+
+
+/**
+ * Instruct the codec to generate a payload/packet from a picture
+ * bitstream to be sent (via network). The maximum payload size or
+ * MTU is configurable via enc_mtu field of #pjmedia_vid_codec_param.
+ * For a long bitstream, application usually need to call this function
+ * multiple times until the whole bitstream is sent. Note that, for
+ * performance reason, the packetization will be done in-place, so the
+ * original bitstream may be modified by this function.
+ *
+ * @param codec	The codec instance
+ * @param bits	The picture bitstream.
+ * @param bits_len	The length of the bitstream.
+ * @param bits_pos	On input, the start position of the bitstream
+ *			to be packetized. On output, the next position for
+ *			next packet.
+ * @param pkt	The pointer of the generated payload.
+ * @param pkt_len	The payload length.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_packetize(
+					    pjmedia_vid_codec *codec,
+					    pj_uint8_t *bits,
+					    pj_size_t bits_len,
+					    unsigned *bits_pos,
+					    const pj_uint8_t **pkt,
+					    pj_size_t *pkt_len )
+{
+    return (*codec->op->packetize)(codec, bits, bits_len, bits_pos,
+				   pkt, pkt_len);
+}
+
+
+/**
+ * Instruct the codec to parse a payload and append it into a picture
+ * bitstream. A picture bitstreams may need to be reconstructed from
+ * one or more payloads. Note that this function will not provide the
+ * detection of picture boundary, so application should manage the
+ * picture boundary detection by itself, e.g: for RTP delivery, payloads
+ * belong to the same picture will share the same RTP timestamp and also
+ * there is marker bit in the RTP header that is usually reserved for
+ * end-of-picture flag. Also note that in case of noticing packet lost,
+ * application should keep calling this function with payload pointer
+ * set to NULL, as the packetizer need to update its internal state.
+ *
+ * @param codec	The codec instance
+ * @param pkt	The input packet.
+ * @param pkt_size	Size of the packet.
+ * @param timestamp	The timestamp of the first sample in the packet.
+ * @param frame_cnt	On input, specifies the maximum number of frames
+ *			in the array. On output, the codec must fill
+ *			with number of frames detected in the packet.
+ * @param frames	On output, specifies the frames that have been
+ *			detected in the packet.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_unpacketize(
+						pjmedia_vid_codec *codec,
+						const pj_uint8_t *payload,
+						pj_size_t payload_len,
+						pj_uint8_t *bits,
+						pj_size_t bits_len,
+						unsigned *bits_pos )
+{
+    return (*codec->op->unpacketize)(codec, payload, payload_len, bits,
+				     bits_len, bits_pos);
+}
+
+
+/** 
+ * Instruct the codec to encode the specified input frame. The input
+ * MUST contain only one picture with appropriate format as specified
+ * in opening the codec.
+ *
+ * @param codec	The codec instance.
+ * @param input	The input frame.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_encode(
+					    pjmedia_vid_codec *codec, 
+					    const pjmedia_frame *input,
+					    unsigned out_size, 
+					    pjmedia_frame *output)
+{
+    return (*codec->op->encode)(codec, input, out_size, output);
+}
+
+
+/** 
+ * Instruct the codec to decode the specified input frame. The input
+ * frame MUST contain exactly one picture. Note that the decoded picture
+ * format may different to the current setting, e.g: the format specified
+ * in the #pjmedia_vid_codec_param when opening the codec, in this case the
+ * PJMEDIA_EVENT_FMT_CHANGED event will be emitted by the codec. The codec
+ * parameter will also be updated, and application can query the format by
+ * using #get_param().
+ *
+ * @param codec	The codec instance.
+ * @param input	The input frame.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_decode(
+					    pjmedia_vid_codec *codec, 
+					    const pjmedia_frame *input,
+					    unsigned out_size, 
+					    pjmedia_frame *output)
+{
+    return (*codec->op->decode)(codec, input, out_size, output);
+}
+
+
+/**
+ * Instruct the codec to recover a missing frame.
+ *
+ * @param codec	The codec instance.
+ * @param out_size	The length of buffer in the output frame.
+ * @param output	The output frame where generated signal
+ *			will be placed.
+ *
+ * @return		PJ_SUCCESS on success;
+ */
+PJ_INLINE(pj_status_t) pjmedia_vid_codec_recover(
+					    pjmedia_vid_codec *codec, 
+					    unsigned out_size, 
+					    pjmedia_frame *output)
+{
+    if (codec->op && codec->op->recover)
+	return (*codec->op->recover)(codec, out_size, output);
+    else
+	return PJ_ENOTSUP;
+}
 
 
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c	(revision 3663)
@@ -887,5 +887,5 @@
         goto on_error;
     }
-    pjmedia_vid_codec_init(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG);
+    pjmedia_vid_codec_reset(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG);
     codec->op = &ffmpeg_op;
     codec->factory = factory;
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stream.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stream.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stream.c	(revision 3663)
@@ -516,7 +516,7 @@
 		frame_out.buf = p_out_samp + samples_count;
 		frame_out.size = frame->size - samples_count*2;
-		status = (*stream->codec->op->recover)(stream->codec,
-						       frame_out.size,
-						       &frame_out);
+		status = pjmedia_codec_recover(stream->codec,
+					       frame_out.size,
+					       &frame_out);
 
 		++stream->plc_cnt;
@@ -565,7 +565,7 @@
 			frame_out.buf = p_out_samp + samples_count;
 			frame_out.size = frame->size - samples_count*2;
-			status = (*stream->codec->op->recover)(stream->codec,
-							       frame_out.size,
-							       &frame_out);
+			status = pjmedia_codec_recover(stream->codec,
+						       frame_out.size,
+						       &frame_out);
 			if (status != PJ_SUCCESS)
 			    break;
@@ -620,7 +620,7 @@
 		    frame_out.buf = p_out_samp + samples_count;
 		    frame_out.size = frame->size - samples_count*2;
-		    status = (*stream->codec->op->recover)(stream->codec,
-							   frame_out.size,
-							   &frame_out);
+		    status = pjmedia_codec_recover(stream->codec,
+						   frame_out.size,
+						   &frame_out);
 		    if (status != PJ_SUCCESS)
 			break;
@@ -671,6 +671,6 @@
 	    frame_out.buf = p_out_samp + samples_count;
 	    frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE;
-	    status = stream->codec->op->decode( stream->codec, &frame_in,
-						frame_out.size, &frame_out);
+	    status = pjmedia_codec_decode( stream->codec, &frame_in,
+					   frame_out.size, &frame_out);
 	    if (status != 0) {
 		LOGERR_((port->info.name.ptr, "codec decode() error", 
@@ -775,6 +775,6 @@
 	    frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO;
 
-	    status = stream->codec->op->decode( stream->codec, &frame_in,
-						0, frame);
+	    status = pjmedia_codec_decode( stream->codec, &frame_in,
+					   0, frame);
 	    if (status != PJ_SUCCESS) {
 		LOGERR_((port->info.name.ptr, "codec decode() error", 
@@ -802,6 +802,5 @@
 	    status = PJ_SUCCESS;
 	    if (stream->codec->op->recover) {
-		status = (*stream->codec->op->recover)(stream->codec,
-						       0, frame);
+		status = pjmedia_codec_recover(stream->codec, 0, frame);
 	    }
 	    
@@ -1249,8 +1248,8 @@
 	
 	/* Encode! */
-	status = stream->codec->op->encode( stream->codec, &silence_frame,
-					    channel->out_pkt_size - 
-					    sizeof(pjmedia_rtp_hdr),
-					    &frame_out);
+	status = pjmedia_codec_encode( stream->codec, &silence_frame,
+				       channel->out_pkt_size - 
+				       sizeof(pjmedia_rtp_hdr),
+				       &frame_out);
 	if (status != PJ_SUCCESS) {
 	    LOGERR_((stream->port.info.name.ptr, 
@@ -1273,8 +1272,8 @@
     {
 	/* Encode! */
-	status = stream->codec->op->encode( stream->codec, frame, 
-					    channel->out_pkt_size - 
-					    sizeof(pjmedia_rtp_hdr),
-					    &frame_out);
+	status = pjmedia_codec_encode( stream->codec, frame, 
+				       channel->out_pkt_size - 
+				       sizeof(pjmedia_rtp_hdr),
+				       &frame_out);
 	if (status != PJ_SUCCESS) {
 	    LOGERR_((stream->port.info.name.ptr, 
@@ -1426,5 +1425,5 @@
     {
 	stream->codec_param.setting.vad = stream->vad_enabled;
-	stream->codec->op->modify(stream->codec, &stream->codec_param);
+	pjmedia_codec_modify(stream->codec, &stream->codec_param);
 	PJ_LOG(4,(stream->port.info.name.ptr,"VAD re-enabled"));
     }
@@ -1692,10 +1691,6 @@
 
 	/* Parse the payload. */
-	status = (*stream->codec->op->parse)(stream->codec,
-					     (void*)payload,
-					     payloadlen,
-					     &ts,
-					     &count,
-					     frames);
+	status = pjmedia_codec_parse(stream->codec, (void*)payload,
+				     payloadlen, &ts, &count, frames);
 	if (status != PJ_SUCCESS) {
 	    LOGERR_((stream->port.info.name.ptr, 
@@ -2059,5 +2054,5 @@
 
     /* Open the codec. */
-    status = stream->codec->op->open(stream->codec, &stream->codec_param);
+    status = pjmedia_codec_open(stream->codec, &stream->codec_param);
     if (status != PJ_SUCCESS)
 	goto err_cleanup;
@@ -2138,5 +2133,5 @@
 	stream->codec_param.setting.vad = 0;
 	stream->ts_vad_disabled = 0;
-	stream->codec->op->modify(stream->codec, &stream->codec_param);
+	pjmedia_codec_modify(stream->codec, &stream->codec_param);
 	PJ_LOG(4,(stream->port.info.name.ptr,"VAD temporarily disabled"));
     }
@@ -2441,5 +2436,5 @@
 
     if (stream->codec) {
-	stream->codec->op->close(stream->codec);
+	pjmedia_codec_close(stream->codec);
 	pjmedia_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
 	stream->codec = NULL;
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c	(revision 3663)
@@ -70,5 +70,5 @@
  * Initialize pjmedia_vid_codec structure with default values.
  */
-PJ_DEF(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec,
+PJ_DEF(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec,
                                     pjmedia_obj_sig sig)
 {
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c	(revision 3663)
@@ -336,5 +336,5 @@
 	case PJMEDIA_EVENT_FMT_CHANGED:
 	    /* Update param from codec */
-	    stream->codec->op->get_param(stream->codec, stream->info.codec_param);
+	    pjmedia_vid_codec_get_param(stream->codec, stream->info.codec_param);
 
 	    /* Update decoding channel port info */
@@ -764,8 +764,8 @@
 
     /* Encode! */
-    status = (*stream->codec->op->encode)(stream->codec, frame, 
-				          channel->buf_size - 
-				          sizeof(pjmedia_rtp_hdr),
-				          &frame_out);
+    status = pjmedia_vid_codec_encode(stream->codec, frame, 
+				      channel->buf_size - 
+				      sizeof(pjmedia_rtp_hdr),
+				      &frame_out);
     if (status != PJ_SUCCESS) {
         LOGERR_((channel->port.info.name.ptr, 
@@ -785,11 +785,10 @@
 
         /* Generate RTP payload */
-        status = (*stream->codec->op->packetize)(
-                                           stream->codec,
-                                           (pj_uint8_t*)frame_out.buf,
-                                           frame_out.size,
-                                           &processed,
-                                           (const pj_uint8_t**)&payload,
-                                           &payload_len);
+        status = pjmedia_vid_codec_packetize(stream->codec,
+                                             (pj_uint8_t*)frame_out.buf,
+                                             frame_out.size,
+                                             &processed,
+                                             (const pj_uint8_t**)&payload,
+                                             &payload_len);
         if (status != PJ_SUCCESS) {
             LOGERR_((channel->port.info.name.ptr, 
@@ -933,5 +932,5 @@
 		}
 
-		status = (*stream->codec->op->unpacketize)(
+		status = pjmedia_vid_codec_unpacketize(
 						stream->codec,
 						p, psize,
@@ -966,6 +965,6 @@
     frame_in.timestamp.u64 = last_ts;
 
-    status = stream->codec->op->decode(stream->codec, &frame_in,
-				       frame->size, frame);
+    status = pjmedia_vid_codec_decode(stream->codec, &frame_in,
+				      frame->size, frame);
     if (status != PJ_SUCCESS) {
 	LOGERR_((port->info.name.ptr, "codec decode() error", 
@@ -1240,8 +1239,8 @@
 
     /* Init and open the codec. */
-    status = stream->codec->op->init(stream->codec, pool);
+    status = pjmedia_vid_codec_init(stream->codec, pool);
     if (status != PJ_SUCCESS)
 	return status;
-    status = stream->codec->op->open(stream->codec, info->codec_param);
+    status = pjmedia_vid_codec_open(stream->codec, info->codec_param);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1446,5 +1445,5 @@
     /* Free codec. */
     if (stream->codec) {
-	stream->codec->op->close(stream->codec);
+	pjmedia_vid_codec_close(stream->codec);
 	pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
 	stream->codec = NULL;
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/test/codec_vectors.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/test/codec_vectors.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/test/codec_vectors.c	(revision 3663)
@@ -74,5 +74,5 @@
     codec_param.setting.vad = 0;
 
-    status = codec->op->init(codec, pool);
+    status = pjmedia_codec_init(codec, pool);
     if (status != PJ_SUCCESS) {
 	rc = -60;
@@ -80,5 +80,5 @@
     }
 
-    status = codec->op->open(codec, &codec_param);
+    status = pjmedia_codec_open(codec, &codec_param);
     if (status != PJ_SUCCESS) {
 	rc = -70;
@@ -118,5 +118,5 @@
 
 	out_frame.size = samples_per_frame;
-	status = codec->op->encode(codec, &in_frame, samples_per_frame,
+	status = pjmedia_codec_encode(codec, &in_frame, samples_per_frame,
 				   &out_frame);
 	if (status != PJ_SUCCESS) {
@@ -189,5 +189,5 @@
 
     if (codec) {
-	codec->op->close(codec);
+	pjmedia_codec_close(codec);
 	pjmedia_codec_mgr_dealloc_codec(mgr, codec);
     }
@@ -327,5 +327,5 @@
     codec_param.setting.vad = 0;
 
-    status = codec->op->init(codec, pool);
+    status = pjmedia_codec_init(codec, pool);
     if (status != PJ_SUCCESS) {
 	rc = -60;
@@ -333,5 +333,5 @@
     }
 
-    status = codec->op->open(codec, &codec_param);
+    status = pjmedia_codec_open(codec, &codec_param);
     if (status != PJ_SUCCESS) {
 	rc = -70;
@@ -388,6 +388,6 @@
 	if (has_frame) {
 	    count = 2;
-	    if (codec->op->parse(codec, pkt, encoded_len, &ts, 
-				 &count, in_frame) != PJ_SUCCESS) 
+	    if (pjmedia_codec_parse(codec, pkt, encoded_len, &ts, 
+				    &count, in_frame) != PJ_SUCCESS) 
 	    {
 		rc = -100;
@@ -400,6 +400,6 @@
 	    }
 
-	    if (codec->op->decode(codec, &in_frame[0], samples_per_frame*2, 
-				  &out_frame) != PJ_SUCCESS) 
+	    if (pjmedia_codec_decode(codec, &in_frame[0], samples_per_frame*2,
+				     &out_frame) != PJ_SUCCESS) 
 	    {
 		rc = -120;
@@ -407,6 +407,6 @@
 	    }
 	} else {
-	    if (codec->op->recover(codec, samples_per_frame*2, 
-				   &out_frame) != PJ_SUCCESS)
+	    if (pjmedia_codec_recover(codec, samples_per_frame*2, 
+				      &out_frame) != PJ_SUCCESS)
 	    {
 		rc = -125;
@@ -484,5 +484,5 @@
 
     if (codec) {
-	codec->op->close(codec);
+	pjmedia_codec_close(codec);
 	pjmedia_codec_mgr_dealloc_codec(mgr, codec);
     }
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/test/mips_test.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/test/mips_test.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/test/mips_test.c	(revision 3663)
@@ -693,6 +693,6 @@
     out_frame.buf = cp->pkt;
     out_frame.size = sizeof(cp->pkt);
-    status = cp->codec->op->encode(cp->codec, frame, sizeof(cp->pkt),
-				   &out_frame);
+    status = pjmedia_codec_encode(cp->codec, frame, sizeof(cp->pkt),
+				  &out_frame);
     pj_assert(status == PJ_SUCCESS);
 
@@ -702,7 +702,7 @@
 	unsigned i;
 
-	status = cp->codec->op->parse(cp->codec, out_frame.buf, 
-				      out_frame.size, &out_frame.timestamp,
-				      &frame_cnt, parsed_frm);
+	status = pjmedia_codec_parse(cp->codec, out_frame.buf, 
+				     out_frame.size, &out_frame.timestamp,
+				     &frame_cnt, parsed_frm);
 	pj_assert(status == PJ_SUCCESS);
 	
@@ -710,6 +710,6 @@
 	    pcm_frm.buf = cp->pcm;
 	    pcm_frm.size = sizeof(cp->pkt);
-	    status = cp->codec->op->decode(cp->codec, &parsed_frm[i], 
-					   sizeof(cp->pcm), &pcm_frm);
+	    status = pjmedia_codec_decode(cp->codec, &parsed_frm[i], 
+					  sizeof(cp->pcm), &pcm_frm);
 	    pj_assert(status == PJ_SUCCESS);
 	}
@@ -723,5 +723,5 @@
     struct codec_port *cp = (struct codec_port*)this_port;
 
-    cp->codec->op->close(cp->codec);
+    pjmedia_codec_close(cp->codec);
     pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
 				    cp->codec);
@@ -783,9 +783,9 @@
 	return NULL;
 
-    status = (*cp->codec->op->init)(cp->codec, pool);
+    status = pjmedia_codec_init(cp->codec, pool);
     if (status != PJ_SUCCESS)
 	return NULL;
 
-    status = cp->codec->op->open(cp->codec, &codec_param);
+    status = pjmedia_codec_open(cp->codec, &codec_param);
     if (status != PJ_SUCCESS)
 	return NULL;
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c	(revision 3663)
@@ -41,5 +41,5 @@
 	++event->proc_cnt;
 
-	status = codec->op->get_param(codec, &codec_param);
+	status = pjmedia_vid_codec_get_param(codec, &codec_param);
 	if (status != PJ_SUCCESS)
 	    return status;
@@ -70,5 +70,6 @@
 	enc_frame.size = port_data->enc_buf_size;
 
-	status = codec->op->encode(codec, frame, enc_frame.size, &enc_frame);
+	status = pjmedia_vid_codec_encode(codec, frame, enc_frame.size,
+					  &enc_frame);
 	if (status != PJ_SUCCESS) goto on_error;
 
@@ -83,9 +84,10 @@
 		pj_size_t payload_len;
 
-		status = codec->op->packetize(codec, 
-					      (pj_uint8_t*)enc_frame.buf,
-					      enc_frame.size, &pos,
-					      (const pj_uint8_t**)&payload,
-					      &payload_len);
+		status = pjmedia_vid_codec_packetize(
+						codec, 
+						(pj_uint8_t*)enc_frame.buf,
+						enc_frame.size, &pos,
+						(const pj_uint8_t**)&payload,
+						&payload_len);
 		if (status == PJ_ENOTSUP)
 		    break;
@@ -93,5 +95,6 @@
 		    goto on_error;
 
-		status = codec->op->unpacketize(codec, payload, payload_len,
+		status = pjmedia_vid_codec_unpacketize(
+						codec, payload, payload_len,
 						port_data->pack_buf,
 						port_data->pack_buf_size,
@@ -113,5 +116,6 @@
 #endif
 
-	status = codec->op->decode(codec, &enc_frame, frame->size, frame);
+	status = pjmedia_vid_codec_decode(codec, &enc_frame,
+					  frame->size, frame);
 	if (status != PJ_SUCCESS) goto on_error;
     }
@@ -277,10 +281,10 @@
         }
 
-        status = codec->op->init(codec, pool);
+        status = pjmedia_vid_codec_init(codec, pool);
         if (status != PJ_SUCCESS) {
 	    rc = 251; goto on_return;
         }
 
-        status = codec->op->open(codec, &codec_param);
+        status = pjmedia_vid_codec_open(codec, &codec_param);
         if (status != PJ_SUCCESS) {
 	    rc = 252; goto on_return;
@@ -415,5 +419,5 @@
     }
     if (codec) {
-        codec->op->close(codec);
+        pjmedia_vid_codec_close(codec);
         pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
     }
Index: pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c	(revision 3663)
@@ -151,5 +151,5 @@
         if (status != PJ_SUCCESS) goto on_error;
 	
-        status = codec->op->decode(codec, frame, frame->size, &enc_frame);
+        status = pjmedia_vid_codec_decode(codec, frame, frame->size, &enc_frame);
         if (status != PJ_SUCCESS) goto on_error;
 	
@@ -164,5 +164,5 @@
     if (status != PJ_SUCCESS) goto on_error;
     
-    status = codec->op->decode(codec, &enc_frame, frame->size, frame);
+    status = pjmedia_vid_codec_decode(codec, &enc_frame, frame->size, frame);
     if (status != PJ_SUCCESS) goto on_error;
     
@@ -283,5 +283,5 @@
             }
 	    
-            status = codec->op->init(codec, pool);
+            status = pjmedia_vid_codec_init(codec, pool);
             if (status != PJ_SUCCESS) {
                 rc = 251; goto on_return;
@@ -290,5 +290,5 @@
             pjmedia_format_copy(&codec_param.dec_fmt, &param.vidparam.fmt);
 	    
-            status = codec->op->open(codec, &codec_param);
+            status = pjmedia_vid_codec_open(codec, &codec_param);
             if (status != PJ_SUCCESS) {
                 rc = 252; goto on_return;
@@ -439,5 +439,5 @@
         pjmedia_port_destroy(vid_port);
     if (codec) {
-        codec->op->close(codec);
+        pjmedia_vid_codec_close(codec);
         pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
     }
Index: pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/encdec.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/encdec.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/encdec.c	(revision 3663)
@@ -138,6 +138,6 @@
     /* Alloc codec */
     CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) );
-    CHECK( codec->op->init(codec, pool) );
-    CHECK( codec->op->open(codec, &param) );
+    CHECK( pjmedia_codec_init(codec, pool) );
+    CHECK( pjmedia_codec_open(codec, &param) );
     
     for (;;) {
@@ -163,5 +163,6 @@
 	frm_bit.buf = bitstream;
 	frm_bit.size = sizeof(bitstream);
-	CHECK(codec->op->encode(codec, &frm_pcm, sizeof(bitstream), &frm_bit));
+	CHECK(pjmedia_codec_encode(codec, &frm_pcm, sizeof(bitstream), 
+	                           &frm_bit));
 
 	/* On DTX, write zero frame to wavout to maintain duration */
@@ -181,6 +182,6 @@
 	ts.u64 = 0;
 	cnt = PJ_ARRAY_SIZE(frames);
-	CHECK( codec->op->parse(codec, bitstream, frm_bit.size, &ts, &cnt, 
-			        frames) );
+	CHECK( pjmedia_codec_parse(codec, bitstream, frm_bit.size, &ts, &cnt, 
+			           frames) );
 	CHECK( (cnt==1 ? PJ_SUCCESS : -1) );
 
@@ -191,9 +192,9 @@
 	if ((pj_rand() % 100) < (int)lost_pct) {
 	    /* Simulate loss */
-	    CHECK( codec->op->recover(codec, sizeof(pcmbuf), &out_frm) );
+	    CHECK( pjmedia_codec_recover(codec, sizeof(pcmbuf), &out_frm) );
 	    TRACE_((THIS_FILE, "%d.%03d Packet lost", T));
 	} else {
 	    /* Decode */
-	    CHECK( codec->op->decode(codec, &frames[0], sizeof(pcmbuf), 
+	    CHECK( pjmedia_codec_decode(codec, &frames[0], sizeof(pcmbuf), 
 				     &out_frm) );
 	}
@@ -211,5 +212,5 @@
 
     /* Close codec */
-    codec->op->close(codec);
+    pjmedia_codec_close(codec);
     pjmedia_codec_mgr_dealloc_codec(cm, codec);
 
Index: pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/pcaputil.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/pcaputil.c	(revision 3662)
+++ pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/pcaputil.c	(revision 3663)
@@ -99,5 +99,5 @@
     if (app.codec) {
 	pjmedia_codec_mgr *cmgr;
-	app.codec->op->close(app.codec);
+	pjmedia_codec_close(app.codec);
 	cmgr = pjmedia_endpt_get_codec_mgr(app.mept);
 	pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec);
@@ -260,6 +260,6 @@
     /* Alloc and init codec */
     T( pjmedia_codec_mgr_alloc_codec(cmgr, ci, &app.codec) );
-    T( app.codec->op->init(app.codec, app.pool) );
-    T( app.codec->op->open(app.codec, &param) );
+    T( pjmedia_codec_init(app.codec, app.pool) );
+    T( pjmedia_codec_open(app.codec, &param) );
 
     /* Open WAV file */
@@ -285,5 +285,5 @@
 	ts.u64 = 0;
 	frame_cnt = PJ_ARRAY_SIZE(frames);
-	T( app.codec->op->parse(app.codec, pkt0.payload, pkt0.payload_len, 
+	T( pjmedia_codec_parse(app.codec, pkt0.payload, pkt0.payload_len, 
 				&ts, &frame_cnt, frames) );
 
@@ -296,5 +296,5 @@
 	    pcm_frame.size = samples_per_frame * 2;
 
-	    T( app.codec->op->decode(app.codec, &frames[i], pcm_frame.size, 
+	    T( pjmedia_codec_decode(app.codec, &frames[i], pcm_frame.size, 
 				     &pcm_frame) );
 	    T( pjmedia_port_put_frame(app.wav, &pcm_frame) );
@@ -315,6 +315,6 @@
 
 	    if (app.codec->op->recover) {
-		T( app.codec->op->recover(app.codec, pcm_frame.size, 
-					  &pcm_frame) );
+		T( pjmedia_codec_recover(app.codec, pcm_frame.size, 
+					 &pcm_frame) );
 	    } else {
 		pj_bzero(pcm_frame.buf, pcm_frame.size);
