Skip to content

Commit 7bea54f

Browse files
committed
Attach pointer to the rtpp_session_ctor_args to the
r_pipe_ctor_args, so that we don't have to copy bunch of pointers and parameters.
1 parent 3761642 commit 7bea54f

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

src/rtpp_pipe.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "config.h"
3434

35+
#include "rtpp_cfg.h"
3536
#include "rtpp_debug.h"
3637
#include "rtpp_log.h"
3738
#include "rtpp_types.h"
@@ -53,6 +54,7 @@
5354
#include "rtpp_pcnts_strm.h"
5455
#include "rtpp_stats.h"
5556
#include "rtpp_refcnt.h"
57+
#include "rtpp_session.h"
5658
#include "advanced/pproc_manager.h"
5759

5860
struct rtpp_pipe_priv
@@ -85,6 +87,7 @@ struct rtpp_pipe *
8587
rtpp_pipe_ctor(const struct r_pipe_ctor_args *ap)
8688
{
8789
struct rtpp_pipe_priv *pvt;
90+
const struct rtpp_cfg *cfs = ap->session_cap->cfs;
8891
int i;
8992

9093
pvt = rtpp_rzmalloc(sizeof(struct rtpp_pipe_priv), PVT_RCOFFS(pvt));
@@ -93,9 +96,13 @@ rtpp_pipe_ctor(const struct r_pipe_ctor_args *ap)
9396
}
9497

9598
RTPP_OBJ_BORROW(&pvt->pub, ap->log);
96-
pvt->streams_wrt = ap->streams_wrt;
99+
if (ap->pipe_type == PIPE_RTP) {
100+
pvt->streams_wrt = cfs->rtp_streams_wrt;
101+
} else {
102+
pvt->streams_wrt = cfs->rtcp_streams_wrt;
103+
}
97104

98-
pvt->pub.ppuid = CALL_SMETHOD(ap->guid, gen);
105+
pvt->pub.ppuid = CALL_SMETHOD(cfs->guid, gen);
99106
struct r_stream_ctor_args rsca = {
100107
.pipe_cap = ap,
101108
};
@@ -127,7 +134,7 @@ rtpp_pipe_ctor(const struct r_pipe_ctor_args *ap)
127134
pvt->pub.stream[1]->pproc_manager->reverse = pvt->pub.stream[0]->pproc_manager;
128135
RTPP_OBJ_BORROW(&pvt->pub, pvt->pub.stream[0]->pproc_manager);
129136
pvt->pipe_type = ap->pipe_type;
130-
pvt->pub.rtpp_stats = ap->rtpp_stats;
137+
pvt->pub.rtpp_stats = cfs->rtpp_stats;
131138
pvt->pub.log = ap->log;
132139
PUBINST_FININIT(&pvt->pub, pvt, rtpp_pipe_dtor);
133140
#if defined(RTPP_DEBUG)

src/rtpp_pipe.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
struct rtpp_stats;
3131
struct rtpp_acct_pipe;
3232
struct rtpp_proc_servers;
33+
struct rtpp_session_ctor_args;
3334

3435
#define PIPE_RTP 1
3536
#define PIPE_RTCP 2
@@ -38,14 +39,9 @@ struct rtpp_proc_servers;
3839

3940
struct r_pipe_ctor_args {
4041
uint64_t seuid;
41-
struct rtpp_weakref *streams_wrt;
42-
struct rtpp_proc_servers *proc_servers;
4342
struct rtpp_log *log;
44-
struct rtpp_stats *rtpp_stats;
4543
int pipe_type;
46-
unsigned int nmodules;
47-
struct pproc_manager *pproc_manager;
48-
struct rtpp_genuid *guid;
44+
const struct rtpp_session_ctor_args *session_cap;
4945
};
5046

5147
DECLARE_CLASS(rtpp_pipe, const struct r_pipe_ctor_args *);

