mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-12 09:15:29 +00:00
rtpsource: add RTP and RTCP source address
Add the RTP and RTCP sender addresses in the stats structure.
This commit is contained in:
parent
d48dcb0499
commit
a0b6202baf
1 changed files with 48 additions and 0 deletions
|
@ -188,12 +188,50 @@ rtp_source_finalize (GObject * object)
|
||||||
G_OBJECT_CLASS (rtp_source_parent_class)->finalize (object);
|
G_OBJECT_CLASS (rtp_source_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_ADDRESS 64
|
||||||
|
static void
|
||||||
|
make_address_string (GstNetAddress * addr, gchar * dest, gulong n)
|
||||||
|
{
|
||||||
|
switch (gst_netaddress_get_net_type (addr)) {
|
||||||
|
case GST_NET_TYPE_IP4:
|
||||||
|
{
|
||||||
|
guint32 address;
|
||||||
|
guint16 port;
|
||||||
|
|
||||||
|
gst_netaddress_get_ip4_address (addr, &address, &port);
|
||||||
|
|
||||||
|
g_snprintf (dest, n, "%d.%d.%d.%d:%d", (address >> 24) & 0xff,
|
||||||
|
(address >> 16) & 0xff, (address >> 8) & 0xff, address & 0xff, port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_NET_TYPE_IP6:
|
||||||
|
{
|
||||||
|
guint8 address[16];
|
||||||
|
guint16 port;
|
||||||
|
|
||||||
|
gst_netaddress_get_ip6_address (addr, address, &port);
|
||||||
|
|
||||||
|
g_snprintf (dest, n, "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]:%d",
|
||||||
|
(address[0] << 8) | address[1], (address[2] << 8) | address[3],
|
||||||
|
(address[4] << 8) | address[5], (address[6] << 8) | address[7],
|
||||||
|
(address[8] << 8) | address[9], (address[10] << 8) | address[11],
|
||||||
|
(address[12] << 8) | address[13], (address[14] << 8) | address[15],
|
||||||
|
port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
dest[0] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GstStructure *
|
static GstStructure *
|
||||||
rtp_source_create_stats (RTPSource * src)
|
rtp_source_create_stats (RTPSource * src)
|
||||||
{
|
{
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
gboolean is_sender = src->is_sender;
|
gboolean is_sender = src->is_sender;
|
||||||
gboolean internal = src->internal;
|
gboolean internal = src->internal;
|
||||||
|
gchar address_str[MAX_ADDRESS];
|
||||||
|
|
||||||
/* common data for all types of sources */
|
/* common data for all types of sources */
|
||||||
s = gst_structure_new ("application/x-rtp-source-stats",
|
s = gst_structure_new ("application/x-rtp-source-stats",
|
||||||
|
@ -204,6 +242,16 @@ rtp_source_create_stats (RTPSource * src)
|
||||||
"is-csrc", G_TYPE_BOOLEAN, src->is_csrc,
|
"is-csrc", G_TYPE_BOOLEAN, src->is_csrc,
|
||||||
"is-sender", G_TYPE_BOOLEAN, is_sender, NULL);
|
"is-sender", G_TYPE_BOOLEAN, is_sender, NULL);
|
||||||
|
|
||||||
|
/* add address and port */
|
||||||
|
if (src->have_rtp_from) {
|
||||||
|
make_address_string (&src->rtp_from, address_str, sizeof (address_str));
|
||||||
|
gst_structure_set (s, "rtp-from", G_TYPE_STRING, address_str, NULL);
|
||||||
|
}
|
||||||
|
if (src->have_rtcp_from) {
|
||||||
|
make_address_string (&src->rtcp_from, address_str, sizeof (address_str));
|
||||||
|
gst_structure_set (s, "rtcp-from", G_TYPE_STRING, address_str, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (internal) {
|
if (internal) {
|
||||||
/* our internal source */
|
/* our internal source */
|
||||||
if (is_sender) {
|
if (is_sender) {
|
||||||
|
|
Loading…
Reference in a new issue