gboolean sent_headers;
} SRTCaller;
-static GstStructure *gst_srt_object_accumulate_stats (GstSRTObject * srtobject,
- SRTSOCKET srtsock);
-
static SRTCaller *
srt_caller_new (void)
{
static void
srt_caller_signal_removed (SRTCaller * caller, GstSRTObject * srtobject)
{
- GstStructure *stats;
-
- stats = gst_srt_object_accumulate_stats (srtobject, caller->sock);
-
- /* FIXME: These are the final statistics for the caller before we close its
- * socket. Deliver the stats to the app before we throw them away. */
- gst_structure_free (stats);
-
g_signal_emit_by_name (srtobject->element, "caller-removed", 0,
caller->sockaddr);
}
gst_srt_object_open (GstSRTObject * srtobject, GCancellable * cancellable,
GError ** error)
{
- srtobject->previous_bytes = 0;
+ srtobject->bytes = 0;
return gst_srt_object_open_internal (srtobject, cancellable, error);
}
g_mutex_lock (&srtobject->sock_lock);
if (srtobject->sock != SRT_INVALID_SOCK) {
- GstStructure *stats;
-
if (srtobject->poll_id != SRT_ERROR) {
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
}
- stats = gst_srt_object_accumulate_stats (srtobject, srtobject->sock);
-
- /* FIXME: These are the final statistics for the socket before we close it.
- * Deliver the stats to the app before we throw them away. */
- gst_structure_free (stats);
-
GST_DEBUG_OBJECT (srtobject->element, "Closing SRT socket (0x%x)",
srtobject->sock);
return -1;
}
}
+
+ srtobject->bytes += len;
break;
}
for (i = 0; i < size; i++) {
SRTSOCKET wsock = sock;
gint wsocklen = 1;
+ gint sent;
GstBuffer *buffer = gst_buffer_list_get (headers, i);
GstMapInfo mapinfo;
return FALSE;
}
- if (srt_sendmsg2 (wsock, (char *) mapinfo.data, mapinfo.size,
- 0) == SRT_ERROR) {
+ sent = srt_sendmsg2 (wsock, (char *) mapinfo.data, mapinfo.size, 0);
+ if (sent == SRT_ERROR) {
GST_ELEMENT_ERROR (srtobject->element, RESOURCE, WRITE, NULL,
("%s", srt_getlasterror_str ()));
gst_buffer_unmap (buffer, &mapinfo);
return FALSE;
}
+ srtobject->bytes += sent;
+
gst_buffer_unmap (buffer, &mapinfo);
}
goto err;
}
len += sent;
+ srtobject->bytes += sent;
}
continue;
break;
}
len += sent;
+ srtobject->bytes += sent;
}
return len;
}
static GstStructure *
-get_stats_for_srtsock (SRTSOCKET srtsock, gboolean is_sender, guint64 * bytes)
+get_stats_for_srtsock (SRTSOCKET srtsock, gboolean is_sender)
{
GstStructure *s = gst_structure_new_empty ("application/x-srt-statistics");
int ret;
/* busy sending time (i.e., idle time exclusive) */
"send-duration-us", G_TYPE_UINT64, stats.usSndDuration,
"negotiated-latency-ms", G_TYPE_INT, stats.msSndTsbPdDelay, NULL);
- *bytes += stats.byteSent;
} else {
gst_structure_set (s,
"packets-received", G_TYPE_INT64, stats.pktRecvTotal,
"bytes-received-lost", G_TYPE_UINT64, stats.byteRcvLossTotal,
"receive-rate-mbps", G_TYPE_DOUBLE, stats.mbpsRecvRate,
"negotiated-latency-ms", G_TYPE_INT, stats.msRcvTsbPdDelay, NULL);
- *bytes += stats.byteRecvTotal;
}
gst_structure_set (s,
{
GstStructure *s = NULL;
gboolean is_sender = GST_IS_BASE_SINK (srtobject->element);
- guint64 bytes;
g_mutex_lock (&srtobject->sock_lock);
- bytes = srtobject->previous_bytes;
-
if (srtobject->sock != SRT_INVALID_SOCK) {
- s = get_stats_for_srtsock (srtobject->sock, is_sender, &bytes);
+ s = get_stats_for_srtsock (srtobject->sock, is_sender);
goto done;
}
GstStructure *tmp;
GValue *v;
- tmp = get_stats_for_srtsock (caller->sock, is_sender, &bytes);
+ tmp = get_stats_for_srtsock (caller->sock, is_sender);
gst_structure_set (tmp, "caller-address", G_TYPE_SOCKET_ADDRESS,
caller->sockaddr, NULL);
done:
gst_structure_set (s, is_sender ? "bytes-sent-total" : "bytes-received-total",
- G_TYPE_UINT64, bytes, NULL);
+ G_TYPE_UINT64, srtobject->bytes, NULL);
g_mutex_unlock (&srtobject->sock_lock);
return s;
}
-
-static GstStructure *
-gst_srt_object_accumulate_stats (GstSRTObject * srtobject, SRTSOCKET srtsock)
-{
- gboolean is_sender = GST_IS_BASE_SINK (srtobject->element);
- GstStructure *stats;
- guint64 bytes = 0;
-
- stats = get_stats_for_srtsock (srtsock, is_sender, &bytes);
- srtobject->previous_bytes += bytes;
-
- return stats;
-}