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 3420)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c	(revision 3425)
@@ -85,4 +85,5 @@
     pjmedia_endpt	    *endpt;	    /**< Media endpoint.	    */
     pjmedia_vid_codec_mgr   *codec_mgr;	    /**< Codec manager.		    */
+    pjmedia_vid_stream_info  info;	    /**< Stream info.		    */
 
     pjmedia_vid_channel	    *enc;	    /**< Encoding channel.	    */
@@ -129,13 +130,9 @@
 
 #if TRACE_JB
-    pj_oshandle_t	    trace_jb_fd;	    /**< Jitter tracing file handle.*/
-    char		   *trace_jb_buf;	    /**< Jitter tracing buffer.	    */
+    pj_oshandle_t	     trace_jb_fd;   /**< Jitter tracing file handle.*/
+    char		    *trace_jb_buf;  /**< Jitter tracing buffer.	    */
 #endif
 
-    pjmedia_vid_codec	    *codec;	            /**< Codec instance being used. */
-    pjmedia_vid_codec_info   codec_info;           /**< Codec param.		    */
-    pjmedia_vid_codec_param  codec_param;          /**< Codec param.		    */
-
-    pjmedia_vid_stream_info     info;
+    pjmedia_vid_codec	    *codec;	    /**< Codec instance being used. */
 };
 
@@ -627,9 +624,5 @@
 	status = pjmedia_jbuf_reset(stream->jb);
 	PJ_LOG(4,(channel->port.info.name.ptr, "Jitter buffer reset"));
-
     } else {
-
-	/* Video stream */
-
 	/* Just put the payload into jitter buffer */
 	pjmedia_jbuf_put_frame3(stream->jb, payload, payloadlen, 0, 
@@ -928,8 +921,9 @@
     if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) {
 	/* Update param from codec */
-	stream->codec->op->get_param(stream->codec, &stream->codec_param);
+	stream->codec->op->get_param(stream->codec, stream->info.codec_param);
 
 	/* Update decoding channel port info */
-	stream->dec->port.info.fmt = stream->codec_param.dec_fmt;
+	pjmedia_format_copy(&stream->dec->port.info.fmt,
+			    &stream->info.codec_param->dec_fmt);
     }
     
@@ -965,8 +959,8 @@
     /* Init vars */
     if (dir==PJMEDIA_DIR_DECODING) {
-	type_name = "vstrmdec";
+	type_name = "vstdec";
 	fmt = &info->codec_param->dec_fmt;
     } else {
-	type_name = "vstrmenc";
+	type_name = "vstenc";
 	fmt = &info->codec_param->enc_fmt;
     }
@@ -1054,4 +1048,7 @@
     PJ_ASSERT_RETURN(stream != NULL, PJ_ENOMEM);
 
+    /* Copy stream info */
+    pj_memcpy(&stream->info, info, sizeof(*info));
+
     /* Get codec manager */
     stream->codec_mgr = pjmedia_vid_codec_mgr_instance();
@@ -1064,5 +1061,4 @@
 
     /* Create and initialize codec: */
-    stream->codec_info = info->codec_info;
     status = pjmedia_vid_codec_mgr_alloc_codec(stream->codec_mgr, 
 					       &info->codec_info,
@@ -1073,16 +1069,25 @@
 
     /* Get codec param: */
-    if (info->codec_param)
-	stream->codec_param = *info->codec_param;
-    else {
+    if (info->codec_param) {
+	stream->info.codec_param = pjmedia_vid_codec_param_clone(
+							pool,
+							info->codec_param);
+    } else {
+	pjmedia_vid_codec_param def_param;
+
 	status = pjmedia_vid_codec_mgr_get_default_param(stream->codec_mgr, 
 						         &info->codec_info,
-						         &stream->codec_param);
+						         &def_param);
 	if (status != PJ_SUCCESS)
 	    return status;
+	stream->info.codec_param = pjmedia_vid_codec_param_clone(
+							pool,
+							&def_param);
+	pj_assert(stream->info.codec_param);
     }
 
     vfd_enc = pjmedia_format_get_video_format_detail(
-                                            &stream->codec_param.enc_fmt, 1);
+					&stream->info.codec_param->enc_fmt,
+					PJ_TRUE);
 
     /* Init stream: */
@@ -1117,6 +1122,7 @@
 
     /* Init codec param */
-    stream->codec_param.dir = info->dir;
-    stream->codec_param.enc_mtu = PJMEDIA_MAX_MTU - sizeof(pjmedia_rtp_hdr);
+    stream->info.codec_param->dir = info->dir;
+    stream->info.codec_param->enc_mtu = PJMEDIA_MAX_MTU - 
+					sizeof(pjmedia_rtp_hdr);
 
     /* Init and open the codec. */
@@ -1124,5 +1130,5 @@
     if (status != PJ_SUCCESS)
 	return status;
-    status = stream->codec->op->open(stream->codec, &stream->codec_param);
+    status = stream->codec->op->open(stream->codec, stream->info.codec_param);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1140,7 +1146,7 @@
     /* Validate the frame size */
     if (stream->frame_size == 0 || 
-	stream->frame_size > PJMEDIA_MAX_VIDEO_FRAME_SIZE)
+	stream->frame_size > PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE)
     {
-	stream->frame_size = PJMEDIA_MAX_VIDEO_FRAME_SIZE;
+	stream->frame_size = PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE;
     }
 
