[vlc-commits] [Git][videolan/vlc][master] 4 commits: rtp: create ES only for one packet type per source
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Fri Nov 19 20:11:51 UTC 2021
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
2b48a8f2 by Rémi Denis-Courmont at 2021-11-19T19:46:34+00:00
rtp: create ES only for one packet type per source
This creates an ES only for the packet type (and underlying payload
format) currently used by an RTP source. Consequently, if the session
has more than one packet type, there are no more ghost ES that disrupt
track selection.
Fixes #26283.
- - - - -
c9bd8ae9 by Rémi Denis-Courmont at 2021-11-19T19:46:34+00:00
rtp: remove unused parameter
No functional changes.
- - - - -
4b4701c0 by Rémi Denis-Courmont at 2021-11-19T19:46:34+00:00
rtp: add all supported static PTs in SDP-less mode
With #26283, autodetection is no longer necessary. All types can be
registered up-front. This also allows switching from one PT to another
without restarting the input.
- - - - -
340d9055 by Rémi Denis-Courmont at 2021-11-19T19:46:34+00:00
rtp: move autodetection code to module init
- - - - -
5 changed files:
- modules/access/rtp/input.c
- modules/access/rtp/rtp.c
- modules/access/rtp/rtp.h
- modules/access/rtp/rtpfmt.c
- modules/access/rtp/session.c
Changes:
=====================================
modules/access/rtp/input.c
=====================================
@@ -74,13 +74,6 @@ static void rtp_process (demux_t *demux, block_t *block)
}
#endif
- /* TODO: use SDP and get rid of this hack */
- if (unlikely(sys->autodetect))
- { /* Autodetect payload type, _before_ rtp_queue() */
- rtp_autodetect(VLC_OBJECT(demux), sys->session, block);
- sys->autodetect = false;
- }
-
rtp_queue (demux, sys->session, block);
return;
drop:
=====================================
modules/access/rtp/rtp.c
=====================================
@@ -381,7 +381,6 @@ static int OpenSDP(vlc_object_t *obj)
sys->timeout = vlc_tick_from_sec(var_InheritInteger(obj, "rtp-timeout"));
sys->max_dropout = var_InheritInteger(obj, "rtp-max-dropout");
sys->max_misorder = -var_InheritInteger(obj, "rtp-max-misorder");
- sys->autodetect = false;
demux->pf_demux = NULL;
demux->pf_control = Control;
@@ -533,7 +532,6 @@ static int OpenURL(vlc_object_t *obj)
p_sys->timeout = vlc_tick_from_sec( var_CreateGetInteger (obj, "rtp-timeout") );
p_sys->max_dropout = var_CreateGetInteger (obj, "rtp-max-dropout");
p_sys->max_misorder = -var_CreateGetInteger (obj, "rtp-max-misorder");
- p_sys->autodetect = true;
demux->pf_demux = NULL;
demux->pf_control = Control;
@@ -543,6 +541,8 @@ static int OpenURL(vlc_object_t *obj)
if (p_sys->session == NULL)
goto error;
+ rtp_autodetect(VLC_OBJECT(demux), p_sys->session);
+
#ifdef HAVE_SRTP
char *key = var_CreateGetNonEmptyString (demux, "srtp-key");
if (key)
=====================================
modules/access/rtp/rtp.h
=====================================
@@ -222,7 +222,7 @@ struct vlc_rtp_es *vlc_rtp_es_request(void *, const es_format_t *fmt);
struct vlc_rtp_es *vlc_rtp_mux_request(void *, const char *name);
-void rtp_autodetect(vlc_object_t *, rtp_session_t *, const block_t *);
+void rtp_autodetect(vlc_object_t *, rtp_session_t *);
static inline uint8_t rtp_ptype (const block_t *block)
{
@@ -266,6 +266,5 @@ 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 */
- bool autodetect; /**< Payload type autodetection pending */
} demux_sys_t;
=====================================
modules/access/rtp/rtpfmt.c
=====================================
@@ -29,7 +29,6 @@
#include <vlc_common.h>
#include <vlc_demux.h>
-#include <vlc_dialog.h>
#include <vlc_aout.h> /* aout_FormatPrepare() */
#include "rtp.h"
@@ -230,28 +229,17 @@ static const struct vlc_rtp_pt_operations rtp_av_ts = {
/* Not using SDP, we need to guess the payload format used */
/* see http://www.iana.org/assignments/rtp-parameters */
-void rtp_autodetect(vlc_object_t *obj, rtp_session_t *session,
- const block_t *block)
+void rtp_autodetect(vlc_object_t *obj, rtp_session_t *session)
{
- uint8_t ptype = rtp_ptype (block);
- char type[6], proto[] = "RTP/AVP", numstr[4];
+ char type[] = "audio", proto[] = "RTP/AVP";
+ char format[] = "0 3 8 10 11 12 14 33";
struct vlc_sdp_media media = {
- .type = type, .port_count = 1, .proto = proto, .format = numstr
- };
+ .type = type, .port_count = 1, .proto = proto, .format = format };
- /* We only support static audio subtypes except MPV (PT=32).
- * MP2T (PT=33) can be treated as either audio or video. */
- memcpy(type, (ptype == 32) ? "video" : "audio", 6);
- snprintf(numstr, sizeof (numstr), "%hhu", ptype);
-
- if (vlc_rtp_add_media_types(obj, session, &media)) {
- msg_Err(obj, "unspecified payload format (type %"PRIu8")", ptype);
- msg_Info(obj, "A valid SDP is needed to parse this RTP stream.");
- vlc_dialog_display_error(obj, N_("SDP required"),
- N_("A description in SDP format is required to receive the RTP "
- "stream. Note that rtp:// URIs cannot work with dynamic "
- "RTP payload format (%"PRIu8")."), ptype);
- }
+ vlc_rtp_add_media_types(obj, session, &media);
+ strcpy(type, "video");
+ strcpy(format, "32");
+ vlc_rtp_add_media_types(obj, session, &media);
}
/*
=====================================
modules/access/rtp/session.c
=====================================
@@ -46,8 +46,7 @@ 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 *, const rtp_session_t *, rtp_source_t *);
+static void rtp_source_destroy(demux_t *, rtp_source_t *);
static void rtp_decode (demux_t *, const rtp_session_t *, rtp_source_t *);
@@ -77,7 +76,7 @@ rtp_session_create (demux_t *demux)
void rtp_session_destroy (demux_t *demux, rtp_session_t *session)
{
for (unsigned i = 0; i < session->srcc; i++)
- rtp_source_destroy (demux, session, session->srcv[i]);
+ rtp_source_destroy(demux, session->srcv[i]);
for (uint_fast8_t i = 0; i < session->ptc; i++)
vlc_rtp_pt_release(session->ptv[i]);
@@ -123,7 +122,10 @@ struct rtp_source_t
uint16_t last_seq; /* sequence of the next dequeued packet */
block_t *blocks; /* re-ordered blocks queue */
- void *opaque[]; /* Per-source private payload data */
+ struct {
+ struct vlc_rtp_pt *instance; /* Per-source current payload format */
+ void *opaque; /* Per-source payload format private data */
+ } pt;
};
/**
@@ -146,11 +148,7 @@ rtp_source_create (demux_t *demux, const rtp_session_t *session,
source->max_seq = source->bad_seq = init_seq;
source->last_seq = init_seq - 1;
source->blocks = NULL;
-
- /* Initializes all payload */
- for (unsigned i = 0; i < session->ptc; i++)
- source->opaque[i] = vlc_rtp_pt_begin(session->ptv[i], demux);
-
+ source->pt.instance = NULL;
msg_Dbg (demux, "added RTP source (%08x)", ssrc);
return source;
}
@@ -159,15 +157,11 @@ 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, const rtp_session_t *session,
- rtp_source_t *source)
+static void rtp_source_destroy(demux_t *demux, rtp_source_t *source)
{
msg_Dbg (demux, "removing RTP source (%08x)", source->ssrc);
-
- for (unsigned i = 0; i < session->ptc; i++)
- vlc_rtp_pt_end(session->ptv[i], source->opaque[i]);
-
+ if (source->pt.instance != NULL)
+ vlc_rtp_pt_end(source->pt.instance, source->pt.opaque);
block_ChainRelease (source->blocks);
free (source);
}
@@ -184,9 +178,8 @@ static inline uint32_t rtp_timestamp (const block_t *block)
return GetDWBE (block->p_buffer + 4);
}
-static struct vlc_rtp_pt *
-rtp_find_ptype (const rtp_session_t *session, rtp_source_t *source,
- const block_t *block, void **pt_data)
+static struct vlc_rtp_pt *rtp_find_ptype(const rtp_session_t *session,
+ const block_t *block)
{
uint8_t ptype = rtp_ptype (block);
@@ -195,11 +188,7 @@ rtp_find_ptype (const rtp_session_t *session, rtp_source_t *source,
struct vlc_rtp_pt *pt = session->ptv[i];
if (pt->number == ptype)
- {
- if (pt_data != NULL)
- *pt_data = source->opaque[i];
return pt;
- }
}
return NULL;
}
@@ -250,7 +239,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, session, tmp);
+ rtp_source_destroy(demux, tmp);
if (--session->srcc > 0)
session->srcv[i] = session->srcv[session->srcc - 1];
}
@@ -280,7 +269,7 @@ rtp_queue (demux_t *demux, rtp_session_t *session, block_t *block)
}
else
{
- const rtp_pt_t *pt = rtp_find_ptype (session, src, block, NULL);
+ const rtp_pt_t *pt = rtp_find_ptype(session, block);
if (pt != NULL)
{
@@ -411,7 +400,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
* match for random gaussian jitter).
*/
vlc_tick_t deadline;
- const rtp_pt_t *pt = rtp_find_ptype (session, src, block, NULL);
+ const rtp_pt_t *pt = rtp_find_ptype(session, block);
if (pt)
deadline = vlc_tick_from_samples(3 * src->jitter, pt->frequency);
else
@@ -469,8 +458,7 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
src->last_seq = rtp_seq (block);
/* Match the payload type */
- void *pt_data;
- struct vlc_rtp_pt *pt = rtp_find_ptype (session, src, block, &pt_data);
+ struct vlc_rtp_pt *pt = rtp_find_ptype(session, block);
if (pt == NULL)
{
msg_Dbg (demux, "unknown payload (%"PRIu8")",
@@ -478,6 +466,15 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
goto drop;
}
+ if (src->pt.instance != pt) {
+ /* Change the active payload type for this source. */
+ if (src->pt.instance != NULL)
+ vlc_rtp_pt_end(src->pt.instance, src->pt.opaque);
+
+ src->pt.instance = pt;
+ src->pt.opaque = vlc_rtp_pt_begin(pt, demux);
+ }
+
/* Computes the PTS from the RTP timestamp and payload RTP frequency..
* DTS is unknown. Also, while the clock frequency depends on the payload
* format, a single source MUST only use payloads of a chosen frequency.
@@ -513,7 +510,7 @@ rtp_decode (demux_t *demux, const rtp_session_t *session, rtp_source_t *src)
block->p_buffer += skip;
block->i_buffer -= skip;
- vlc_rtp_pt_decode(pt, pt_data, block);
+ vlc_rtp_pt_decode(pt, src->pt.opaque, block);
return;
drop:
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/99ee7a29c1671c5401f1f16ab444e723dfc5ec36...340d90556cf0d05aedc2fda6e8abf6d0dd300534
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/99ee7a29c1671c5401f1f16ab444e723dfc5ec36...340d90556cf0d05aedc2fda6e8abf6d0dd300534
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list