Skip to content

Commit 6b8bf32

Browse files
committed
Simplify pipe / stream constructor parameters passing by just
passing reference to the r_pipe_ctor_args inside r_stream_ctor_args instead of copying bunch of parameters over.
1 parent b75f6f7 commit 6b8bf32

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

src/rtpp_pipe.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,7 @@ rtpp_pipe_ctor(const struct r_pipe_ctor_args *ap)
9797

9898
pvt->pub.ppuid = CALL_SMETHOD(ap->guid, gen);
9999
struct r_stream_ctor_args rsca = {
100-
.log = ap->log,
101-
.proc_servers = ap->proc_servers,
102-
.rtpp_stats = ap->rtpp_stats,
103-
.pipe_type = ap->pipe_type,
104-
.seuid = ap->seuid,
105-
.nmodules = ap->nmodules,
106-
.pproc_manager = ap->pproc_manager,
107-
.guid = ap->guid,
100+
.pipe_cap = ap,
108101
};
109102
for (i = 0; i < 2; i++) {
110103
rsca.side = i;

src/rtpp_stream.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,27 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
244244
{
245245
struct rtpp_stream_priv *pvt;
246246
size_t alen;
247+
const struct r_pipe_ctor_args *pap = ap->pipe_cap;
247248

248249
alen = offsetof(struct rtpp_stream_priv, pmod_data.adp) +
249-
(ap->nmodules * sizeof(pvt->pmod_data.adp[0]));
250+
(pap->nmodules * sizeof(pvt->pmod_data.adp[0]));
250251
pvt = rtpp_rzmalloc(alen, PVT_RCOFFS(pvt));
251252
if (pvt == NULL) {
252253
goto e0;
253254
}
254255
if (pthread_mutex_init(&pvt->lock, NULL) != 0) {
255256
goto e1;
256257
}
257-
pvt->pub.log = ap->log;
258-
RTPP_OBJ_BORROW(&pvt->pub, ap->log);
258+
pvt->pub.log = pap->log;
259+
RTPP_OBJ_BORROW(&pvt->pub, pap->log);
259260
RTPP_OBJ_DTOR_ATTACH(&pvt->pub, pthread_mutex_destroy, &pvt->lock);
260-
pvt->pub.pproc_manager = CALL_SMETHOD(ap->pproc_manager, clone);
261+
pvt->pub.pproc_manager = CALL_SMETHOD(pap->pproc_manager, clone);
261262
if (pvt->pub.pproc_manager == NULL) {
262263
goto e1;
263264
}
264265
RTPP_OBJ_DTOR_ATTACH_OBJ(&pvt->pub, pvt->pub.pproc_manager);
265-
if (ap->pipe_type == PIPE_RTP) {
266-
pvt->pub.analyzer = rtpp_analyzer_ctor(ap->log);
266+
if (pap->pipe_type == PIPE_RTP) {
267+
pvt->pub.analyzer = rtpp_analyzer_ctor(pap->log);
267268
if (pvt->pub.analyzer == NULL) {
268269
goto e1;
269270
}
@@ -277,7 +278,7 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
277278
};
278279
if (CALL_SMETHOD(pvt->pub.pproc_manager, reg, PPROC_ORD_RESIZE, &resize_packet_poi) < 0)
279280
goto e1;
280-
pvt->npkts_resizer_in_idx = CALL_SMETHOD(ap->rtpp_stats, getidxbyname,
281+
pvt->npkts_resizer_in_idx = CALL_SMETHOD(pap->rtpp_stats, getidxbyname,
281282
"npkts_resizer_in");
282283
if (pvt->npkts_resizer_in_idx == -1)
283284
goto e2;
@@ -287,7 +288,7 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
287288
.descr = "analyze_packet",
288289
.arg = (void *)pvt->pub.analyzer,
289290
.key = (void *)pvt,
290-
.enqueue = (ap->pipe_type == PIPE_RTP) ? &analyze_rtp_packet : &analyze_rtcp_packet,
291+
.enqueue = (pap->pipe_type == PIPE_RTP) ? &analyze_rtp_packet : &analyze_rtcp_packet,
291292
};
292293
if (CALL_SMETHOD(pvt->pub.pproc_manager, reg, PPROC_ORD_ANALYZE, &analyze_packet_poi) < 0)
293294
goto e2;
@@ -307,26 +308,26 @@ rtpp_stream_ctor(const struct r_stream_ctor_args *ap)
307308
goto e3;
308309
}
309310
RTPP_OBJ_DTOR_ATTACH_OBJ(&pvt->pub, pvt->rem_addr);
310-
pvt->proc_servers = ap->proc_servers;
311-
RTPP_OBJ_BORROW(&pvt->pub, ap->proc_servers);
312-
pvt->rtpp_stats = ap->rtpp_stats;
311+
pvt->proc_servers = pap->proc_servers;
312+
RTPP_OBJ_BORROW(&pvt->pub, pap->proc_servers);
313+
pvt->rtpp_stats = pap->rtpp_stats;
313314
pvt->pub.side = ap->side;
314-
pvt->pub.pipe_type = ap->pipe_type;
315+
pvt->pub.pipe_type = pap->pipe_type;
315316

316-
pvt->pub.stuid = CALL_SMETHOD(ap->guid, gen);
317-
pvt->pub.seuid = ap->seuid;
318-
for (unsigned int i = 0; i < ap->nmodules; i++) {
317+
pvt->pub.stuid = CALL_SMETHOD(pap->guid, gen);
318+
pvt->pub.seuid = pap->seuid;
319+
for (unsigned int i = 0; i < pap->nmodules; i++) {
319320
atomic_init(&(pvt->pmod_data.adp[i]), NULL);
320321
}
321-
pvt->pmod_data.nmodules = ap->nmodules;
322+
pvt->pmod_data.nmodules = pap->nmodules;
322323
pvt->pub.pmod_datap = &(pvt->pmod_data);
323324
PUBINST_FININIT(&pvt->pub, pvt, rtpp_stream_dtor);
324325
return (&pvt->pub);
325326

326327
e3:
327328
CALL_SMETHOD(pvt->pub.pproc_manager, unreg, pvt);
328329
e2:
329-
if (ap->pipe_type == PIPE_RTP) {
330+
if (pap->pipe_type == PIPE_RTP) {
330331
CALL_SMETHOD(pvt->pub.pproc_manager, unreg, pvt + 1);
331332
}
332333
e1:

src/rtpp_stream.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,8 @@ enum rtpps_latch_mode {
5353
};
5454

5555
struct r_stream_ctor_args {
56-
struct rtpp_log *log;
57-
struct rtpp_proc_servers *proc_servers;
58-
struct rtpp_stats *rtpp_stats;
5956
enum rtpp_stream_side side;
60-
int pipe_type;
61-
uint64_t seuid;
62-
unsigned int nmodules;
63-
struct pproc_manager *pproc_manager;
64-
struct rtpp_genuid *guid;
57+
const struct r_pipe_ctor_args *pipe_cap;
6558
};
6659

6760
struct r_stream_h_play_args {

0 commit comments

Comments
 (0)