[vlc-devel] Patch to specify audio/video payload type for RTP streaming

Rémi Denis-Courmont remi at remlab.net
Sun Apr 13 14:35:11 CEST 2014


Le dimanche 13 avril 2014, 14:15:38 Andreas Granig a écrit :
> Now if you do SDP offer/answer instead, the requesting client is sending
> an SDP offer with the codecs it supports, plus the payload type it
> wishes to use for those codecs.

Not really. In O/A, the sender must follow the payload format(s) and the 
transport parameters specified by the receiver. There is a lot more to that 
than the payload type number. Well it might work in some special case.

Anyway...

diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 4031d18..5462842 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -123,6 +123,15 @@
 #define PORT_VIDEO_LONGTEXT N_( \
     "This allows you to specify the default video port for the RTP 
streaming." )
 
+#define PTYPE_AUDIO_TEXT N_("Audio payload type")
+#define PTYPE_AUDIO_LONGTEXT N_( \
+    "This allows you to specify the payload type of the audio stream " \
+    "for RTP streaming." )
+#define PTYPE_VIDEO_TEXT N_("Video payload type")
+#define PTYPE_VIDEO_LONGTEXT N_( \
+    "This allows you to specify the payload type of the video stream " \
+    "for RTP streaming." )

This is confusing IMHO. This does not select the actual payload type, only the 
number it is mapped to.

+
 #define TTL_TEXT N_("Hop limit (TTL)")
 #define TTL_LONGTEXT N_( \
     "This is the hop limit (also known as \"Time-To-Live\" or TTL) of " \
@@ -223,6 +232,10 @@ vlc_module_begin ()
                  PORT_AUDIO_LONGTEXT, true )
     add_integer( SOUT_CFG_PREFIX "port-video", 0, PORT_VIDEO_TEXT,
                  PORT_VIDEO_LONGTEXT, true )
+    add_integer( SOUT_CFG_PREFIX "ptype-audio", 0, PTYPE_AUDIO_TEXT,
+                 PTYPE_AUDIO_LONGTEXT, true )
+    add_integer( SOUT_CFG_PREFIX "ptype-video", 0, PTYPE_VIDEO_TEXT,
+                 PTYPE_VIDEO_LONGTEXT, true )

The range 0-127 should be specified, and the default values too, probably 96 
and 97.
 
     add_integer( SOUT_CFG_PREFIX "ttl", -1, TTL_TEXT,
                  TTL_LONGTEXT, true )
@@ -264,7 +277,8 @@ vlc_module_end ()
  * Exported prototypes
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
-    "dst", "name", "cat", "port", "port-audio", "port-video", "*sdp", "ttl",
+    "dst", "name", "cat", "port", "port-audio", "port-video", 
+    "ptype-audio", "ptype-video", "*sdp", "ttl",
     "mux", "sap", "description", "url", "email", "phone",
     "proto", "rtcp-mux", "caching",
 #ifdef HAVE_SRTP
@@ -326,6 +340,8 @@ struct sout_stream_sys_t
     uint16_t  i_port;
     uint16_t  i_port_audio;
     uint16_t  i_port_video;
+    uint16_t  i_ptype_audio;
+    uint16_t  i_ptype_video;

uint8_t

     uint8_t   proto;
     bool      rtcp_mux;
     bool      b_latm;
@@ -412,6 +428,8 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_port       = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port" );
     p_sys->i_port_audio = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port-
audio" );
     p_sys->i_port_video = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port-
video" );
+    p_sys->i_ptype_audio = var_GetInteger( p_stream, SOUT_CFG_PREFIX "ptype-
audio" );
+    p_sys->i_ptype_video = var_GetInteger( p_stream, SOUT_CFG_PREFIX "ptype-
video" );
     p_sys->rtcp_mux     = var_GetBool( p_stream, SOUT_CFG_PREFIX "rtcp-mux" 
);
 
     if( p_sys->i_port_audio && p_sys->i_port_video == p_sys->i_port_audio )
@@ -1086,6 +1104,11 @@ static sout_stream_id_sys_t *Add( sout_stream_t 
*p_stream, es_format_t *p_fmt )
 
         id->i_port = i_port;
 
+        if( p_fmt->i_cat == AUDIO_ES && p_sys->i_ptype_audio > 0 )
+            id->rtp_fmt.payload_type = p_sys->i_ptype_audio;
+        else if( p_fmt->i_cat == VIDEO_ES && p_sys->i_ptype_video > 0 )
+            id->rtp_fmt.payload_type = p_sys->i_ptype_video;

No, zero is a legal value here.

+
         int type = SOCK_STREAM;
 
         switch( p_sys->proto )



-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list