wireshark/ui/rtp_media.h

83 lines
2.7 KiB
C
Raw Normal View History

/** @file
*
* RTP decoding routines for Wireshark.
* Copied from ui/gtk/rtp_player.c
*
* Copyright 2006, Alejandro Vaquero <alejandrovaquero@yahoo.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RTP_MEDIA_H__
#define __RTP_MEDIA_H__
2021-02-10 14:32:18 +00:00
#include <glib.h>
/** @file
* "RTP Player" dialog box common routines.
* @ingroup main_ui_group
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
/* INTERFACE */
/****************************************************************************/
typedef gint16 SAMPLE;
Qt: Initial RTP playback. Note the "initial". This is woefully incomplete. See the "to do" lists below and in the code. This differs a bit from the GTK+ version in that you specify one or more streams to be decoded. Instead of showing waveforms in individual widgets, add them all to a single QCustomPlot. This conserves screen real estate and lets us more easily take advantage of the QCP API. It also looks better IMHO. Change a bunch of checks for QtMultimediaWidgets to QtMultimedia. We probably won't use the widgets until we make 5.0 our minimum Qt version and plain old QtMultimedia lets us support Qt 4 more easily (in theory at least). Add resampling code from libspeex. I initially used this to resample each packet to match the preferred rate of our output device, but this resulted in poorer audio quality than expected. Leave it in and use to create visual samples for QCP and to match rates any time the rate changes. The latter is currently untested. Add some debugging macros. Note that both the RTP player and RTP analysis dialogs decode audio data using different code. Note that voip_calls_packet and voip_calls_init_tap appear to be dead code. To do: - Add silence frames where needed. - Implement the jitter buffer. - Implement the playback timing controls. - Tapping / scanning streams might be too slow. Change-Id: I20dd3b66d3df53c9b1f3501262dc01458849f6b4 Bug: 9007 Reviewed-on: https://code.wireshark.org/review/10458 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-12-13 00:51:40 +00:00
#define SAMPLE_MAX G_MAXINT16
#define SAMPLE_MIN G_MININT16
#define SAMPLE_NaN SAMPLE_MIN
#define SAMPLE_BYTES (sizeof(SAMPLE) / sizeof(char))
/* Defines an RTP packet */
typedef struct _rtp_packet {
guint32 frame_num; /* Qt only */
struct _rtp_info *info; /* the RTP dissected info */
double arrive_offset; /* arrive offset time since the beginning of the stream as ms in GTK UI and s in Qt UI */
guint8* payload_data;
} rtp_packet_t;
/** Create a new hash table.
*
* @return A new hash table suitable for passing to decode_rtp_packet.
*/
GHashTable *rtp_decoder_hash_table_new(void);
/** Decode payload from an RTP packet
*
* @param payload_type Payload number
* @param payload_type_str Payload name, can be NULL
* @param payload_data Payload
* @param payload_len Length of payload
* @param out_buff Output audio samples.
* @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
* @param channels_ptr If non-NULL, receives the number of channels in the sample.
* @param sample_rate_ptr If non-NULL, receives the sample rate.
* @return The number of decoded bytes on success, 0 on failure.
*/
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);
/** Decode an RTP packet
*
* @param rp Wrapper for per-packet RTP tap data.
* @param out_buff Output audio samples.
* @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
* @param channels_ptr If non-NULL, receives the number of channels in the sample.
* @param sample_rate_ptr If non-NULL, receives the sample rate.
* @return The number of decoded bytes on success, 0 on failure.
*/
size_t decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __RTP_MEDIA_H__ */