1 /* rtp_media.h
2  *
3  * RTP decoding routines for Wireshark.
4  * Copied from ui/gtk/rtp_player.c
5  *
6  * Copyright 2006, Alejandro Vaquero <alejandrovaquero@yahoo.com>
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1999 Gerald Combs
11  *
12  * SPDX-License-Identifier: GPL-2.0-or-later
13  */
14 
15 #ifndef __RTP_MEDIA_H__
16 #define __RTP_MEDIA_H__
17 
18 #include <glib.h>
19 
20 /** @file
21  *  "RTP Player" dialog box common routines.
22  *  @ingroup main_ui_group
23  */
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28 
29 /****************************************************************************/
30 /* INTERFACE */
31 /****************************************************************************/
32 
33 typedef gint16 SAMPLE;
34 #define SAMPLE_MAX G_MAXINT16
35 #define SAMPLE_MIN G_MININT16
36 #define SAMPLE_NaN SAMPLE_MIN
37 #define SAMPLE_BYTES (sizeof(SAMPLE) / sizeof(char))
38 
39 /* Defines an RTP packet */
40 typedef struct _rtp_packet {
41     guint32 frame_num;      /* Qt only */
42     struct _rtp_info *info;	/* the RTP dissected info */
43     double arrive_offset;	/* arrive offset time since the beginning of the stream as ms in GTK UI and s in Qt UI */
44     guint8* payload_data;
45 } rtp_packet_t;
46 
47 /** Create a new hash table.
48  *
49  * @return A new hash table suitable for passing to decode_rtp_packet.
50  */
51 GHashTable *rtp_decoder_hash_table_new(void);
52 
53 /** Decode payload from an RTP packet
54  *
55  * @param payload_type Payload number
56  * @param payload_type_str Payload name, can be NULL
57  * @param payload_data Payload
58  * @param payload_len Length of payload
59  * @param out_buff Output audio samples.
60  * @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
61  * @param channels_ptr If non-NULL, receives the number of channels in the sample.
62  * @param sample_rate_ptr If non-NULL, receives the sample rate.
63  * @return The number of decoded bytes on success, 0 on failure.
64  */
65 size_t decode_rtp_packet_payload(guint8 payload_type, const gchar *payload_type_str, guint8 *payload_data, size_t payload_len, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr);
66 
67 /** Decode an RTP packet
68  *
69  * @param rp Wrapper for per-packet RTP tap data.
70  * @param out_buff Output audio samples.
71  * @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
72  * @param channels_ptr If non-NULL, receives the number of channels in the sample.
73  * @param sample_rate_ptr If non-NULL, receives the sample rate.
74  * @return The number of decoded bytes on success, 0 on failure.
75  */
76 size_t decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr);
77 
78 #ifdef __cplusplus
79 }
80 #endif /* __cplusplus */
81 
82 #endif /* __RTP_MEDIA_H__ */
83