@@ -1151,5 +1157,5 @@
     /* Create decoder channel */
     status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 
-			     info->codec_info.pt, info, &stream->dec);
+			     info->rx_pt, info, &stream->dec);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1408,4 +1414,75 @@
 
 /*
+ * Get stream statistics.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat(
+					    const pjmedia_vid_stream *stream,
+					    pjmedia_rtcp_stat *stat)
+{
+    PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);
+
+    pj_memcpy(stat, &stream->rtcp.stat, sizeof(pjmedia_rtcp_stat));
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Reset the stream statistics in the middle of a stream session.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_stream_reset_stat(pjmedia_vid_stream *stream)
+{
+    PJ_ASSERT_RETURN(stream, PJ_EINVAL);
+
+    pjmedia_rtcp_init_stat(&stream->rtcp.stat);
+
+    return PJ_SUCCESS;
+}
+
+
+#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
+/*
+ * Get stream extended statistics.
+ */
+PJ_DEF(pj_status_t) pjmedia_stream_get_stat_xr(
+					    const pjmedia_vid_stream *stream,
+					    pjmedia_rtcp_xr_stat *stat)
+{
+    PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);
+
+    if (stream->rtcp.xr_enabled) {
+	pj_memcpy(stat, &stream->rtcp.xr_session.stat,
+		  sizeof(pjmedia_rtcp_xr_stat));
+	return PJ_SUCCESS;
+    }
+    return PJ_ENOTFOUND;
+}
+#endif
+
+/*
+ * Get jitter buffer state.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat_jbuf(
+					    const pjmedia_vid_stream *stream,
+					    pjmedia_jb_state *state)
+{
+    PJ_ASSERT_RETURN(stream && state, PJ_EINVAL);
+    return pjmedia_jbuf_get_state(stream->jb, state);
+}
+
+
+/*
+ * Get the stream info.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_stream_get_info(
+					    const pjmedia_vid_stream *stream,
+					    pjmedia_vid_stream_info *info)
+{
+    PJ_ASSERT_RETURN(stream && info, PJ_EINVAL);
+    pj_memcpy(info, &stream->info, sizeof(*info));
+    return PJ_SUCCESS;
+}
+
+
+/*
  * Start stream.
  */
@@ -1434,61 +1511,4 @@
 }
 
-
-/*
- * Get stream statistics.
- */
-PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat(
-					    const pjmedia_vid_stream *stream,
-					    pjmedia_rtcp_stat *stat)
-{
-    PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);
-
-    pj_memcpy(stat, &stream->rtcp.stat, sizeof(pjmedia_rtcp_stat));
-    return PJ_SUCCESS;
-}
-
-
-/*
- * Reset the stream statistics in the middle of a stream session.
- */
-PJ_DEF(pj_status_t) pjmedia_vid_stream_reset_stat(pjmedia_vid_stream *stream)
-{
-    PJ_ASSERT_RETURN(stream, PJ_EINVAL);
-
-    pjmedia_rtcp_init_stat(&stream->rtcp.stat);
-
-    return PJ_SUCCESS;
-}
-
-
-#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
-/*
- * Get stream extended statistics.
- */
-PJ_DEF(pj_status_t) pjmedia_stream_get_stat_xr(
-					    const pjmedia_vid_stream *stream,
-					    pjmedia_rtcp_xr_stat *stat)
-{
-    PJ_ASSERT_RETURN(stream && stat, PJ_EINVAL);
-
-    if (stream->rtcp.xr_enabled) {
-	pj_memcpy(stat, &stream->rtcp.xr_session.stat,
-		  sizeof(pjmedia_rtcp_xr_stat));
-	return PJ_SUCCESS;
-    }
-    return PJ_ENOTFOUND;
-}
-#endif
-
-/*
- * Get jitter buffer state.
- */
-PJ_DEF(pj_status_t) pjmedia_vid_stream_get_stat_jbuf(
-					    const pjmedia_vid_stream *stream,
-					    pjmedia_jb_state *state)
-{
-    PJ_ASSERT_RETURN(stream && state, PJ_EINVAL);
-    return pjmedia_jbuf_get_state(stream->jb, state);
-}
 
 /*
@@ -1579,4 +1599,5 @@
      */
     pt = pj_strtoul(&local_m->desc.fmt[0]);
+    si->rx_pt = pt;
     if (pt < 96) {
 	const pjmedia_vid_codec_info *p_info;
@@ -1660,5 +1681,5 @@
 
     /* Get local fmtp for our decoder. */
-    pjmedia_stream_info_parse_fmtp(pool, local_m, pt,
+    pjmedia_stream_info_parse_fmtp(pool, local_m, si->rx_pt,
 				   &si->codec_param->dec_fmtp);
 
@@ -1718,5 +1739,5 @@
 
     /* Media type must be audio */
-    if (pj_stricmp(&local_m->desc.media, &ID_VIDEO) == 0)
+    if (pj_stricmp(&local_m->desc.media, &ID_VIDEO) != 0)
 	return PJMEDIA_EINVALIMEDIATYPE;
 
