*** C:\Lars\Ethereal-Dev\ethereal-2004-01-22\gtk\rtp_analysis.c	Fri Jan 23 17:17:59 2004
--- C:\Lars\Ethereal-Dev\ethereal-2004-01-22-dev\gtk\rtp_analysis.c	Fri Jan 23 17:18:50 2004
***************
*** 110,116 ****
  #endif
  } dialog_data_t;
  
! #define OK_TEXT "Ok"
  
  /* type of error when saving voice in a file didn't succeed */
  typedef enum {
--- 110,117 ----
  #endif
  } dialog_data_t;
  
! #define OK_TEXT "[ Ok ]"
! #define PT_UNDEFINED -1
  
  /* type of error when saving voice in a file didn't succeed */
  typedef enum {
***************
*** 146,151 ****
--- 147,153 ----
  	gboolean under;
  	gint cycles;
  	guint16 pt;
+ 	guint16 reg_pt;
  } tap_rtp_stat_t;
  
  /* status flags for the flags parameter in tap_rtp_stat_t */
***************
*** 154,159 ****
--- 156,163 ----
  #define STAT_FLAG_WRONG_SEQ   0x04
  #define STAT_FLAG_PT_CHANGE   0x08
  #define STAT_FLAG_PT_CN       0x10
+ #define STAT_FLAG_FOLLOW_PT_CN  0x20
+ #define STAT_FLAG_REG_PT_CHANGE  0x40
  
  typedef struct _tap_rtp_save_info_t {
  	FILE *fp;
***************
*** 243,248 ****
--- 247,254 ----
  	user_data->reversed.statinfo.start_time = 0;
  	user_data->forward.statinfo.time = 0;
  	user_data->reversed.statinfo.time = 0;
+ 	user_data->forward.statinfo.reg_pt = PT_UNDEFINED;
+ 	user_data->reversed.statinfo.reg_pt = PT_UNDEFINED;
  
  	user_data->forward.saveinfo.count = 0;
  	user_data->reversed.saveinfo.count = 0;
***************
*** 354,364 ****
  	if (rtpinfo->info_payload_type == PT_CN
  		|| rtpinfo->info_payload_type == PT_CN_OLD)
  		statinfo->flags |= STAT_FLAG_PT_CN;
  	if (rtpinfo->info_payload_type != statinfo->pt)
  		statinfo->flags |= STAT_FLAG_PT_CHANGE;
  
  	statinfo->pt = rtpinfo->info_payload_type;
! 	
  	/* store the current time and calculate the current jitter */
  	current_time = (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000;
  	current_jitter = statinfo->jitter + ( fabs (current_time - (statinfo->time) -
--- 360,373 ----
  	if (rtpinfo->info_payload_type == PT_CN
  		|| rtpinfo->info_payload_type == PT_CN_OLD)
  		statinfo->flags |= STAT_FLAG_PT_CN;
+ 	if (statinfo->pt == PT_CN
+ 		|| statinfo->pt == PT_CN_OLD)
+ 		statinfo->flags |= STAT_FLAG_FOLLOW_PT_CN;
  	if (rtpinfo->info_payload_type != statinfo->pt)
  		statinfo->flags |= STAT_FLAG_PT_CHANGE;
  
  	statinfo->pt = rtpinfo->info_payload_type;
! 
  	/* store the current time and calculate the current jitter */
  	current_time = (double)pinfo->fd->rel_secs + (double) pinfo->fd->rel_usecs/1000000;
  	current_jitter = statinfo->jitter + ( fabs (current_time - (statinfo->time) -
***************
*** 380,392 ****
  		statinfo->delta_timestamp = rtpinfo->info_timestamp - statinfo->timestamp;
  		statinfo->flags |= STAT_FLAG_MARKER;
  	}
! 	/* if neither then it is a normal packet */
! 	if (!(statinfo->first_packet) && !(rtpinfo->info_marker_set)) {
  		if (statinfo->delay > statinfo->max_delay) {
  			statinfo->max_delay = statinfo->delay;
  			statinfo->max_nr = pinfo->fd->num;
  		}
  	}
  
  	/* When calculating expected rtp packets the seq number can wrap around
  	* so we have to count the number of cycles
--- 389,419 ----
  		statinfo->delta_timestamp = rtpinfo->info_timestamp - statinfo->timestamp;
  		statinfo->flags |= STAT_FLAG_MARKER;
  	}
! 	/* is it a regular packet? */
! 	if (!(statinfo->flags & STAT_FLAG_FIRST)
! 		&& !(statinfo->flags & STAT_FLAG_MARKER)
! 		&& !(statinfo->flags & STAT_FLAG_PT_CN)
! 		&& !(statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)) {
! 		/* include it in maximum delay calculation */
  		if (statinfo->delay > statinfo->max_delay) {
  			statinfo->max_delay = statinfo->delay;
  			statinfo->max_nr = pinfo->fd->num;
  		}
  	}
+ 	/* regular payload change? (CN ignored) */
+ 	if (!(statinfo->flags & STAT_FLAG_FIRST)
+ 		&& !(statinfo->flags & STAT_FLAG_PT_CN)) {
+ 		if ((statinfo->pt != statinfo->reg_pt)
+ 			&& (statinfo->reg_pt != PT_UNDEFINED)) {
+ 			statinfo->flags |= STAT_FLAG_REG_PT_CHANGE;
+ 		}
+ 	}
+ 
+ 	/* set regular payload*/
+ 	if (!(statinfo->flags & STAT_FLAG_PT_CN)) {
+ 		statinfo->reg_pt = statinfo->pt;
+ 	}
+ 
  
  	/* When calculating expected rtp packets the seq number can wrap around
  	* so we have to count the number of cycles
***************
*** 452,457 ****
--- 479,489 ----
  }
  
  
+ static const GdkColor COLOR_DEFAULT = {0, 0xffff, 0xffff, 0xffff};
+ static const GdkColor COLOR_ERROR = {0, 0xffff, 0xbfff, 0xbfff};
+ static const GdkColor COLOR_WARNING = {0, 0xffff, 0xdfff, 0xbfff};
+ static const GdkColor COLOR_CN = {0, 0xbfff, 0xbfff, 0xffff};
+ 
  /****************************************************************************/
  /* adds statistics information from the packet to the clist */
  static int rtp_packet_add_info(GtkCList *clist,
***************
*** 462,468 ****
  	struct tm *tm_tmp;
  	time_t then;
  	gchar status[40];
! 	GdkColor color = {0, 0xffff, 0xffff, 0xffff};
  
  	then = pinfo->fd->abs_secs;
  	msecs = (guint16)(pinfo->fd->abs_usecs/1000);
--- 494,500 ----
  	struct tm *tm_tmp;
  	time_t then;
  	gchar status[40];
! 	GdkColor color = COLOR_DEFAULT;
  
  	then = pinfo->fd->abs_secs;
  	msecs = (guint16)(pinfo->fd->abs_usecs/1000);
***************
*** 478,512 ****
  
  	if (statinfo->pt == PT_CN) {
  		snprintf(status,40,"Comfort noise (PT=13, RFC 3389)");
! 		color.pixel = 0;
! 		color.red = 0x7fff;
! 		color.green = 0x7fff;
! 		color.blue = 0xffff;
  	}
  	else if (statinfo->pt == PT_CN_OLD) {
  		snprintf(status,40,"Comfort noise (PT=19, reserved)");
! 		color.pixel = 0;
! 		color.red = 0x7fff;
! 		color.green = 0x7fff;
! 		color.blue = 0xffff;
  	}
  	else if (statinfo->flags & STAT_FLAG_WRONG_SEQ) {
  		snprintf(status,40,"Wrong sequence nr.");
! 		color.pixel = 0;
! 		color.red = 0xffff;
! 		color.green = 0x7fff;
! 		color.blue = 0x7fff;
  	}
  	else if ((statinfo->flags & STAT_FLAG_PT_CHANGE)
  		&&  !(statinfo->flags & STAT_FLAG_FIRST)
! 		&&  !(statinfo->flags & STAT_FLAG_PT_CN)) {
! 		snprintf(status,40,"Payload type changed to PT=%u", statinfo->pt);
! 		color.pixel = 0;
! 		color.red = 0xffff;
! 		color.green = 0x7fff;
! 		color.blue = 0x7fff;
  	}
  	else {
  		snprintf(status,40,OK_TEXT);
  	}
  
--- 510,547 ----
  
  	if (statinfo->pt == PT_CN) {
  		snprintf(status,40,"Comfort noise (PT=13, RFC 3389)");
! 		color = COLOR_CN;
  	}
  	else if (statinfo->pt == PT_CN_OLD) {
  		snprintf(status,40,"Comfort noise (PT=19, reserved)");
! 		color = COLOR_CN;
  	}
  	else if (statinfo->flags & STAT_FLAG_WRONG_SEQ) {
  		snprintf(status,40,"Wrong sequence nr.");
! 		color = COLOR_ERROR;
! 	}
! /*
! 	else if ((statinfo->flags & STAT_FLAG_PT_CHANGE)
! 		&&  !(statinfo->flags & STAT_FLAG_FIRST)
! 		&&  !(statinfo->flags & STAT_FLAG_PT_CN)
! 		&&  !(statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)) {
! */
! 	else if (statinfo->flags & STAT_FLAG_REG_PT_CHANGE) {
! 		snprintf(status,40,"Payload changed to PT=%u", statinfo->pt);
! 		color = COLOR_WARNING;
  	}
  	else if ((statinfo->flags & STAT_FLAG_PT_CHANGE)
  		&&  !(statinfo->flags & STAT_FLAG_FIRST)
! 		&&  !(statinfo->flags & STAT_FLAG_PT_CN)
! 		&&  (statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)
! 		&&  !(statinfo->flags & STAT_FLAG_MARKER)) {
! 		snprintf(status,40,"Marker missing?", statinfo->pt);
! 		color = COLOR_WARNING;
  	}
  	else {
+ 		if (statinfo->flags & STAT_FLAG_MARKER) {
+ 			color = COLOR_WARNING;
+ 		}
  		snprintf(status,40,OK_TEXT);
  	}
  
***************
*** 1545,1562 ****
  	gint32 f_lost = f_expected - user_data->forward.statinfo.total_nr;
  	gint32 r_lost = r_expected - user_data->reversed.statinfo.total_nr;
  
! 	g_snprintf(label_max, 199, "Max delay = %f sec at packet no. %u \n\n"
  		"Total RTP packets = %u   (expected %u)   Lost RTP packets = %d"
  		"   Sequence errors = %u",
! 		user_data->forward.statinfo.max_delay, user_data->forward.statinfo.max_nr, user_data->forward.statinfo.total_nr,
  		f_expected, f_lost, user_data->forward.statinfo.sequence);
  
  	gtk_label_set_text(GTK_LABEL(user_data->dlg.label_stats_fwd), label_max);
  
! 	g_snprintf(label_max, 199, "Max delay = %f sec at packet no. %u \n\n"
  		"Total RTP packets = %u   (expected %u)   Lost RTP packets = %d"
  		"   Sequence errors = %u",
! 		user_data->reversed.statinfo.max_delay, user_data->reversed.statinfo.max_nr, user_data->reversed.statinfo.total_nr,
  		r_expected, r_lost, user_data->reversed.statinfo.sequence);
  
  	gtk_label_set_text(GTK_LABEL(user_data->dlg.label_stats_rev), label_max);
--- 1580,1599 ----
  	gint32 f_lost = f_expected - user_data->forward.statinfo.total_nr;
  	gint32 r_lost = r_expected - user_data->reversed.statinfo.total_nr;
  
! 	g_snprintf(label_max, 199, "Max delay = %f sec at packet no. %u \n"
  		"Total RTP packets = %u   (expected %u)   Lost RTP packets = %d"
  		"   Sequence errors = %u",
! 		user_data->forward.statinfo.max_delay, user_data->forward.statinfo.max_nr,
! 		user_data->forward.statinfo.total_nr,
  		f_expected, f_lost, user_data->forward.statinfo.sequence);
  
  	gtk_label_set_text(GTK_LABEL(user_data->dlg.label_stats_fwd), label_max);
  
! 	g_snprintf(label_max, 199, "Max delay = %f sec at packet no. %u \n"
  		"Total RTP packets = %u   (expected %u)   Lost RTP packets = %d"
  		"   Sequence errors = %u",
! 		user_data->reversed.statinfo.max_delay, user_data->reversed.statinfo.max_nr,
! 		user_data->reversed.statinfo.total_nr,
  		r_expected, r_lost, user_data->reversed.statinfo.sequence);
  
  	gtk_label_set_text(GTK_LABEL(user_data->dlg.label_stats_rev), label_max);
***************
*** 1797,1804 ****
  	SIGNAL_CONNECT(window, "destroy", on_destroy, user_data);
  
  	/* Container for each row of widgets */
! 	main_vb = gtk_vbox_new(FALSE, 3);
! 	gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
  	gtk_container_add(GTK_CONTAINER(window), main_vb);
  	gtk_widget_show(main_vb);
  
--- 1834,1841 ----
  	SIGNAL_CONNECT(window, "destroy", on_destroy, user_data);
  
  	/* Container for each row of widgets */
! 	main_vb = gtk_vbox_new(FALSE, 2);
! 	gtk_container_border_width(GTK_CONTAINER(main_vb), 2);
  	gtk_container_add(GTK_CONTAINER(window), main_vb);
  	gtk_widget_show(main_vb);
  
***************
*** 1807,1820 ****
  	strcpy(str_ip_dst, ip_to_str((ip_addr_p)&user_data->ip_dst_fwd));
  
  	g_snprintf(label_forward, 149, 
! 		"Analysing stream from  %s port %u  to  %s port %u   SSRC = %u\n", 
  		str_ip_src, user_data->port_src_fwd, str_ip_dst, user_data->port_dst_fwd, user_data->ssrc_fwd);
  
  	strcpy(str_ip_src, ip_to_str((ip_addr_p)&user_data->ip_src_rev));
  	strcpy(str_ip_dst, ip_to_str((ip_addr_p)&user_data->ip_dst_rev));
  
  	g_snprintf(label_reverse, 149,
! 		"Analysing stream from  %s port %u  to  %s port %u   SSRC = %u\n", 
  		str_ip_src, user_data->port_src_rev, str_ip_dst, user_data->port_dst_rev, user_data->ssrc_rev);
  
  	/* Start a notebook for flipping between sets of changes */
--- 1844,1857 ----
  	strcpy(str_ip_dst, ip_to_str((ip_addr_p)&user_data->ip_dst_fwd));
  
  	g_snprintf(label_forward, 149, 
! 		"Analysing stream from  %s port %u  to  %s port %u   SSRC = %u", 
  		str_ip_src, user_data->port_src_fwd, str_ip_dst, user_data->port_dst_fwd, user_data->ssrc_fwd);
  
  	strcpy(str_ip_src, ip_to_str((ip_addr_p)&user_data->ip_src_rev));
  	strcpy(str_ip_dst, ip_to_str((ip_addr_p)&user_data->ip_dst_rev));
  
  	g_snprintf(label_reverse, 149,
! 		"Analysing stream from  %s port %u  to  %s port %u   SSRC = %u", 
  		str_ip_src, user_data->port_src_rev, str_ip_dst, user_data->port_dst_rev, user_data->ssrc_rev);
  
  	/* Start a notebook for flipping between sets of changes */
***************
*** 1825,1844 ****
                         user_data);
  
  	/* page for forward connection */
! 	page = gtk_vbox_new(FALSE, 5);
! 	gtk_container_set_border_width(GTK_CONTAINER(page), 20);
  
  	/* direction label */
  	label = gtk_label_new(label_forward);
  	gtk_box_pack_start(GTK_BOX(page), label, FALSE, FALSE, 0);
  
  	/* place for some statistics */
! 	label_stats_fwd = gtk_label_new("\n\n");
! 	gtk_box_pack_end(GTK_BOX(page), label_stats_fwd, FALSE, FALSE, 5);
  
  	/* scrolled window */
  	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
! 	WIDGET_SET_SIZE(scrolled_window, 520, 200);
  	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), 
  		GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  
--- 1862,1881 ----
                         user_data);
  
  	/* page for forward connection */
! 	page = gtk_vbox_new(FALSE, 8);
! 	gtk_container_set_border_width(GTK_CONTAINER(page), 8);
  
  	/* direction label */
  	label = gtk_label_new(label_forward);
  	gtk_box_pack_start(GTK_BOX(page), label, FALSE, FALSE, 0);
  
  	/* place for some statistics */
! 	label_stats_fwd = gtk_label_new("\n");
! 	gtk_box_pack_end(GTK_BOX(page), label_stats_fwd, FALSE, FALSE, 0);
  
  	/* scrolled window */
  	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
! 	WIDGET_SET_SIZE(scrolled_window, 560, 200);
  	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), 
  		GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  
***************
*** 1854,1868 ****
  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
  
  	/* same page for reversed connection */
! 	page_r = gtk_vbox_new(FALSE, 5);
! 	gtk_container_set_border_width(GTK_CONTAINER(page_r), 20);
  	label = gtk_label_new(label_reverse);
  	gtk_box_pack_start(GTK_BOX(page_r), label, FALSE, FALSE, 0);
! 	label_stats_rev = gtk_label_new("\n\n");
! 	gtk_box_pack_end(GTK_BOX(page_r), label_stats_rev, FALSE, FALSE, 5);
  
  	scrolled_window_r = gtk_scrolled_window_new(NULL, NULL);
! 	WIDGET_SET_SIZE(scrolled_window_r, 600, 200);
  	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window_r), 
  		GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  
--- 1891,1905 ----
  	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
  
  	/* same page for reversed connection */
! 	page_r = gtk_vbox_new(FALSE, 8);
! 	gtk_container_set_border_width(GTK_CONTAINER(page_r), 8);
  	label = gtk_label_new(label_reverse);
  	gtk_box_pack_start(GTK_BOX(page_r), label, FALSE, FALSE, 0);
! 	label_stats_rev = gtk_label_new("\n");
! 	gtk_box_pack_end(GTK_BOX(page_r), label_stats_rev, FALSE, FALSE, 0);
  
  	scrolled_window_r = gtk_scrolled_window_new(NULL, NULL);
! 	WIDGET_SET_SIZE(scrolled_window_r, 560, 200);
  	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window_r), 
  		GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  
