Index: gtk/rtp_analysis.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/rtp_analysis.c,v
retrieving revision 1.28
diff -u -r1.28 rtp_analysis.c
--- gtk/rtp_analysis.c	27 Jan 2004 18:05:32 -0000	1.28
+++ gtk/rtp_analysis.c	30 Jan 2004 17:03:39 -0000
@@ -313,12 +313,12 @@
 	tap_rtp_stat_t *statinfo, packet_info *pinfo, struct _rtp_info *rtpinfo);
 static int rtp_packet_save_payload(tap_rtp_save_info_t *saveinfo, 
 								   tap_rtp_stat_t *statinfo,
-								   packet_info *pinfo, struct _rtp_info *rtpinfo);
+								   packet_info *pinfo, epan_dissect_t *edt, struct _rtp_info *rtpinfo);
 
 
 /****************************************************************************/
 /* whenever a RTP packet is seen by the tap listener */
-static int rtp_packet(void *user_data_arg, packet_info *pinfo, epan_dissect_t *edt _U_, void *rtpinfo_arg)
+static int rtp_packet(void *user_data_arg, packet_info *pinfo, epan_dissect_t *edt, void *rtpinfo_arg)
 {
 	user_data_t *user_data = user_data_arg;
 	struct _rtp_info *rtpinfo = rtpinfo_arg;
@@ -341,7 +341,7 @@
 		rtp_packet_add_info(user_data->dlg.clist_fwd,
 			&(user_data->forward.statinfo), pinfo, rtpinfo);
 		rtp_packet_save_payload(&(user_data->forward.saveinfo),
-			&(user_data->forward.statinfo), pinfo, rtpinfo);
+			&(user_data->forward.statinfo), pinfo, edt, rtpinfo);
 	}
 	/* is it the reversed direction? */
 	else if (user_data->ssrc_rev == rtpinfo->info_sync_src) {
@@ -354,7 +354,7 @@
 		rtp_packet_add_info(user_data->dlg.clist_rev,
 			&(user_data->reversed.statinfo), pinfo, rtpinfo);
 		rtp_packet_save_payload(&(user_data->reversed.saveinfo),
-			&(user_data->reversed.statinfo), pinfo, rtpinfo);
+			&(user_data->reversed.statinfo), pinfo, edt, rtpinfo);
 	}
 
 	return 0;
@@ -582,10 +582,10 @@
 /****************************************************************************/
 static int rtp_packet_save_payload(tap_rtp_save_info_t *saveinfo, 
 								   tap_rtp_stat_t *statinfo,
-								   packet_info *pinfo, struct _rtp_info *rtpinfo)
+								   packet_info *pinfo, epan_dissect_t *edt, struct _rtp_info *rtpinfo)
 {
 	guint i;
-	guint8 *data;
+	guint8 data[WTAP_MAX_PACKET_SIZE];
 	gint16 tmp;
 
 	/*  is this the first packet we got in this direction? */
@@ -620,6 +620,21 @@
 		return 0;
 	}
 
+	/* we extract from the beggining of the RTP data, that is
+	 * at the end of the current frame minus the length of the
+	 * padding count minus length of the RTP data */
+	tvb_memcpy(edt->tvb, data, pinfo->fd->pkt_len - rtpinfo->info_payload_len, rtpinfo->info_payload_len);
+
+	/* dynamically assigned payload? */
+	if (rtpinfo->info_payload_type >= 96
+		&& rtpinfo->info_payload_type <= 127) {
+		fwrite(data, rtpinfo->info_payload_len - rtpinfo->info_padding_count, 1, saveinfo->fp);
+		fflush(saveinfo->fp);
+		saveinfo->count += rtpinfo->info_payload_len - rtpinfo->info_padding_count;
+		saveinfo->saved = TRUE;
+		return 0;
+	}
+
 	/* do we need to insert some silence? */
 	if ((rtpinfo->info_marker_set) &&
 		!(statinfo->flags & STAT_FLAG_FIRST) &&
@@ -639,12 +654,8 @@
 
 	/* ulaw? */
 	if (rtpinfo->info_payload_type == PT_PCMU) {
-		/* we put the pointer at the beggining of the RTP data, that is
-		* at the end of the current frame minus the length of the
-		* padding count minus length of the RTP data */
-		data = cfile.pd + (pinfo->fd->pkt_len - rtpinfo->info_payload_len);
-		for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++, data++) {
-			tmp = (gint16 )ulaw2linear((unsigned char)*data);
+		for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++) {
+			tmp = (gint16 )ulaw2linear(data[i]);
 			fwrite(&tmp, 2, 1, saveinfo->fp);
 			saveinfo->count++;
 		}
@@ -655,9 +666,8 @@
 
 	/* alaw? */
 	else if (rtpinfo->info_payload_type == PT_PCMA) {
-		data = cfile.pd + (pinfo->fd->pkt_len - rtpinfo->info_payload_len);
-		for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++, data++) {
-			tmp = (gint16 )alaw2linear((unsigned char)*data);
+		for(i=0; i < (rtpinfo->info_payload_len - rtpinfo->info_padding_count); i++) {
+			tmp = (gint16 )alaw2linear(data[i]);
 			fwrite(&tmp, 2, 1, saveinfo->fp);
 			saveinfo->count++;
 		}
@@ -1471,27 +1481,39 @@
 			"Can't save reversed direction in a file: File I/O problem!");
 		return;
 	}
-	
-	/*if (GTK_TOGGLE_BUTTON (wav)->active)
-	format = 1;
-	else if (GTK_TOGGLE_BUTTON (au)->active)
-	format = 2;
-	else if (GTK_TOGGLE_BUTTON (sw)->active)
-	format = 3;*/
-	
-	if (GTK_TOGGLE_BUTTON (rev)->active)
-		channels = 2;
-	else if (GTK_TOGGLE_BUTTON (both)->active)
-		channels = 3;
-	else 
-		channels = 1;
-	
-	if(!copy_file(g_dest, channels/*, format*/, user_data)) {
-		simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL, NULL,
-			"An error occured while saving voice in a file!");
-		return;
+
+	if (user_data->forward.statinfo.pt >= 96
+		&& user_data->forward.statinfo.pt <= 127) {
+		char buffer[256];
+
+		if (snprintf(buffer, sizeof buffer, "cp -f %s %s", user_data->f_tempname, g_dest) >= sizeof buffer
+			|| system(buffer) < 0) {
+			simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL, NULL,
+				"An error occured while saving the raw RTP stream in a file!");
+		}
+	} else {
+/*		if (GTK_TOGGLE_BUTTON (wav)->active)
+			format = 1;
+		else if (GTK_TOGGLE_BUTTON (au)->active)
+			format = 2;
+		else if (GTK_TOGGLE_BUTTON (sw)->active)
+			format = 3;
+*/
+
+		if (GTK_TOGGLE_BUTTON (rev)->active)
+			channels = 2;
+		else if (GTK_TOGGLE_BUTTON (both)->active)
+			channels = 3;
+		else
+			channels = 1;
+
+		if(!copy_file(g_dest, channels/*, format*/, user_data)) {
+			simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL, NULL,
+				"An error occured while saving voice in a file!");
+			return;
+		}
 	}
-	
+
 	gtk_widget_destroy(GTK_WIDGET(user_data->dlg.save_voice_as_w));
 }
 
