[vlc-commits] commit: rtp: option to assume Theora for unknown dynamic payloads ( Pierre Ynard )

git at videolan.org git at videolan.org
Sat Dec 4 00:09:31 CET 2010


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sat Dec  4 00:07:48 2010 +0100| [c6c52cc8d4aa1243e7b42087dfd82c948bbfd7e8] | committer: Pierre Ynard 

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c6c52cc8d4aa1243e7b42087dfd82c948bbfd7e8
---

 modules/access/rtp/Modules.am |    3 +-
 modules/access/rtp/rtp.c      |   43 +++++++++++++++++++++++++++++++++++++---
 modules/access/rtp/rtp.h      |    8 +++++++
 modules/access/rtp/xiph.c     |   15 ++++++++++---
 4 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/modules/access/rtp/Modules.am b/modules/access/rtp/Modules.am
index 849c8e4..57b39ce 100644
--- a/modules/access/rtp/Modules.am
+++ b/modules/access/rtp/Modules.am
@@ -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 =
diff --git a/modules/access/rtp/rtp.c b/modules/access/rtp/rtp.c
index 3cf48eb..b9aec03 100644
--- a/modules/access/rtp/rtp.c
+++ b/modules/access/rtp/rtp.c
@@ -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.
  */
diff --git a/modules/access/rtp/rtp.h b/modules/access/rtp/rtp.h
index c90b010..e9deebd 100644
--- a/modules/access/rtp/rtp.h
+++ b/modules/access/rtp/rtp.h
@@ -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 *);
diff --git a/modules/access/rtp/xiph.c b/modules/access/rtp/xiph.c
index 4866513..a40d1f6 100644
--- a/modules/access/rtp/xiph.c
+++ b/modules/access/rtp/xiph.c
@@ -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 */



More information about the vlc-commits mailing list