diff options
author | Peter Wu <peter@lekensteyn.nl> | 2016-12-05 23:00:33 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-12-06 08:59:56 +0000 |
commit | 104b9fe5afc1f7aac1df263dd8e9af1fd1cb449f (patch) | |
tree | 6f1f97924a8bfac01209491702c435e4616e58cb | |
parent | 89bc07c5d59ead31cad3ab5eea4378b6bb60bce9 (diff) | |
download | wireshark-104b9fe5afc1f7aac1df263dd8e9af1fd1cb449f.tar.gz |
rtp: add function to duplicate rtp_dyn_payload_t
There is no way to iterate through the contents. For a future patch to
the SDP dissector (where the session-level info is copied to the
media-level), it would be nice to duplicate the dynamic payload info.
Change-Id: I79b8349e5e157298a28fc608e20c2c2e03e76400
Reviewed-on: https://code.wireshark.org/review/19106
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-rtp.c | 21 | ||||
-rw-r--r-- | epan/dissectors/packet-rtp.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c index ab01da6cde..2efc2deed4 100644 --- a/epan/dissectors/packet-rtp.c +++ b/epan/dissectors/packet-rtp.c @@ -1006,6 +1006,27 @@ rtp_dyn_payload_t* rtp_dyn_payload_new(void) return rtp_dyn_payload; } +/* Creates a copy of the given dynamic payload information. */ +rtp_dyn_payload_t* rtp_dyn_payload_dup(rtp_dyn_payload_t *rtp_dyn_payload) +{ + rtp_dyn_payload_t *rtp_dyn_payload2 = rtp_dyn_payload_new(); + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init(&iter, rtp_dyn_payload->table); + while (g_hash_table_iter_next(&iter, &key, &value)) { + const guint pt = GPOINTER_TO_UINT(key); + encoding_name_and_rate_t *encoding_name_and_rate_pt = + (encoding_name_and_rate_t *)value; + + rtp_dyn_payload_insert(rtp_dyn_payload2, pt, + encoding_name_and_rate_pt->encoding_name, + encoding_name_and_rate_pt->sample_rate); + } + + return rtp_dyn_payload2; +} + static rtp_dyn_payload_t* rtp_dyn_payload_ref(rtp_dyn_payload_t *rtp_dyn_payload) { diff --git a/epan/dissectors/packet-rtp.h b/epan/dissectors/packet-rtp.h index 23aba7cf4d..b695c3a6a2 100644 --- a/epan/dissectors/packet-rtp.h +++ b/epan/dissectors/packet-rtp.h @@ -120,6 +120,9 @@ typedef struct _rtp_dyn_payload_t rtp_dyn_payload_t; WS_DLL_PUBLIC rtp_dyn_payload_t* rtp_dyn_payload_new(void); +/* Creates a copy of the given dynamic payload information. */ +rtp_dyn_payload_t* rtp_dyn_payload_dup(rtp_dyn_payload_t *rtp_dyn_payload); + /* Inserts the given payload type key, for the encoding name and sample rate, into the hash table. This makes copies of the encoding name, scoped to the life of the capture file or sooner if rtp_dyn_payload_free is called. */ |