Use the sample rate from SDP info in RTP stream analysis.

svn path=/trunk/; revision=32466
This commit is contained in:
Anders Broman 2010-04-14 20:48:37 +00:00
parent b09f79f414
commit 83ce037aa9
7 changed files with 91 additions and 29 deletions

View File

@ -323,6 +323,13 @@ static void update_unicast_addr(unicast_addr_t *req_addr, unicast_addr_t *ack_ad
}
}
static void free_encoding_name_str (encoding_name_and_rate_t *encoding_name_and_rate)
{
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel_lcl)
{
gint *key;
@ -343,10 +350,13 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
/* (S)RTP, (S)RTCP */
if (upcoming_channel_lcl->rfc2198 > 0) {
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
encoding_name_and_rate_t *encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
encoding_name_and_rate->encoding_name = g_strdup("red");
encoding_name_and_rate->sample_rate = 8000;
key = g_malloc(sizeof(gint));
*key = upcoming_channel_lcl->rfc2198;
g_hash_table_insert(rtp_dyn_payload, key, g_strdup("red"));
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
}
if (upcoming_channel_lcl->srtp_flag) {

View File

@ -8062,6 +8062,13 @@ elem_a2p_bearer_session(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint l
/*
* IOS 5 4.2.90
*/
static void free_encoding_name_str (encoding_name_and_rate_t *encoding_name_and_rate)
{
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static guint8
elem_a2p_bearer_format(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
{
@ -8081,7 +8088,7 @@ elem_a2p_bearer_format(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint le
GHashTable *rtp_dyn_payload;
gint *key;
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
first_assigned_found = FALSE;
@ -8305,9 +8312,13 @@ elem_a2p_bearer_format(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint le
format_assigned &&
(first_assigned_found == FALSE))
{
encoding_name_and_rate_t *encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
key = (gint *)g_malloc(sizeof(gint));
*key = rtp_payload_type;
g_hash_table_insert(rtp_dyn_payload, key, g_strdup(mime_type));
encoding_name_and_rate->encoding_name = g_strdup(mime_type);
/* Assumtion; all pt:s above have a sample rate of 8000 */
encoding_name_and_rate->sample_rate = 8000;
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
first_assigned_found = TRUE;

View File

@ -454,6 +454,13 @@ static void update_unicast_addr(unicast_addr_t *req_addr, unicast_addr_t *ack_ad
}
}
static void free_encoding_name_str (encoding_name_and_rate_t *encoding_name_and_rate)
{
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel_lcl)
{
gint *key;
@ -474,10 +481,13 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
/* (S)RTP, (S)RTCP */
if (upcoming_channel_lcl->rfc2198 > 0) {
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
encoding_name_and_rate_t *encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
encoding_name_and_rate->encoding_name = g_strdup("red");
encoding_name_and_rate->sample_rate = 8000;
key = g_malloc(sizeof(gint));
*key = upcoming_channel_lcl->rfc2198;
g_hash_table_insert(rtp_dyn_payload, key, g_strdup("red"));
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
}
if (upcoming_channel_lcl->srtp_flag) {
@ -1905,7 +1915,7 @@ static int hf_h245_encrypted = -1; /* OCTET_STRING */
static int hf_h245_encryptedAlphanumeric = -1; /* EncryptedAlphanumeric */
/*--- End of included file: packet-h245-hf.c ---*/
#line 373 "packet-h245-template.c"
#line 383 "packet-h245-template.c"
/* Initialize the subtree pointers */
static int ett_h245 = -1;
@ -2406,7 +2416,7 @@ static gint ett_h245_FlowControlIndication = -1;
static gint ett_h245_MobileMultilinkReconfigurationIndication = -1;
/*--- End of included file: packet-h245-ett.c ---*/
#line 378 "packet-h245-template.c"
#line 388 "packet-h245-template.c"
/* Forward declarations */
static int dissect_h245_MultimediaSystemControlMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
@ -14451,7 +14461,7 @@ static void dissect_OpenLogicalChannel_PDU(tvbuff_t *tvb _U_, packet_info *pinfo
/*--- End of included file: packet-h245-fn.c ---*/
#line 387 "packet-h245-template.c"
#line 397 "packet-h245-template.c"
static void
dissect_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
@ -20132,7 +20142,7 @@ void proto_register_h245(void) {
"h245.EncryptedAlphanumeric", HFILL }},
/*--- End of included file: packet-h245-hfarr.c ---*/
#line 463 "packet-h245-template.c"
#line 473 "packet-h245-template.c"
};
/* List of subtrees */
@ -20635,7 +20645,7 @@ void proto_register_h245(void) {
&ett_h245_MobileMultilinkReconfigurationIndication,
/*--- End of included file: packet-h245-ettarr.c ---*/
#line 470 "packet-h245-template.c"
#line 480 "packet-h245-template.c"
};
module_t *h245_module;

View File

@ -649,7 +649,9 @@ process_rtp_payload(tvbuff_t *newtvb, packet_info *pinfo, proto_tree *tree,
else if ( (payload_type >= PT_UNDF_96 && payload_type <= PT_UNDF_127) ) {
if (p_conv_data && p_conv_data->rtp_dyn_payload) {
gchar *payload_type_str = NULL;
payload_type_str = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
encoding_name_and_rate_pt = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
payload_type_str = encoding_name_and_rate_pt->encoding_name;
if (payload_type_str){
found_match = dissector_try_string(rtp_dyn_pt_dissector_table,
payload_type_str, newtvb, pinfo, tree);
@ -934,7 +936,9 @@ dissect_rtp_rfc2198(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
/* if it is dynamic payload, let use the conv data to see if it is defined */
if ((hdr_new->pt > 95) && (hdr_new->pt < 128)) {
if (p_conv_data && p_conv_data->rtp_dyn_payload){
encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
payload_type_str = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &hdr_new->pt);
payload_type_str = encoding_name_and_rate_pt->encoding_name;
}
}
/* Add a subtree for this header and add items */
@ -1100,6 +1104,7 @@ dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
rtp_info->info_is_srtp = FALSE;
rtp_info->info_setup_frame_num = 0;
rtp_info->info_payload_type_str = NULL;
rtp_info->info_payload_rate = 0;
/*
* Do we have all the data?
@ -1162,8 +1167,10 @@ dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
/* if it is dynamic payload, let use the conv data to see if it is defined */
if ( (payload_type>95) && (payload_type<128) ) {
if (p_conv_data && p_conv_data->rtp_dyn_payload){
payload_type_str = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
rtp_info->info_payload_type_str = payload_type_str;
encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
encoding_name_and_rate_pt = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
rtp_info->info_payload_type_str = encoding_name_and_rate_pt->encoding_name;
rtp_info->info_payload_rate = encoding_name_and_rate_pt->sample_rate;
}
}

View File

@ -45,6 +45,7 @@ struct _rtp_info {
guint32 info_setup_frame_num; /* the frame num of the packet that set this RTP connection */
const guint8* info_data; /* pointer to raw rtp data */
gchar *info_payload_type_str;
gint info_payload_rate;
/*
* info_data: pointer to raw rtp data = header + payload incl. padding.
* That should be safe because the "epan_dissect_t" constructed for the packet
@ -114,6 +115,11 @@ struct _rtp_conversation_info
struct srtp_info *srtp_info; /* SRTP context */
};
typedef struct {
char *encoding_name;
int sample_rate;
} encoding_name_and_rate_t;
/* Add an RTP conversation with the given details */
void rtp_add_address(packet_info *pinfo,
address *addr, int port,

View File

@ -208,8 +208,8 @@ typedef struct {
char *connection_address;
char *connection_type;
char *media_type;
char *encoding_name[SDP_NO_OF_PT];
char *encoding_name_and_rate[SDP_NO_OF_PT];
char *encoding_name[SDP_NO_OF_PT];
int sample_rate[SDP_NO_OF_PT];
char *media_port[SDP_MAX_RTP_CHANNELS];
char *media_proto[SDP_MAX_RTP_CHANNELS];
transport_media_pt_t media[SDP_MAX_RTP_CHANNELS];
@ -253,6 +253,13 @@ static void dissect_sdp_media(tvbuff_t *tvb, proto_item *ti,
transport_info_t *transport_info);
static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_item *ti, int length,transport_info_t *transport_info);
static void free_encoding_name_str (encoding_name_and_rate_t *encoding_name_and_rate)
{
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void
dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
@ -297,7 +304,7 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
transport_info.media_type=NULL;
for (n=0; n < SDP_NO_OF_PT; n++){
transport_info.encoding_name[n]=unknown_encoding;
transport_info.encoding_name_and_rate[n]=unknown_encoding;
transport_info.sample_rate[n] = 0;
}
for (n=0; n < SDP_MAX_RTP_CHANNELS; n++)
{
@ -305,7 +312,7 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
transport_info.media_proto[n]=NULL;
transport_info.media[n].pt_count = 0;
transport_info.media[n].rtp_dyn_payload =
g_hash_table_new_full( g_int_hash, g_int_equal, g_free, g_free);
g_hash_table_new_full( g_int_hash, g_int_equal, g_free, free_encoding_name_str);
}
transport_info.media_count = 0;
@ -539,9 +546,9 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* if the payload type is dynamic (96 to 127), check the hash table to add the desc in the SDP summary */
if ( (transport_info.media[n].pt[i] >=96) && (transport_info.media[n].pt[i] <=127) ) {
gchar *str_dyn_pt = g_hash_table_lookup(transport_info.media[n].rtp_dyn_payload, &transport_info.media[n].pt[i]);
if (str_dyn_pt)
g_snprintf(sdp_pi->summary_str, 50, "%s %s", sdp_pi->summary_str, str_dyn_pt);
encoding_name_and_rate_t *encoding_name_and_rate_pt = g_hash_table_lookup(transport_info.media[n].rtp_dyn_payload, &transport_info.media[n].pt[i]);
if (encoding_name_and_rate_pt)
g_snprintf(sdp_pi->summary_str, 50, "%s %s", sdp_pi->summary_str, encoding_name_and_rate_pt->encoding_name);
else
g_snprintf(sdp_pi->summary_str, 50, "%s %d", sdp_pi->summary_str, transport_info.media[n].pt[i]);
} else
@ -1476,6 +1483,7 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
const char *h324ext_h223lcparm = "h324ext/h223lcparm";
gboolean has_more_pars = TRUE;
tvbuff_t *h245_tvb;
encoding_name_and_rate_t *encoding_name_and_rate;
offset = 0;
next_offset = 0;
@ -1555,11 +1563,10 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
break;
next_offset++;
}
transport_info->encoding_name_and_rate[pt] = (char*)tvb_get_ephemeral_string(tvb, start_offset, next_offset - start_offset);
proto_tree_add_text(sdp_media_attribute_tree, tvb, start_offset, next_offset - start_offset, "[Debug: %s]",transport_info->encoding_name_and_rate[pt]);
tokenlen = next_offset - offset;
proto_tree_add_item(sdp_media_attribute_tree, hf_media_sample_rate, tvb,
offset, tokenlen, FALSE);
transport_info->sample_rate[pt] = atoi(tvb_get_ephemeral_string(tvb, offset, tokenlen));
/* As per RFC2327 it is possible to have multiple Media Descriptions ("m=").
For example:
@ -1579,27 +1586,34 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
*/
if (transport_info->media_count == 0) {
for (n=0; n < SDP_MAX_RTP_CHANNELS; n++) {
if (n==0)
encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate->sample_rate = transport_info->sample_rate[pt];
if (n==0){
g_hash_table_insert(transport_info->media[n].rtp_dyn_payload,
key, g_strdup(transport_info->encoding_name[pt]));
key, encoding_name_and_rate);
}
else { /* we create a new key and encoding_name to assign to the other hash tables */
gint *key2;
key2=g_malloc( sizeof(gint) );
*key2=atol((char*)payload_type);
g_hash_table_insert(transport_info->media[n].rtp_dyn_payload,
key2, g_strdup(transport_info->encoding_name[pt]));
key2, encoding_name_and_rate);
}
}
return;
/* if the "a=" is after an "m=", only apply to this "m=" */
}else
/* in case there is an overflow in SDP_MAX_RTP_CHANNELS, we keep always the last "m=" */
encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate->sample_rate = transport_info->sample_rate[pt];
if (transport_info->media_count == SDP_MAX_RTP_CHANNELS-1)
g_hash_table_insert(transport_info->media[ transport_info->media_count ].rtp_dyn_payload,
key, g_strdup(transport_info->encoding_name[pt]));
key, encoding_name_and_rate);
else
g_hash_table_insert(transport_info->media[ transport_info->media_count-1 ].rtp_dyn_payload,
key, g_strdup(transport_info->encoding_name[pt]));
key, encoding_name_and_rate);
break;
case SDP_FMTP:
if(sdp_media_attribute_tree){

View File

@ -571,7 +571,11 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
clock_rate = 0;
statinfo->flags |= STAT_FLAG_PT_T_EVENT;
}else{
clock_rate = get_dyn_pt_clock_rate(rtpinfo-> info_payload_type_str);
if(rtpinfo->info_payload_rate !=0){
clock_rate = rtpinfo->info_payload_rate;
}else{
clock_rate = get_dyn_pt_clock_rate(rtpinfo-> info_payload_type_str);
}
}
}else{
clock_rate = 0;