Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/splitcomb.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/splitcomb.c	(revision 3391)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/splitcomb.c	(revision 3392)
@@ -190,5 +190,5 @@
  */
 static pj_status_t put_frame(pjmedia_port *this_port, 
-			     const pjmedia_frame *frame);
+			     pjmedia_frame *frame);
 static pj_status_t get_frame(pjmedia_port *this_port, 
 			     pjmedia_frame *frame);
@@ -196,5 +196,5 @@
 
 static pj_status_t rport_put_frame(pjmedia_port *this_port, 
-				   const pjmedia_frame *frame);
+				   pjmedia_frame *frame);
 static pj_status_t rport_get_frame(pjmedia_port *this_port, 
 				   pjmedia_frame *frame);
@@ -285,5 +285,5 @@
 
     /* Check the channel number */
-    PJ_ASSERT_RETURN(ch_num < sc->base.info.channel_count, PJ_EINVAL);
+    PJ_ASSERT_RETURN(ch_num < PJMEDIA_PIA_CCNT(&sc->base.info), PJ_EINVAL);
 
     /* options is unused for now */
@@ -309,5 +309,6 @@
     struct splitcomb *sc = (struct splitcomb*) splitcomb;
     struct reverse_port *rport;
-    unsigned buf_cnt, ptime;
+    unsigned buf_cnt;
+    const pjmedia_audio_format_detail *sc_afd, *p_afd;
     pjmedia_port *port;
     pj_status_t status;
@@ -320,8 +321,10 @@
 
     /* Check the channel number */
-    PJ_ASSERT_RETURN(ch_num < sc->base.info.channel_count, PJ_EINVAL);
+    PJ_ASSERT_RETURN(ch_num < PJMEDIA_PIA_CCNT(&sc->base.info), PJ_EINVAL);
 
     /* options is unused for now */
     PJ_UNUSED_ARG(options);
+
+    sc_afd = pjmedia_format_get_audio_format_detail(&splitcomb->info.fmt, 1);
 
     /* Create the port */
@@ -333,8 +336,10 @@
     port = &rport->base;
     pjmedia_port_info_init(&port->info, &name, SIGNATURE_PORT, 
-			   splitcomb->info.clock_rate, 1, 
-			   splitcomb->info.bits_per_sample, 
-			   splitcomb->info.samples_per_frame / 
-				   splitcomb->info.channel_count);
+			   sc_afd->clock_rate, 1,
+			   sc_afd->bits_per_sample,
+			   PJMEDIA_PIA_SPF(&splitcomb->info) /
+				   sc_afd->channel_count);
+
+    p_afd = pjmedia_format_get_audio_format_detail(&port->info.fmt, 1);
 
     /* ... and the callbacks */
@@ -348,7 +353,4 @@
 	buf_cnt = MAX_BUF_CNT;
 
-    ptime = port->info.samples_per_frame * 1000 / port->info.clock_rate /
-	    port->info.channel_count;
-
     rport->max_burst = MAX_BURST;
     rport->max_null_frames = MAX_NULL_FRAMES;
@@ -356,9 +358,9 @@
     /* Create downstream/put buffers */
     status = pjmedia_delay_buf_create(pool, "scombdb-dn",
-				      port->info.clock_rate,
-				      port->info.samples_per_frame,
-				      port->info.channel_count,
-				      buf_cnt * ptime, 0,
-				      &rport->buf[DIR_DOWNSTREAM].dbuf);
+				      p_afd->clock_rate,
+				      PJMEDIA_PIA_SPF(&port->info),
+				      p_afd->channel_count,
+				      buf_cnt * p_afd->frame_time_usec / 1000,
+				      0, &rport->buf[DIR_DOWNSTREAM].dbuf);
     if (status != PJ_SUCCESS) {
 	return status;
@@ -367,9 +369,9 @@
     /* Create upstream/get buffers */
     status = pjmedia_delay_buf_create(pool, "scombdb-up",
-				      port->info.clock_rate,
-				      port->info.samples_per_frame,
-				      port->info.channel_count,
-				      buf_cnt * ptime, 0,
-				      &rport->buf[DIR_UPSTREAM].dbuf);
+				      p_afd->clock_rate,
+				      PJMEDIA_PIA_SPF(&port->info),
+				      p_afd->channel_count,
+				      buf_cnt * p_afd->frame_time_usec / 1000,
+				      0, &rport->buf[DIR_UPSTREAM].dbuf);
     if (status != PJ_SUCCESS) {
 	pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf);
