Commit c6c52cc8 authored by Pierre Ynard's avatar Pierre Ynard
Browse files

rtp: option to assume Theora for unknown dynamic payloads

Theora support is enabled. An option is added to manually select the
payload format of unknown dynamic payload types, in pre-arranged
streaming setups, without needing SDP. The only choice for now is
Theora.
parent 75d5cb12
......@@ -5,7 +5,8 @@ librtp_plugin_la_SOURCES = \
rtp.c \
rtp.h \
input.c \
session.c
session.c \
xiph.c
librtp_plugin_la_CFLAGS = $(AM_CFLAGS)
librtp_plugin_la_LIBADD = $(AM_LIBADD)
librtp_plugin_la_DEPENDENCIES =
......
......@@ -75,6 +75,16 @@
"RTP packets will be discarded if they are too far behind (i.e. in the " \
"past) by this many packets from the last received packet." )
#define RTP_DYNAMIC_PT_TEXT N_("RTP payload format assumed for dynamic " \
"payloads")
#define RTP_DYNAMIC_PT_LONGTEXT N_( \
"This payload format will be assumed for dynamic payload types " \
"(between 96 and 127) if it can't be determined otherwise with " \
"out-of-band mappings (SDP)" )
static const char *const dynamic_pt_list[] = { "theora" };
static const char *const dynamic_pt_list_text[] = { "Theora Encoded Video" };
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
......@@ -114,6 +124,9 @@ vlc_module_begin ()
add_integer ("rtp-max-misorder", 100, RTP_MAX_MISORDER_TEXT,
RTP_MAX_MISORDER_LONGTEXT, true)
change_integer_range (0, 32767)
add_string ("rtp-dynamic-pt", NULL, RTP_DYNAMIC_PT_TEXT,
RTP_DYNAMIC_PT_LONGTEXT, true)
change_string_list (dynamic_pt_list, dynamic_pt_list_text, NULL)
/*add_shortcut ("sctp")*/
add_shortcut ("dccp", "rtptcp", /* "tcp" is already taken :( */
......@@ -407,19 +420,19 @@ static int Control (demux_t *demux, int i_query, va_list args)
* Generic packet handlers
*/
static void *codec_init (demux_t *demux, es_format_t *fmt)
void *codec_init (demux_t *demux, es_format_t *fmt)
{
return es_out_Add (demux->out, fmt);
}
static void codec_destroy (demux_t *demux, void *data)
void codec_destroy (demux_t *demux, void *data)
{
if (data)
es_out_Del (demux->out, (es_out_id_t *)data);
}
/* Send a packet to decoder */
static void codec_decode (demux_t *demux, void *data, block_t *block)
void codec_decode (demux_t *demux, void *data, block_t *block)
{
if (data)
{
......@@ -695,6 +708,28 @@ int rtp_autodetect (demux_t *demux, rtp_session_t *session,
pt.frequency = 90000;
break;
}
else if (ptype >= 96)
{
char *dynamic = var_InheritString(demux, "rtp-dynamic-pt");
if (dynamic == NULL)
;
else if (!strcmp(dynamic, "theora"))
{
msg_Dbg (demux, "assuming Theora Encoded Video");
pt.init = theora_init;
pt.destroy = xiph_destroy;
pt.decode = xiph_decode;
pt.frequency = 90000;
}
else
{
msg_Err (demux, "invalid dynamic payload format `%s' "
"specified", dynamic);
free(dynamic);
return -1;
}
free(dynamic);
}
else
{
return -1;
......@@ -706,5 +741,5 @@ int rtp_autodetect (demux_t *demux, rtp_session_t *session,
/*
* Dynamic payload type handlers
* Hmm, none implemented yet.
* Hmm, none implemented yet apart from Xiph ones.
*/
......@@ -39,6 +39,14 @@ static inline uint8_t rtp_ptype (const block_t *block)
return block->p_buffer[1] & 0x7F;
}
void *codec_init (demux_t *demux, es_format_t *fmt);
void codec_destroy (demux_t *demux, void *data);
void codec_decode (demux_t *demux, void *data, block_t *block);
void *theora_init (demux_t *demux);
void xiph_destroy (demux_t *demux, void *data);
void xiph_decode (demux_t *demux, void *data, block_t *block);
/** @section RTP session */
rtp_session_t *rtp_session_create (demux_t *);
void rtp_session_destroy (demux_t *, rtp_session_t *);
......
......@@ -61,6 +61,7 @@ static void *xiph_init (bool vorbis)
return self;
}
#if 0
/* PT=dynamic
* vorbis: Xiph Vorbis audio (RFC 5215)
*/
......@@ -69,17 +70,18 @@ static void *vorbis_init (demux_t *demux)
(void)demux;
return xiph_init (true);
}
#endif
/* PT=dynamic
* vorbis: Xiph Theora video
*/
static void *theora_init (demux_t *demux)
void *theora_init (demux_t *demux)
{
(void)demux;
return xiph_init (false);
}
static void xiph_destroy (demux_t *demux, void *data)
void xiph_destroy (demux_t *demux, void *data)
{
rtp_xiph_t *self = data;
......@@ -145,7 +147,7 @@ static ssize_t xiph_header (void **pextra, const uint8_t *buf, size_t len)
}
static void xiph_decode (demux_t *demux, void *data, block_t *block)
void xiph_decode (demux_t *demux, void *data, block_t *block)
{
rtp_xiph_t *self = data;
......@@ -240,7 +242,12 @@ static void xiph_decode (demux_t *demux, void *data, block_t *block)
case 0: /* Raw payload */
{
if (self->ident != ident)
break; /* Ignore raw without configuration */
{
msg_Warn (demux, self->vorbis ?
"ignoring raw Vorbis payload without configuration" :
"ignoring raw Theora payload without configuration");
break;
}
block_t *raw = block_Alloc (len);
memcpy (raw->p_buffer, block->p_buffer, len);
raw->i_pts = block->i_pts; /* FIXME: what about pkts > 1 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment