feat: 视频与控制程序合并
This commit is contained in:
@@ -87,6 +87,30 @@ static PyObject *build_stats_dict(const omnisocket_session_stats_t *stats) {
|
||||
);
|
||||
}
|
||||
|
||||
static PyObject *build_kcp_stats_dict(const omnisocket_session_kcp_stats_t *stats) {
|
||||
return Py_BuildValue(
|
||||
"{s:i,s:I,s:I,s:i,s:i,s:I,s:I,s:I,s:I}",
|
||||
"connected",
|
||||
stats->connected,
|
||||
"conv",
|
||||
stats->conv,
|
||||
"rto_ms",
|
||||
stats->rto_ms,
|
||||
"srtt_ms",
|
||||
stats->srtt_ms,
|
||||
"srttvar_ms",
|
||||
stats->srttvar_ms,
|
||||
"snd_queue",
|
||||
stats->snd_queue,
|
||||
"rcv_queue",
|
||||
stats->rcv_queue,
|
||||
"snd_buffer",
|
||||
stats->snd_buffer,
|
||||
"xmit_total",
|
||||
stats->xmit_total
|
||||
);
|
||||
}
|
||||
|
||||
static PyObject *PyOmniSession_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
|
||||
PyOmniSession *self;
|
||||
(void) args;
|
||||
@@ -314,6 +338,14 @@ static PyObject *PyOmniSession_stats(PyOmniSession *self, PyObject *Py_UNUSED(ig
|
||||
return build_stats_dict(&stats);
|
||||
}
|
||||
|
||||
static PyObject *PyOmniSession_kcp_stats(PyOmniSession *self, PyObject *Py_UNUSED(ignored)) {
|
||||
omnisocket_session_kcp_stats_t stats;
|
||||
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
omnisocket_session_kcp_stats_snapshot(&self->session, &stats);
|
||||
return build_kcp_stats_dict(&stats);
|
||||
}
|
||||
|
||||
static PyMethodDef PyOmniSession_methods[] = {
|
||||
{"connect", (PyCFunction) PyOmniSession_connect, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{"close", (PyCFunction) PyOmniSession_close, METH_NOARGS, NULL},
|
||||
@@ -321,6 +353,7 @@ static PyMethodDef PyOmniSession_methods[] = {
|
||||
{"recv", (PyCFunction) PyOmniSession_recv, METH_VARARGS | METH_KEYWORDS, PyOmniSession_recv_doc},
|
||||
{"recv_into", (PyCFunction) PyOmniSession_recv_into, METH_VARARGS | METH_KEYWORDS, PyOmniSession_recv_into_doc},
|
||||
{"stats", (PyCFunction) PyOmniSession_stats, METH_NOARGS, NULL},
|
||||
{"kcp_stats", (PyCFunction) PyOmniSession_kcp_stats, METH_NOARGS, NULL},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user