diff --git a/rtpdump.1 b/rtpdump.1 index 2ff7a39..94e5503 100644 --- a/rtpdump.1 +++ b/rtpdump.1 @@ -40,6 +40,7 @@ .Op Fl o Ar outfile .Op Fl t Ar minutes .Op Fl x Ar bytes +.Op Fl d Ar event_payload_id .Oo Ar address Oc Ns / Ns Ar port .Sh DESCRIPTION .Nm @@ -225,6 +226,10 @@ This is only applicable for the and .Cm hex formats. +.It Fl d Ar event_payload_id +Consider the dynamic payload id +.Ar event_payload_id +as the payload id for RTP Events .El .Sh EXAMPLES .Bd -literal diff --git a/rtpdump.c b/rtpdump.c index 6602635..3c9d708 100644 --- a/rtpdump.c +++ b/rtpdump.c @@ -73,12 +73,15 @@ typedef enum { F_ascii } t_format; + +int dyn_payload_rtpevent = 101; /* Default payload type for RTPEvent packets */ + static void usage(const char *argv0) { fprintf(stderr, "usage: %s " "[-F hex|ascii|rtcp|short|payload|dump|header] " "[-f infile] [-o outfile] [-t minutes] [-x bytes] " - "[address]/port > file\n", argv0); + "[-d event_payload_id] [address]/port > file\n", argv0); } @@ -264,6 +267,7 @@ static int parse_data(FILE *out, char *buf, int len) rtp_hdr_ext_t *ext; int i, ext_len; int hlen = 0; + char *payload_data = NULL; /* Show vat format packets. */ if (r->version == 0) { @@ -289,6 +293,29 @@ static int parse_data(FILE *out, char *buf, int len) for (i = 0; i < r->cc; i++) { fprintf(out, "csrc[%d]=0x%0lx ", i, r->csrc[i]); } + + /* Check if it is an RTPEvent Packet */ + if (dyn_payload_rtpevent == r->pt) + { + + payload_data = (char*)buf + 12 + (r->cc*4); + if (payload_data[0] == 10) + { + + payload_data[0] = '*'; + } + else if (payload_data[0] == 11) + { + payload_data[0] = '#'; + } + else + { + payload_data[0] += '0'; + } + fprintf(out, "dtmf=%c duration=%dms end=%d ", payload_data[0], ntohs(*(short*)(payload_data+2))/8,(payload_data[1]>>7)&0x1); + + } + if (r->x) { /* header extension */ ext = (rtp_hdr_ext_t *)((char *)buf + hlen); ext_len = ntohs(ext->len); @@ -532,7 +559,6 @@ void packet_handler(FILE *out, t_format format, int trunc, double dnow = tdbl(&now); int hlen; /* header length */ int offset; - switch(format) { case F_header: offset = (dnow - dstart) * 1000; @@ -639,7 +665,7 @@ int main(int argc, char *argv[]) extern double tdbl(struct timeval *); startupSocket(); - while ((c = getopt(argc, argv, "F:f:o:t:x:h")) != EOF) { + while ((c = getopt(argc, argv, "F:f:o:t:x:d:h")) != EOF) { switch(c) { /* output format */ case 'F': @@ -686,6 +712,11 @@ int main(int argc, char *argv[]) } break; + /* Dynamic Payload Type for RTPEVENT packets */ + case 'd': + dyn_payload_rtpevent = atoi(optarg); + break; + case '?': case 'h': usage(argv[0]);