]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
Set the DCCP service code(s) from RTP stream output
[vlc] / modules / stream_out / rtp.c
index 193f0221fb0b03177f6ccfb0300ebddaaecea5c4..712db8fcb0e0d1c6ad2d91df135dfd4c760925b4 100644 (file)
     "This sends and receives RTCP packet multiplexed over the same port " \
     "as RTP packets." )
 
-#define DCCP_TEXT N_("DCCP transport")
-#define DCCP_LONGTEXT N_( \
-    "This enables DCCP instead of UDP as a transport for RTP." )
-#define TCP_TEXT N_("TCP transport")
-#define TCP_LONGTEXT N_( \
-    "This enables TCP instead of UDP as a transport for RTP." )
-#define UDP_LITE_TEXT N_("UDP-Lite transport")
-#define UDP_LITE_LONGTEXT N_( \
-    "This enables UDP-Lite instead of UDP as a transport for RTP." )
+#define PROTO_TEXT N_("Transport protocol")
+#define PROTO_LONGTEXT N_( \
+    "This selects which transport protocol to use for RTP." )
+
+static const char *const ppsz_protos[] = {
+    "dccp", "sctp", "tcp", "udp", "udplite",
+};
+
+static const char *const ppsz_protocols[] = {
+    "DCCP", "SCTP", "TCP", "UDP", "UDP-Lite",
+};
 
 #define RFC3016_TEXT N_("MP4A LATM")
 #define RFC3016_LONGTEXT N_( \
@@ -168,6 +170,9 @@ vlc_module_begin();
     add_string( SOUT_CFG_PREFIX "phone", "", NULL, PHONE_TEXT,
                 PHONE_LONGTEXT, VLC_TRUE );
 
+    add_string( SOUT_CFG_PREFIX "proto", "udp", NULL, PROTO_TEXT,
+                PROTO_LONGTEXT, VLC_FALSE );
+        change_string_list( ppsz_protos, ppsz_protocols, NULL );
     add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, PORT_TEXT,
                  PORT_LONGTEXT, VLC_TRUE );
     add_integer( SOUT_CFG_PREFIX "port-audio", 1230, NULL, PORT_AUDIO_TEXT,
@@ -177,17 +182,9 @@ vlc_module_begin();
 
     add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL, TTL_TEXT,
                  TTL_LONGTEXT, VLC_TRUE );
-
     add_bool( SOUT_CFG_PREFIX "rtcp-mux", VLC_FALSE, NULL,
               RTCP_MUX_TEXT, RTCP_MUX_LONGTEXT, VLC_FALSE );
 
-    add_bool( SOUT_CFG_PREFIX "dccp", VLC_FALSE, NULL,
-              DCCP_TEXT, DCCP_LONGTEXT, VLC_FALSE );
-    add_bool( SOUT_CFG_PREFIX "tcp", VLC_FALSE, NULL,
-              TCP_TEXT, TCP_LONGTEXT, VLC_FALSE );
-    add_bool( SOUT_CFG_PREFIX "udplite", VLC_FALSE, NULL,
-              UDP_LITE_TEXT, UDP_LITE_LONGTEXT, VLC_FALSE );
-
     add_bool( SOUT_CFG_PREFIX "mp4a-latm", 0, NULL, RFC3016_TEXT,
                  RFC3016_LONGTEXT, VLC_FALSE );
 
@@ -200,7 +197,7 @@ vlc_module_end();
 static const char *ppsz_sout_options[] = {
     "dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux",
     "description", "url", "email", "phone",
-    "rtcp-mux", "dccp", "tcp", "udplite",
+    "proto", "rtcp-mux",
     "mp4a-latm", NULL
 };
 
@@ -310,7 +307,6 @@ struct sout_stream_id_t
     int64_t           i_caching;
 };
 
-
 /*****************************************************************************
  * Open:
  *****************************************************************************/
@@ -369,23 +365,40 @@ static int Open( vlc_object_t *p_this )
 
     /* Transport protocol */
     p_sys->proto = IPPROTO_UDP;
+    psz = var_GetNonEmptyString (p_stream, SOUT_CFG_PREFIX"proto");
 
-    if( var_GetBool( p_stream, SOUT_CFG_PREFIX "dccp" ) )
+    if ((psz == NULL) || !strcasecmp (psz, "udp"))
+        (void)0; /* default */
+    else
+    if (!strcasecmp (psz, "dccp"))
     {
         p_sys->proto = IPPROTO_DCCP;
         p_sys->rtcp_mux = VLC_TRUE; /* Force RTP/RTCP mux */
     }
 #if 0
     else
-    if( var_GetBool( p_stream, SOUT_CFG_PREFIX "tcp" ) )
+    if (!strcasecmp (psz, "sctp"))
     {
         p_sys->proto = IPPROTO_TCP;
         p_sys->rtcp_mux = VLC_TRUE; /* Force RTP/RTCP mux */
     }
+#endif
+#if 0
     else
+    if (!strcasecmp (psz, "tcp"))
+    {
+        p_sys->proto = IPPROTO_TCP;
+        p_sys->rtcp_mux = VLC_TRUE; /* Force RTP/RTCP mux */
+    }
 #endif
-    if( var_GetBool( p_stream, SOUT_CFG_PREFIX "udplite" ) )
+    else
+    if (!strcasecmp (psz, "udplite") || !strcasecmp (psz, "udp-lite"))
         p_sys->proto = IPPROTO_UDPLITE;
+    else
+        msg_Warn (p_this, "unknown or unsupported transport protocol \"%s\"",
+                  psz);
+    free (psz);
+    var_Create (p_this, "dccp-service", VLC_VAR_STRING);
 
     if( ( p_sys->psz_destination == NULL ) && !b_rtsp )
     {
@@ -763,11 +776,9 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
         {
             if( id->listen_fd != NULL )
                 sdp_AddAttribute( &psz_sdp, "setup", "passive" );
-#if 0
             if( p_sys->proto == IPPROTO_DCCP )
                 sdp_AddAttribute( &psz_sdp, "dccp-service-code", 
                                   "SC:RTP%c", toupper( mime_major[0] ) );
-#endif
         }
     }
 
@@ -886,8 +897,19 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     if( p_sys->psz_destination != NULL )
         switch( p_sys->proto )
         {
-            case IPPROTO_TCP:
             case IPPROTO_DCCP:
+            {
+                const char *code;
+                switch (id->i_cat)
+                {
+                    case VIDEO_ES: code = "RTPV";     break;
+                    case AUDIO_ES: code = "RTPARTPV"; break;
+                    case SPU_ES:   code = "RTPTRPTV"; break;
+                    default:       code = "RTPORTPV"; break;
+                }
+                var_SetString (p_stream, "dccp-service", code);
+            }   /* fall through */
+            case IPPROTO_TCP:
                 id->listen_fd = net_Listen( VLC_OBJECT(p_stream),
                                             p_sys->psz_destination, i_port,
                                             p_sys->proto );
@@ -1665,5 +1687,6 @@ static sout_access_out_t *GrabberCreate( sout_stream_t *p_stream )
     p_grab->p_sys       = (sout_access_out_sys_t *)p_stream;
     p_grab->pf_seek     = NULL;
     p_grab->pf_write    = AccessOutGrabberWrite;
+    vlc_object_attach( p_grab, p_stream );
     return p_grab;
 }