RTP updates.

Merge rtp_sample_header_t into rtp_sample_t. That's the only place it
was used. Note that rtp_sample_t is used for writing rtpdump files.

Move the rtp_sample_t definition to tap-rtp-common.c. Rename it to
rtpdump_info_t. Make rtp_write_sample static.

Change-Id: I04e7428f634efa87a98e5d6c82a354f94ab1765d
Reviewed-on: https://code.wireshark.org/review/9629
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-07-13 11:56:20 -07:00
parent bed3163725
commit ef3cc4a2c1
4 changed files with 19 additions and 29 deletions

View File

@ -159,7 +159,7 @@ static PaStream *pa_stream;
typedef struct _rtp_channel_info {
nstime_t start_time_abs;
nstime_t stop_time_abs;
GArray *samples; /* the array with decoded audio */
GArray *samples; /* Array of sample_t (decoded audio) */
guint16 call_num;
gboolean selected;
unsigned long frame_index;

View File

@ -44,23 +44,6 @@ extern "C" {
#include <epan/address.h>
#include <epan/tap.h>
/****************************************************************************/
/* type for storing rtp frame information */
typedef struct st_rtp_sample_header {
double rec_time; /**< milliseconds since start of recording */
guint16 frame_length; /**< number of bytes in *frame */
} rtp_sample_header_t;
/** type for storing rtp frame information */
typedef struct st_rtp_sample {
rtp_sample_header_t header; /**< date and size */
const guint8 *frame; /**< data bytes */
} rtp_sample_t;
typedef rtp_sample_t* rtp_sample_p;
/** Defines an rtp stream */
typedef struct _rtp_stream_info {
address src_addr;

View File

@ -44,6 +44,14 @@
E.G., when captured frames are truncated.
*/
/****************************************************************************/
/* Type for storing and writing rtpdump information */
typedef struct st_rtpdump_info {
double rec_time; /**< milliseconds since start of recording */
guint16 num_samples; /**< number of bytes in *frame */
const guint8 *samples; /**< data bytes */
} rtpdump_info_t;
/****************************************************************************/
/* GCompareFunc style comparison function for _rtp_stream_info */
static gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
@ -158,16 +166,16 @@ void rtp_write_header(rtp_stream_info_t *strinfo, FILE *file)
}
/* utility function for writing a sample to file in rtpdump -F dump format (.rtp)*/
void rtp_write_sample(rtp_sample_t* sample, FILE* file)
static void rtp_write_sample(rtpdump_info_t* rtpdump_info, FILE* file)
{
guint16 length; /* length of packet, including this header (may
be smaller than plen if not whole packet recorded) */
guint16 plen; /* actual header+payload length for RTP, 0 for RTCP */
guint32 offset; /* milliseconds since the start of recording */
length = g_htons(sample->header.frame_length + 8);
plen = g_htons(sample->header.frame_length);
offset = g_htonl(sample->header.rec_time);
length = g_htons(rtpdump_info->num_samples + 8);
plen = g_htons(rtpdump_info->num_samples);
offset = g_htonl(rtpdump_info->rec_time);
if (fwrite(&length, 2, 1, file) == 0)
return;
@ -175,7 +183,7 @@ void rtp_write_sample(rtp_sample_t* sample, FILE* file)
return;
if (fwrite(&offset, 4, 1, file) == 0)
return;
if (fwrite(sample->frame, sample->header.frame_length, 1, file) == 0)
if (fwrite(rtpdump_info->samples, rtpdump_info->num_samples, 1, file) == 0)
return;
}
@ -189,7 +197,7 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con
rtp_stream_info_t new_stream_info;
rtp_stream_info_t *stream_info = NULL;
GList* list;
rtp_sample_t sample;
rtpdump_info_t rtpdump_info;
struct _rtp_conversation_info *p_conv_data = NULL;
@ -257,11 +265,11 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con
if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0) {
/* XXX - what if rtpinfo->info_all_data_present is
FALSE, so that we don't *have* all the data? */
sample.header.rec_time = nstime_to_msec(&pinfo->fd->abs_ts) -
rtpdump_info.rec_time = nstime_to_msec(&pinfo->fd->abs_ts) -
nstime_to_msec(&tapinfo->filter_stream_fwd->start_fd->abs_ts);
sample.header.frame_length = rtpinfo->info_data_len;
sample.frame = rtpinfo->info_data;
rtp_write_sample(&sample, tapinfo->save_file);
rtpdump_info.num_samples = rtpinfo->info_data_len;
rtpdump_info.samples = rtpinfo->info_data;
rtp_write_sample(&rtpdump_info, tapinfo->save_file);
}
}
else if (tapinfo->mode == TAP_MARK && tapinfo->tap_mark_packet) {

View File

@ -32,7 +32,6 @@
void rtpstream_reset_cb(void*);
void rtp_write_header(rtp_stream_info_t*, FILE*);
void rtp_write_sample(rtp_sample_t*, FILE*);
int rtpstream_packet(void*, packet_info*, epan_dissect_t *, const void *);
#endif /*TAP_RTP_COMMON_H_INCLUDED*/