Index: pjproject/trunk/pjmedia/src/pjmedia/resample_port.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/resample_port.c	(revision 3553)
+++ pjproject/trunk/pjmedia/src/pjmedia/resample_port.c	(revision 3664)
@@ -26,5 +26,5 @@
 
 #define BYTES_PER_SAMPLE	2
-#define SIGNATURE		PJMEDIA_PORT_SIGNATURE('R','S','M','P')
+#define SIGNATURE		PJMEDIA_SIG_PORT_RESAMPLE
 
 
@@ -43,5 +43,5 @@
 
 static pj_status_t resample_put_frame(pjmedia_port *this_port,
-				      const pjmedia_frame *frame);
+				      pjmedia_frame *frame);
 static pj_status_t resample_get_frame(pjmedia_port *this_port, 
 				      pjmedia_frame *frame);
@@ -58,5 +58,5 @@
     const pj_str_t name = pj_str("resample");
     struct resample_port *rport;
-    unsigned ptime;
+    pjmedia_audio_format_detail *d_afd, *r_afd;
     pj_status_t status;
 
@@ -65,9 +65,8 @@
 
     /* Only supports 16bit samples per frame */
-    PJ_ASSERT_RETURN(dn_port->info.bits_per_sample == 16, PJMEDIA_ENCBITS);
-
-    ptime = dn_port->info.samples_per_frame * 1000 / 
-	    dn_port->info.clock_rate;
-    
+    PJ_ASSERT_RETURN(PJMEDIA_PIA_BITS(&dn_port->info) == 16, PJMEDIA_ENCBITS);
+
+    d_afd = pjmedia_format_get_audio_format_detail(&dn_port->info.fmt, 1);
+
     /* Create and initialize port. */
     rport = PJ_POOL_ZALLOC_T(pool, struct resample_port);
@@ -75,10 +74,11 @@
 
     pjmedia_port_info_init(&rport->base.info, &name, SIGNATURE, clock_rate,
-			   dn_port->info.channel_count, BYTES_PER_SAMPLE * 8, 
-			   clock_rate * ptime / 1000);
+		           d_afd->channel_count, BYTES_PER_SAMPLE * 8,
+			   clock_rate * d_afd->frame_time_usec / 1000000);
 
     rport->dn_port = dn_port;
     rport->options = opt;
 
+    r_afd = pjmedia_format_get_audio_format_detail(&rport->base.info.fmt, 1);
 
     /* Create buffers. 
@@ -87,9 +87,9 @@
      */
     rport->get_buf = (pj_int16_t*)
-		     pj_pool_alloc(pool, dn_port->info.bytes_per_frame);
+		     pj_pool_alloc(pool, PJMEDIA_PIA_AVG_FSZ(&dn_port->info));
     PJ_ASSERT_RETURN(rport->get_buf != NULL, PJ_ENOMEM);
 
     rport->put_buf = (pj_int16_t*)
-		     pj_pool_alloc(pool, dn_port->info.bytes_per_frame);
+		     pj_pool_alloc(pool, PJMEDIA_PIA_AVG_FSZ(&dn_port->info));
     PJ_ASSERT_RETURN(rport->put_buf != NULL, PJ_ENOMEM);
 
@@ -99,8 +99,8 @@
 				     (opt&PJMEDIA_RESAMPLE_USE_LINEAR)==0,
 				     (opt&PJMEDIA_RESAMPLE_USE_SMALL_FILTER)==0,
-				     dn_port->info.channel_count,
-				     dn_port->info.clock_rate, 
-				     rport->base.info.clock_rate,
-				     dn_port->info.samples_per_frame, 
+				     d_afd->channel_count,
+				     d_afd->clock_rate,
+				     r_afd->clock_rate,
+				     PJMEDIA_PIA_SPF(&dn_port->info),
 				     &rport->resample_get);
     if (status != PJ_SUCCESS)
@@ -111,8 +111,8 @@
 				     (opt&PJMEDIA_RESAMPLE_USE_LINEAR)==0, 
 				     (opt&PJMEDIA_RESAMPLE_USE_SMALL_FILTER)==0,
-				     dn_port->info.channel_count,
-				     rport->base.info.clock_rate, 
-				     dn_port->info.clock_rate,
-				     rport->base.info.samples_per_frame,
+				     d_afd->channel_count,
+				     r_afd->clock_rate,
+				     d_afd->clock_rate,
+				     PJMEDIA_PIA_SPF(&rport->base.info),
 				     &rport->resample_put);
 
@@ -132,5 +132,5 @@
 
 static pj_status_t resample_put_frame(pjmedia_port *this_port,
-				      const pjmedia_frame *frame)
+				      pjmedia_frame *frame)
 {
     struct resample_port *rport = (struct resample_port*) this_port;
@@ -148,5 +148,5 @@
 
 	downstream_frame.buf = rport->put_buf;
-	downstream_frame.size = rport->dn_port->info.bytes_per_frame;
+	downstream_frame.size = PJMEDIA_PIA_AVG_FSZ(&rport->dn_port->info);
     } else {
 	downstream_frame.buf = frame->buf;
@@ -176,5 +176,5 @@
 
     tmp_frame.buf = rport->get_buf;
-    tmp_frame.size = rport->dn_port->info.bytes_per_frame;
+    tmp_frame.size = PJMEDIA_PIA_AVG_FSZ(&rport->dn_port->info);
     tmp_frame.timestamp.u64 = frame->timestamp.u64;
     tmp_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
@@ -188,6 +188,6 @@
 	frame->timestamp = tmp_frame.timestamp;
 	/* Copy whatever returned as long as the buffer size is enough */
-	frame->size = tmp_frame.size < rport->base.info.bytes_per_frame ?
-		      tmp_frame.size : rport->base.info.bytes_per_frame;
+	frame->size = tmp_frame.size < PJMEDIA_PIA_AVG_FSZ(&rport->base.info) ?
+		      tmp_frame.size : PJMEDIA_PIA_AVG_FSZ(&rport->base.info);
 	if (tmp_frame.size) {
 	    pjmedia_copy_samples((pj_int16_t*)frame->buf, 
@@ -202,5 +202,5 @@
 			  (pj_int16_t*) frame->buf);
 
-    frame->size = rport->base.info.bytes_per_frame;
+    frame->size = PJMEDIA_PIA_AVG_FSZ(&rport->base.info);
     frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
 