src/rtpp_session.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,13 @@ rtpp_session_ctor(const struct rtpp_session_ctor_args *ap)
112112
CALL_METHOD(log, start, cfs);
113113
CALL_METHOD(log, setlevel, cfs->log_level);
114114
pipe_cfg = (struct r_pipe_ctor_args){.seuid = pub->seuid,
115-
.streams_wrt = cfs->rtp_streams_wrt, .proc_servers = cfs->proc_servers,
116-
.log = log, .rtpp_stats = cfs->rtpp_stats, .pipe_type = PIPE_RTP,
117-
#if ENABLE_MODULE_IF
118-
.nmodules = cfs->modules_cf->count.total,
119-
#endif
120-
.pproc_manager = cfs->pproc_manager,
121-
.guid = cfs->guid,
115+
.log = log, .pipe_type = PIPE_RTP, .session_cap = ap,
122116
};
123117
pub->rtp = rtpp_pipe_ctor(&pipe_cfg);
124118
if (pub->rtp == NULL) {
125119
goto e3;
126120
}
127121
/* spb is RTCP twin session for this one. */
128-
pipe_cfg.streams_wrt = cfs->rtcp_streams_wrt;
129122
pipe_cfg.pipe_type = PIPE_RTCP;
130123
pub->rtcp = rtpp_pipe_ctor(&pipe_cfg);
131124
if (pub->rtcp == NULL) {
@@ -155,10 +148,6 @@ rtpp_session_ctor(const struct rtpp_session_ctor_args *ap)
155148
goto e8;
156149
}
157150
pub->from_tag_nmn = &pvt->from_tag_nmn.fx;
158-
for (i = 0; i < 2; i++) {
159-
pub->rtp->stream[i]->laddr = ap->lia[i];
160-
pub->rtcp->stream[i]->laddr = ap->lia[i];
161-
}
162151
if (ap->weak) {
163152
pub->rtp->stream[0]->weak = 1;
164153
} else {

src/rtpp_stream.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
#include "advanced/pproc_manager.h"
8383
#include "advanced/packet_processor.h"
8484
#include "rtpp_command_stats.h"
85+
#include "rtpp_modman.h"
86+
#include "rtpp_session.h"
8587

8688
#define SEQ_SYNC_IVAL 1.0 /* in seconds */
8789

@@ -245,9 +247,16 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
245247
struct rtpp_stream_priv *pvt;
246248
size_t alen;
247249
const struct r_pipe_ctor_args *pap = ap->pipe_cap;
250+
const struct rtpp_session_ctor_args *sap = pap->session_cap;
251+
const struct rtpp_cfg *cfs = sap->cfs;
252+
int nmodules = 0;
253+
254+
#if ENABLE_MODULE_IF
255+
nmodules = cfs->modules_cf->count.total;
256+
#endif
248257

249258
alen = offsetof(struct rtpp_stream_priv, pmod_data.adp) +
250-
(pap->nmodules * sizeof(pvt->pmod_data.adp[0]));
259+
(nmodules * sizeof(pvt->pmod_data.adp[0]));
251260
pvt = rtpp_rzmalloc(alen, PVT_RCOFFS(pvt));
252261
if (pvt == NULL) {
253262
goto e0;
@@ -258,7 +267,7 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
258267
pvt->pub.log = pap->log;
259268
RTPP_OBJ_BORROW(&pvt->pub, pap->log);
260269
RTPP_OBJ_DTOR_ATTACH(&pvt->pub, pthread_mutex_destroy, &pvt->lock);
261-
pvt->pub.pproc_manager = CALL_SMETHOD(pap->pproc_manager, clone);
270+
pvt->pub.pproc_manager = CALL_SMETHOD(cfs->pproc_manager, clone);
262271
if (pvt->pub.pproc_manager == NULL) {
263272
goto e1;
264273
}
@@ -278,7 +287,7 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
278287
};
279288
if (CALL_SMETHOD(pvt->pub.pproc_manager, reg, PPROC_ORD_RESIZE, &resize_packet_poi) < 0)
280289
goto e1;
281-
pvt->npkts_resizer_in_idx = CALL_SMETHOD(pap->rtpp_stats, getidxbyname,
290+
pvt->npkts_resizer_in_idx = CALL_SMETHOD(cfs->rtpp_stats, getidxbyname,
282291
"npkts_resizer_in");
283292
if (pvt->npkts_resizer_in_idx == -1)
284293
goto e2;
@@ -308,19 +317,20 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
308317
goto e3;
309318
}
310319
RTPP_OBJ_DTOR_ATTACH_OBJ(&pvt->pub, pvt->rem_addr);
311-
pvt->proc_servers = pap->proc_servers;
312-
RTPP_OBJ_BORROW(&pvt->pub, pap->proc_servers);
313-
pvt->rtpp_stats = pap->rtpp_stats;
320+
pvt->proc_servers = cfs->proc_servers;
321+
RTPP_OBJ_BORROW(&pvt->pub, cfs->proc_servers);
322+
pvt->rtpp_stats = cfs->rtpp_stats;
314323
pvt->pub.side = ap->side;
315324
pvt->pub.pipe_type = pap->pipe_type;
316325

317-
pvt->pub.stuid = CALL_SMETHOD(pap->guid, gen);
326+
pvt->pub.stuid = CALL_SMETHOD(cfs->guid, gen);
318327
pvt->pub.seuid = pap->seuid;
319-
for (unsigned int i = 0; i < pap->nmodules; i++) {
328+
for (unsigned int i = 0; i < nmodules; i++) {
320329
atomic_init(&(pvt->pmod_data.adp[i]), NULL);
321330
}
322-
pvt->pmod_data.nmodules = pap->nmodules;
331+
pvt->pmod_data.nmodules = nmodules;
323332
pvt->pub.pmod_datap = &(pvt->pmod_data);
333+
pvt->pub.laddr = sap->lia[ap->side];
324334
PUBINST_FININIT(&pvt->pub, pvt, rtpp_stream_dtor);
325335
return (&pvt->pub);
326336

0 commit comments

Comments
 (0)