]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
* grah one more compile issue
[vlc] / modules / stream_out / rtp.c
index c54b61564fbeaee68f5f7f77c3d63c8f621f5d8a..6f08d41f8a8ab851e86ce8f6ddeee34c7e6819ba 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#include "config.h"
+#include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#   include <unistd.h>
+#endif
 
 #include <errno.h>
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/sout.h>
+#include <vlc_sout.h>
+#include <vlc_block.h>
 
-#include "vlc_httpd.h"
-#include "vlc_url.h"
-#include "network.h"
-#include "charset.h"
+#include <vlc_httpd.h>
+#include <vlc_url.h>
+#include <vlc_network.h>
+#include <vlc_charset.h>
 
 /*****************************************************************************
  * Module descriptor
 #define PORT_VIDEO_LONGTEXT N_( \
     "This allows you to specify the default video port for the RTP streaming." )
 
-#define TTL_TEXT N_("Time-To-Live (TTL)")
+#define TTL_TEXT N_("Hop limit (TTL)")
 #define TTL_LONGTEXT N_( \
-    "This allows you to specify the Time-To-Live for the output stream." )
+    "This is the hop limit (also known as \"Time-To-Live\" or TTL) of " \
+    "the multicast packets sent by the stream output (0 = use operating " \
+    "system built-in default).")
 
 #define RFC3016_TEXT N_("MP4A LATM")
 #define RFC3016_LONGTEXT N_( \
@@ -291,11 +298,12 @@ static int Open( vlc_object_t *p_this )
     sout_stream_t       *p_stream = (sout_stream_t*)p_this;
     sout_instance_t     *p_sout = p_stream->p_sout;
     sout_stream_sys_t   *p_sys = NULL;
-    sout_cfg_t          *p_cfg = NULL;
+    config_chain_t      *p_cfg = NULL;
     vlc_value_t         val;
     vlc_bool_t          b_rtsp = VLC_FALSE;
 
-    sout_CfgParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg );
+    config_ChainParse( p_stream, SOUT_CFG_PREFIX,
+                       ppsz_sout_options, p_stream->p_cfg );
 
     p_sys = malloc( sizeof( sout_stream_sys_t ) );
 
@@ -521,17 +529,11 @@ static int Open( vlc_object_t *p_this )
         }
 
         /* create the SDP for a muxed stream (only once) */
-        /* FIXME  http://www.faqs.org/rfcs/rfc2327.html
-           All text fields should be UTF-8 encoded. Use global a:charset to announce this.
+        /* FIXME  http://www.faqs.org/rfcs/rfc4566.html
            o= - should be local username (no spaces allowed)
-           o= time should be hashed with some other value to garantue uniqueness
-           o= we need IP6 support?
+           o= time should be hashed with some other value to garantee uniqueness
            o= don't use the localhost address. use fully qualified domain name or IP4 address
-           p= international phone number (pass via vars?)
-           c= IP6 support
-           a= recvonly (missing)
-           a= type:broadcast (missing)
-           a= charset: (normally charset should be UTF-8, this can be used to override s= and i=)
+          a= source-filter: we need our source address
            a= x-plgroup: (missing)
            RTP packets need to get the correct src IP address  */
         if( net_AddressIsMulticast( (vlc_object_t *)p_stream, p_sys->psz_destination ) )
@@ -552,9 +554,11 @@ static int Open( vlc_object_t *p_this )
                   "i=%s\r\n"
                   "u=%s\r\n"
                   "e=%s\r\n"
+                  "c=IN IP%c %s%s\r\n"
                   "t=0 0\r\n" /* permanent stream */ /* when scheduled from vlm, we should set this info correctly */
                   "a=tool:"PACKAGE_STRING"\r\n"
-                  "c=IN IP%c %s%s\r\n"
+                  "a=recvonly\r\n"
+                  "a=type:broadcast\r\n"
                   "m=video %d RTP/AVP %d\r\n"
                   "a=rtpmap:%d %s\r\n",
                   p_sys->i_sdp_id, p_sys->i_sdp_version,
@@ -589,7 +593,7 @@ static int Open( vlc_object_t *p_this )
     var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val );
     if( *val.psz_string )
     {
-        sout_cfg_t *p_cfg;
+        config_chain_t *p_cfg;
 
         SDPHandleUrl( p_stream, val.psz_string );
 
@@ -690,6 +694,13 @@ static void Close( vlc_object_t * p_this )
         free( p_sys->psz_sdp );
         p_sys->psz_sdp = NULL;
     }
+    if( p_sys->b_export_sdp_file )
+    {
+#ifdef HAVE_UNISTD_H
+        unlink( p_sys->psz_sdp_file );
+#endif
+        free( p_sys->psz_sdp_file );
+    }
     free( p_sys );
 }
 
@@ -1148,8 +1159,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             {
                 uint8_t *p_buffer = p_fmt->p_extra;
                 int     i_buffer = p_fmt->i_extra;
-                char    *p_64_sps;
-                char    *p_64_pps;
+                char    *p_64_sps = NULL;
+                char    *p_64_pps = NULL;
                 char    hexa[6];
                 
                 while( i_buffer > 4 && 
@@ -1198,6 +1209,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             }
             else
                 id->psz_fmtp = strdup( "packetization-mode=1" );
+if( p_fmt->i_extra > 0 )
+msg_Dbg( p_stream, "WE HAVE %d bytes extra data", p_fmt->i_extra );
             break;
 
         case VLC_FOURCC( 'm', 'p', '4', 'v' ):
@@ -1635,7 +1648,7 @@ static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, char *psz_session
 {
     int i;
 
-    if( psz_session ) return NULL;
+    if( !psz_session ) return NULL;
 
     for( i = 0; i < p_stream->p_sys->i_rtsp; i++ )
     {
@@ -1723,7 +1736,7 @@ static int  RtspCallback( httpd_callback_sys_t *p_args,
             answer->i_status = 200;
             answer->psz_status = strdup( "OK" );
             httpd_MsgAdd( answer, "Content-type",  "%s", "application/sdp" );
-
+           httpd_MsgAdd( answer, "Content-Base",  "%s/", p_sys->psz_rtsp_control );
             answer->p_body = (uint8_t *)psz_sdp;
             answer->i_body = strlen( psz_sdp );
             break;
@@ -2493,6 +2506,10 @@ static int rtp_packetize_h264( sout_stream_t *p_stream, sout_stream_id_t *id,
     p_data+=3;
     i_data-=3;
     i_nal_type = p_data[0]&0x1f;
+
+    /* Skip global headers */
+    if( i_nal_type == 7 || i_nal_type == 8 )
+        return VLC_SUCCESS;
     
     if( i_data <= i_max ) /* The whole pack will fit in one rtp payload */
     {