@@ -379,5 +381,6 @@
     /* And temporary upstream/get buffer */
     rport->tmp_up_buf = (pj_int16_t*)
-	                pj_pool_alloc(pool, port->info.bytes_per_frame);
+	                pj_pool_alloc(pool,
+				      PJMEDIA_PIA_AVG_FSZ(&port->info));
 
     /* Save port in the splitcomb */
@@ -437,5 +440,5 @@
 
     if (op == OP_PUT) {
-	rport->buf[dir].ts.u64 += rport->base.info.samples_per_frame;
+	rport->buf[dir].ts.u64 += PJMEDIA_PIA_SPF(&rport->base.info);
     }
 
@@ -485,5 +488,5 @@
  */
 static pj_status_t put_frame(pjmedia_port *this_port, 
-			     const pjmedia_frame *frame)
+			     pjmedia_frame *frame)
 {
     struct splitcomb *sc = (struct splitcomb*) this_port;
@@ -492,5 +495,5 @@
     /* Handle null frame */
     if (frame->type == PJMEDIA_FRAME_TYPE_NONE) {
-	for (ch=0; ch < this_port->info.channel_count; ++ch) {
+	for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) {
 	    pjmedia_port *port = sc->port_desc[ch].port;
 
@@ -534,5 +537,5 @@
 		/* Generate zero frame. */
 		pjmedia_zero_samples(sc->put_buf, 
-				     this_port->info.samples_per_frame);
+				     PJMEDIA_PIA_SPF(&this_port->info));
 
 		/* Put frame to delay buffer */
@@ -548,5 +551,5 @@
      * it for now.
      */
-    PJ_ASSERT_RETURN(frame->size == this_port->info.bytes_per_frame,
+    PJ_ASSERT_RETURN(frame->size == PJMEDIA_PIA_AVG_FSZ(&this_port->info),
 		     PJ_EINVAL);
 
@@ -554,5 +557,5 @@
      * Write mono frame into each channels 
      */
-    for (ch=0; ch < this_port->info.channel_count; ++ch) {
+    for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) {
 	pjmedia_port *port = sc->port_desc[ch].port;
 
@@ -562,8 +565,8 @@
 	/* Extract the mono frame to temporary buffer */
 	extract_mono_frame((const pj_int16_t*)frame->buf, sc->put_buf, ch, 
-			   this_port->info.channel_count, 
+			   PJMEDIA_PIA_CCNT(&this_port->info),
 			   frame->size * 8 / 
-			     this_port->info.bits_per_sample /
-			     this_port->info.channel_count);
+			     PJMEDIA_PIA_BITS(&this_port->info) /
+			     PJMEDIA_PIA_CCNT(&this_port->info));
 
 	if (!sc->port_desc[ch].reversed) {
@@ -572,5 +575,5 @@
 
 	    mono_frame.buf = sc->put_buf;
-	    mono_frame.size = frame->size / this_port->info.channel_count;
+	    mono_frame.size = frame->size / PJMEDIA_PIA_CCNT(&this_port->info);
 	    mono_frame.type = frame->type;
 	    mono_frame.timestamp.u64 = frame->timestamp.u64;
@@ -613,5 +616,5 @@
 
     /* Read frame from each port */
-    for (ch=0; ch < this_port->info.channel_count; ++ch) {
+    for (ch=0; ch < PJMEDIA_PIA_CCNT(&this_port->info); ++ch) {
 	pjmedia_port *port = sc->port_desc[ch].port;
 	pjmedia_frame mono_frame;
@@ -620,11 +623,11 @@
 	if (!port) {
 	    pjmedia_zero_samples(sc->get_buf, 
-				 this_port->info.samples_per_frame /
-				    this_port->info.channel_count);
+				 PJMEDIA_PIA_SPF(&this_port->info) /
+				  PJMEDIA_PIA_CCNT(&this_port->info));
 
 	} else if (sc->port_desc[ch].reversed == PJ_FALSE) {
 	    /* Read from normal port */
 	    mono_frame.buf = sc->get_buf;
-	    mono_frame.size = port->info.bytes_per_frame;
+	    mono_frame.size = PJMEDIA_PIA_AVG_FSZ(&port->info);
 	    mono_frame.timestamp.u64 = frame->timestamp.u64;
 
@@ -634,5 +637,5 @@
 	    {
 		pjmedia_zero_samples(sc->get_buf, 
-				     port->info.samples_per_frame);
+				     PJMEDIA_PIA_SPF(&port->info));
 	    }
 
@@ -652,5 +655,5 @@
 	    } else {
 		pjmedia_zero_samples(sc->get_buf, 
-				     port->info.samples_per_frame);
+				     PJMEDIA_PIA_SPF(&port->info));
 	    }
 
@@ -661,7 +664,7 @@
 	store_mono_frame(sc->get_buf, 
 			 (pj_int16_t*)frame->buf, ch,
-			 this_port->info.channel_count,
-			 this_port->info.samples_per_frame /
-			 this_port->info.channel_count);
+			 PJMEDIA_PIA_CCNT(&this_port->info),
+			 PJMEDIA_PIA_SPF(&this_port->info) /
+			  PJMEDIA_PIA_CCNT(&this_port->info));
 
 	has_frame = PJ_TRUE;
@@ -671,5 +674,5 @@
     if (has_frame) {
 	frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
-	frame->size = this_port->info.bytes_per_frame;
+	frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info);
     } else
 	frame->type = PJMEDIA_FRAME_TYPE_NONE;
@@ -695,9 +698,9 @@
  */
 static pj_status_t rport_put_frame(pjmedia_port *this_port, 
-				   const pjmedia_frame *frame)
+				   pjmedia_frame *frame)
 {
     struct reverse_port *rport = (struct reverse_port*) this_port;
 
-    pj_assert(frame->size <= rport->base.info.bytes_per_frame);
+    pj_assert(frame->size <= PJMEDIA_PIA_AVG_FSZ(&rport->base.info));
 
     /* Handle NULL frame */
@@ -731,5 +734,5 @@
 	/* Generate zero frame. */
 	pjmedia_zero_samples(rport->tmp_up_buf, 
-			     this_port->info.samples_per_frame);
+			     PJMEDIA_PIA_SPF(&this_port->info));
 
 	/* Put frame to delay buffer */
@@ -739,5 +742,5 @@
 
     /* Not sure how to handle partial frame, so better reject for now */
-    PJ_ASSERT_RETURN(frame->size == this_port->info.bytes_per_frame,
+    PJ_ASSERT_RETURN(frame->size == PJMEDIA_PIA_AVG_FSZ(&this_port->info),
 		     PJ_EINVAL);
 
@@ -756,5 +759,5 @@
      */
     pjmedia_copy_samples(rport->tmp_up_buf, (const pj_int16_t*)frame->buf,
-		         this_port->info.samples_per_frame);
+		         PJMEDIA_PIA_SPF(&this_port->info));
 
     /* Put frame to delay buffer */
@@ -784,5 +787,5 @@
 
     /* Get frame from delay buffer */
-    frame->size = this_port->info.bytes_per_frame;
+    frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info);
     frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
     frame->timestamp.u64 = rport->buf[DIR_DOWNSTREAM].ts.u64;
