[vlc-commits] [Git][videolan/vlc][master] 5 commits: rtp: rename demux_sys_t to rtp_sys_t
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat May 27 11:59:37 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
ddf445e7 by Loïc Branstett at 2023-05-27T11:19:52+00:00
rtp: rename demux_sys_t to rtp_sys_t
- - - - -
d2d1db43 by Loïc Branstett at 2023-05-27T11:19:52+00:00
rtp: remove demux_t dependence for RTP sessions
- - - - -
71b16a97 by Loïc Branstett at 2023-05-27T11:19:52+00:00
rtp: add vlc_logger directly to rtp_sys_t
- - - - -
db3522b5 by Loïc Branstett at 2023-05-27T11:19:52+00:00
rtp: remove demux_t dependence for RTP queue/dequeue operations
- - - - -
71421552 by Loïc Branstett at 2023-05-27T11:19:52+00:00
rtp: remove demux_t dependence for the RTP process thread
- - - - -
4 changed files:
- modules/access/rtp/input.c
- modules/access/rtp/rtp.c
- modules/access/rtp/rtp.h
- modules/access/rtp/session.c
Changes:
=====================================
modules/access/rtp/input.c
=====================================
@@ -52,10 +52,8 @@
/**
* Processes a packet received from the RTP socket.
*/
-static void rtp_process (demux_t *demux, block_t *block)
+static void rtp_process (rtp_sys_t *sys, block_t *block)
{
- demux_sys_t *sys = demux->p_sys;
-
if (block->i_buffer < 2)
goto drop;
const uint8_t ptype = rtp_ptype (block);
@@ -68,14 +66,14 @@ static void rtp_process (demux_t *demux, block_t *block)
size_t len = block->i_buffer;
if (srtp_recv (sys->srtp, block->p_buffer, &len))
{
- msg_Dbg (demux, "SRTP authentication/decryption failed");
+ vlc_debug (sys->logger, "SRTP authentication/decryption failed");
goto drop;
}
block->i_buffer = len;
}
#endif
- rtp_queue (demux, sys->session, block);
+ rtp_queue (sys, sys->session, block);
return;
drop:
block_Release (block);
@@ -101,8 +99,7 @@ static int rtp_timeout (vlc_tick_t deadline)
*/
void *rtp_dgram_thread (void *opaque)
{
- demux_t *demux = opaque;
- demux_sys_t *sys = demux->p_sys;
+ rtp_sys_t *sys = opaque;
vlc_tick_t deadline = VLC_TICK_INVALID;
struct vlc_dtls *rtp_sock = sys->rtp_sock;
@@ -134,20 +131,20 @@ void *rtp_dgram_thread (void *opaque)
block->i_buffer, &truncated);
if (len >= 0) {
if (truncated) {
- msg_Err(demux, "packet truncated (MRU was %zu)",
+ vlc_error (sys->logger, "packet truncated (MRU was %zu)",
block->i_buffer);
block->i_flags |= BLOCK_FLAG_CORRUPTED;
}
else
block->i_buffer = len;
- rtp_process (demux, block);
+ rtp_process (sys, block);
}
else
{
if (errno == EPIPE)
break; /* connection terminated */
- msg_Warn (demux, "RTP network error: %s",
+ vlc_warning (sys->logger, "RTP network error: %s",
vlc_strerror_c(errno));
block_Release (block);
}
@@ -156,7 +153,7 @@ void *rtp_dgram_thread (void *opaque)
}
dequeue:
- if (!rtp_dequeue (demux, sys->session, &deadline))
+ if (!rtp_dequeue (sys, sys->session, &deadline))
deadline = VLC_TICK_INVALID;
vlc_restorecancel (canc);
}
=====================================
modules/access/rtp/rtp.c
=====================================
@@ -218,7 +218,7 @@ static int extract_port (char **phost)
*/
static int Control (demux_t *demux, int query, va_list args)
{
- demux_sys_t *sys = demux->p_sys;
+ rtp_sys_t *sys = demux->p_sys;
switch (query)
{
@@ -268,7 +268,7 @@ static int Control (demux_t *demux, int query, va_list args)
static void Close (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
- demux_sys_t *p_sys = demux->p_sys;
+ rtp_sys_t *p_sys = demux->p_sys;
vlc_cancel(p_sys->thread);
vlc_join(p_sys->thread, NULL);
@@ -276,7 +276,7 @@ static void Close (vlc_object_t *obj)
if (p_sys->srtp)
srtp_destroy (p_sys->srtp);
#endif
- rtp_session_destroy (demux, p_sys->session);
+ rtp_session_destroy (obj->logger, p_sys->session);
if (p_sys->rtcp_sock != NULL)
vlc_dtls_Close(p_sys->rtcp_sock);
vlc_dtls_Close(p_sys->rtp_sock);
@@ -305,7 +305,7 @@ static int OpenSDP(vlc_object_t *obj)
if (sdplen < 0)
return sdplen;
- demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
+ rtp_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -416,6 +416,7 @@ static int OpenSDP(vlc_object_t *obj)
}
}
+ sys->logger = obj->logger;
sys->chained_demux = NULL;
sys->max_src = var_InheritInteger(obj, "rtp-max-src");
sys->timeout = vlc_tick_from_sec(var_InheritInteger(obj, "rtp-timeout"));
@@ -426,7 +427,7 @@ static int OpenSDP(vlc_object_t *obj)
demux->pf_control = Control;
demux->p_sys = sys;
- sys->session = rtp_session_create(demux);
+ sys->session = rtp_session_create();
if (sys->session == NULL)
goto error;
@@ -440,8 +441,8 @@ static int OpenSDP(vlc_object_t *obj)
if (err > 0 && module_exists("live555")) /* Bail out to live555 */
goto error;
- if (vlc_clone(&sys->thread, rtp_dgram_thread, demux)) {
- rtp_session_destroy(demux, sys->session);
+ if (vlc_clone(&sys->thread, rtp_dgram_thread, sys)) {
+ rtp_session_destroy(obj->logger, sys->session);
goto error;
}
@@ -479,7 +480,7 @@ static int OpenURL(vlc_object_t *obj)
else
return VLC_EGENERIC;
- demux_sys_t *p_sys = vlc_obj_malloc(obj, sizeof (*p_sys));
+ rtp_sys_t *p_sys = vlc_obj_malloc(obj, sizeof (*p_sys));
if (unlikely(p_sys == NULL))
return VLC_ENOMEM;
@@ -568,6 +569,7 @@ static int OpenURL(vlc_object_t *obj)
#ifdef HAVE_SRTP
p_sys->srtp = NULL;
#endif
+ p_sys->logger = obj->logger;
p_sys->max_src = var_CreateGetInteger (obj, "rtp-max-src");
p_sys->timeout = vlc_tick_from_sec( var_CreateGetInteger (obj, "rtp-timeout") );
p_sys->max_dropout = var_CreateGetInteger (obj, "rtp-max-dropout");
@@ -577,7 +579,7 @@ static int OpenURL(vlc_object_t *obj)
demux->pf_control = Control;
demux->p_sys = p_sys;
- p_sys->session = rtp_session_create (demux);
+ p_sys->session = rtp_session_create();
if (p_sys->session == NULL)
goto error;
@@ -610,7 +612,7 @@ static int OpenURL(vlc_object_t *obj)
}
#endif
- if (vlc_clone (&p_sys->thread, rtp_dgram_thread, demux))
+ if (vlc_clone (&p_sys->thread, rtp_dgram_thread, p_sys))
goto error;
return VLC_SUCCESS;
@@ -620,7 +622,7 @@ error:
srtp_destroy(p_sys->srtp);
#endif
if (p_sys->session != NULL)
- rtp_session_destroy(demux, p_sys->session);
+ rtp_session_destroy(obj->logger, p_sys->session);
if (p_sys->rtcp_sock != NULL)
vlc_dtls_Close(p_sys->rtcp_sock);
vlc_dtls_Close(p_sys->rtp_sock);
=====================================
modules/access/rtp/rtp.h
=====================================
@@ -355,27 +355,11 @@ static inline uint8_t rtp_ptype (const block_t *block)
/** @} */
-/**
- * \defgroup rtp_session RTP session
- * @{
- */
-rtp_session_t *rtp_session_create (demux_t *);
-void rtp_session_destroy (demux_t *, rtp_session_t *);
-void rtp_queue (demux_t *, rtp_session_t *, block_t *);
-bool rtp_dequeue (demux_t *, const rtp_session_t *, vlc_tick_t *);
-int rtp_add_type(rtp_session_t *ses, rtp_pt_t *pt);
-int vlc_rtp_add_media_types(vlc_object_t *obj, rtp_session_t *ses,
- const struct vlc_sdp_media *media,
- const struct vlc_rtp_pt_owner *restrict owner);
-
-void *rtp_dgram_thread (void *data);
-
-/** @} */
-/** @} */
-
/* Global data */
typedef struct
{
+ struct vlc_logger *logger;
+
rtp_session_t *session;
struct vlc_demux_chained_t *chained_demux;
#ifdef HAVE_SRTP
@@ -389,5 +373,22 @@ typedef struct
uint16_t max_dropout; /**< Max packet forward misordering */
uint16_t max_misorder; /**< Max packet backward misordering */
uint8_t max_src; /**< Max simultaneous RTP sources */
-} demux_sys_t;
+} rtp_sys_t;
+
+/**
+ * \defgroup rtp_session RTP session
+ * @{
+ */
+rtp_session_t *rtp_session_create (void);
+void rtp_session_destroy (struct vlc_logger *, rtp_session_t *);
+void rtp_queue (rtp_sys_t *, rtp_session_t *, block_t *);
+bool rtp_dequeue (rtp_sys_t *, const rtp_session_t *, vlc_tick_t *);
+int rtp_add_type(rtp_session_t *ses, rtp_pt_t *pt);
+int vlc_rtp_add_media_types(vlc_object_t *obj, rtp_session_t *ses,
+ const struct vlc_sdp_media *media,
+ const struct vlc_rtp_pt_owner *restrict owner);
+void *rtp_dgram_thread (void *data);
+
+/** @} */
+/** @} */
=====================================
modules/access/rtp/session.c
=====================================
@@ -45,16 +45,16 @@ struct rtp_session_t
};
static rtp_source_t *
-rtp_source_create (demux_t *, const rtp_session_t *, uint32_t, uint16_t);
-static void rtp_source_destroy(demux_t *, rtp_source_t *);
+rtp_source_create (struct vlc_logger *, const rtp_session_t *, uint32_t, uint16_t);
+static void rtp_source_destroy(struct vlc_logger *, rtp_source_t *);
-static void rtp_decode (demux_t *, const rtp_session_t *, rtp_source_t *);
+static void rtp_decode (struct vlc_logger *, const rtp_session_t *, rtp_source_t *);
/**
* Creates a new RTP session.
*/
rtp_session_t *
-rtp_session_create (demux_t *demux)
+rtp_session_create (void)
{
rtp_session_t *session = malloc (sizeof (*session));
if (session == NULL)
@@ -65,7 +65,6 @@ rtp_session_create (demux_t *demux)
session->ptc = 0;
session->ptv = NULL;
- (void)demux;
return session;
}
@@ -73,10 +72,10 @@ rtp_session_create (demux_t *demux)
/**
* Destroys an RTP session.
*/
-void rtp_session_destroy (demux_t *demux, rtp_session_t *session)
+void rtp_session_destroy (struct vlc_logger *logger, rtp_session_t *session)
{
for (unsigned i = 0; i < session->srcc; i++)
- rtp_source_destroy(demux, session->srcv[i]);
+ rtp_source_destroy(logger, session->srcv[i]);
for (uint_fast8_t i = 0; i < session->ptc; i++)
vlc_rtp_pt_release(session->ptv[i]);
@@ -84,7 +83,6 @@ void rtp_session_destroy (demux_t *demux, rtp_session_t *session)
free (session->srcv);
free (session->ptv);
free (session);
- (void)demux;
}
/**
@@ -132,7 +130,7 @@ struct rtp_source_t
* Initializes a new RTP source within an RTP session.
*/
static rtp_source_t *
-rtp_source_create (demux_t *demux, const rtp_session_t *session,
+rtp_source_create (struct vlc_logger *logger, const rtp_session_t *session,
uint32_t ssrc, uint16_t init_seq)
{
rtp_source_t *source;
@@ -149,7 +147,7 @@ rtp_source_create (demux_t *demux, const rtp_session_t *session,
source->last_seq = init_seq - 1;
source->blocks = NULL;
source->pt.instance = NULL;
- msg_Dbg (demux, "added RTP source (%08x)", ssrc);
+ vlc_debug (logger, "added RTP source (%08x)", ssrc);
return source;
}
@@ -157,9 +155,9 @@ rtp_source_create (demux_t *demux, const rtp_session_t *session,
/**
* Destroys an RTP source and its associated streams.
*/
-static void rtp_source_destroy(demux_t *demux, rtp_source_t *source)
+static void rtp_source_destroy(struct vlc_logger *logger, rtp_source_t *source)
{
- msg_Dbg (demux, "removing RTP source (%08x)", source->ssrc);
+ vlc_debug (logger, "removing RTP source (%08x)", source->ssrc);
if (source->pt.instance != NULL)
vlc_rtp_pt_end(source->pt.instance, source->pt.opaque);
block_ChainRelease (source->blocks);
@@ -201,10 +199,8 @@ static struct vlc_rtp_pt *rtp_find_ptype(const rtp_session_t *session,
* @param block RTP packet including the RTP header
*/
void
-rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
+rtp_queue (rtp_sys_t *p_sys, rtp_session_t *session, block_t *block)
{
- demux_sys_t *p_sys = demux->p_sys;
-
/* RTP header sanity checks (see RFC 3550) */
if (block->i_buffer < 12)
goto drop;
@@ -239,7 +235,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
/* RTP source garbage collection */
if ((tmp->last_rx + p_sys->timeout) < now)
{
- rtp_source_destroy(demux, tmp);
+ rtp_source_destroy(p_sys->logger, tmp);
if (--session->srcc > 0)
session->srcv[i] = session->srcv[session->srcc - 1];
}
@@ -250,7 +246,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
/* New source */
if (session->srcc >= p_sys->max_src)
{
- msg_Warn (demux, "too many RTP sessions");
+ vlc_warning (p_sys->logger, "too many RTP sessions");
goto drop;
}
@@ -260,7 +256,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
goto drop;
session->srcv = tab;
- src = rtp_source_create (demux, session, ssrc, seq);
+ src = rtp_source_create (p_sys->logger, session, ssrc, seq);
if (src == NULL)
goto drop;
@@ -299,13 +295,13 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
if ((delta_seq.s >= 0) ? (delta_seq.u > p_sys->max_dropout)
: (delta_seq.u < p_sys->max_misorder))
{
- msg_Dbg (demux, "sequence discontinuity"
+ vlc_debug (p_sys->logger, "sequence discontinuity"
" (got: %"PRIu16", expected: %"PRIu16")", seq, src->max_seq);
if (seq == src->bad_seq)
{
src->max_seq = src->bad_seq = seq + 1;
src->last_seq = seq - 0x7fffe; /* hack for rtp_decode() */
- msg_Warn (demux, "sequence resynchronized");
+ vlc_warning (p_sys->logger, "sequence resynchronized");
block_ChainRelease (src->blocks);
src->blocks = NULL;
}
@@ -329,7 +325,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
break;
if (delta_seq.s == 0)
{
- msg_Dbg (demux, "duplicate packet (sequence: %"PRIu16")", seq);
+ vlc_debug (p_sys->logger, "duplicate packet (sequence: %"PRIu16")", seq);
goto drop; /* duplicate */
}
pp = &prev->p_next;
@@ -345,8 +341,6 @@ drop:
}
-static void rtp_decode (demux_t *, const rtp_session_t *, rtp_source_t *);
-
/**
* Dequeues RTP packets and pass them to decoder. Not cancellation-safe(?).
* A packet is decoded if it is the next in sequence order, or if we have
@@ -359,7 +353,7 @@ static void rtp_decode (demux_t *, const rtp_session_t *, rtp_source_t *);
* @return true if the buffer is not empty, false otherwise.
* In the later case, *deadlinep is undefined.
*/
-bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
+bool rtp_dequeue (rtp_sys_t *sys, const rtp_session_t *session,
vlc_tick_t *restrict deadlinep)
{
vlc_tick_t now = vlc_tick_now ();
@@ -392,7 +386,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
{
if ((int16_t)(rtp_seq (block) - (src->last_seq + 1)) <= 0)
{ /* Next (or earlier) block ready, no need to wait */
- rtp_decode (demux, session, src);
+ rtp_decode (sys->logger, session, src);
continue;
}
@@ -418,7 +412,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
deadline += block->i_pts;
if (now >= deadline)
{
- rtp_decode (demux, session, src);
+ rtp_decode (sys->logger, session, src);
continue;
}
if (*deadlinep > deadline)
@@ -434,7 +428,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
* Decodes one RTP packet.
*/
static void
-rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
+rtp_decode (struct vlc_logger *logger, const rtp_session_t *session, rtp_source_t *src)
{
block_t *block = src->blocks;
@@ -448,11 +442,11 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
{
if (delta_seq >= 0x8000)
{ /* Trash too late packets (and PIM Assert duplicates) */
- msg_Dbg (demux, "ignoring late packet (sequence: %"PRIu16")",
+ vlc_debug (logger, "ignoring late packet (sequence: %"PRIu16")",
rtp_seq (block));
goto drop;
}
- msg_Warn (demux, "%"PRIu16" packet(s) lost", delta_seq);
+ vlc_warning (logger, "%"PRIu16" packet(s) lost", delta_seq);
block->i_flags |= BLOCK_FLAG_DISCONTINUITY;
}
src->last_seq = rtp_seq (block);
@@ -461,7 +455,7 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
struct vlc_rtp_pt *pt = rtp_find_ptype(session, block);
if (pt == NULL)
{
- msg_Dbg (demux, "unknown payload (%"PRIu8")",
+ vlc_debug (logger, "unknown payload (%"PRIu8")",
rtp_ptype (block));
goto drop;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ab6009c59e6e7d0ad140cd4a3c1443ab46527a4e...714215529d95a86c583f491e2f46dfa6c4e353c9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ab6009c59e6e7d0ad140cd4a3c1443ab46527a4e...714215529d95a86c583f491e2f46dfa6c4e353c9
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list