]> git.sesse.net Git - vlc/commitdiff
Cleanup RTP / RTSP boundary a little
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 23 Aug 2007 17:55:00 +0000 (17:55 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 23 Aug 2007 17:55:00 +0000 (17:55 +0000)
modules/stream_out/rtp.c
modules/stream_out/rtp.h
modules/stream_out/rtsp.c

index 297c019164bccc69da74b2fc19374f32e61d4eaf..17f8785f6f4f6510347d7c46e52c8d3549b20c47 100644 (file)
@@ -514,8 +514,7 @@ static void Close( vlc_object_t * p_this )
         }
     }
 
-    while( p_sys->i_rtsp > 0 )
-        RtspClientDel( p_stream, p_sys->rtsp[0] );
+    RtspUnsetup( p_stream );
 
     vlc_mutex_destroy( &p_sys->lock_sdp );
 
@@ -1112,23 +1111,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu );
 
     if( p_sys->p_rtsp_url )
-    {
-        char psz_urlc[strlen( p_sys->psz_rtsp_control ) + 1 + 10];
-
-        sprintf( psz_urlc, "%s/trackID=%d", p_sys->psz_rtsp_path, p_sys->i_es );
-        msg_Dbg( p_stream, "rtsp: adding %s\n", psz_urlc );
-        id->p_rtsp_url = httpd_UrlNewUnique( p_sys->p_rtsp_host, psz_urlc, NULL, NULL, NULL );
-
-        if( id->p_rtsp_url )
-        {
-            httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_DESCRIBE, RtspCallbackId, (void*)id );
-            httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_SETUP,    RtspCallbackId, (void*)id );
-            httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PLAY,     RtspCallbackId, (void*)id );
-            httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PAUSE,    RtspCallbackId, (void*)id );
-            httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_TEARDOWN, RtspCallbackId, (void*)id );
-        }
-    }
-
+        RtspSetupId( p_stream, id );
 
     /* Update p_sys context */
     vlc_mutex_lock( &p_sys->lock_es );
index f136838f0020dc76d98362527d1b076e623d5644..47e825a5c1e8fd4722d7f527423209f6f1577841 100644 (file)
 
 typedef struct rtsp_client_t rtsp_client_t;
 
-int RtspSetup( sout_stream_t *p_stream, vlc_url_t * );
-
-int RtspCallbackId( httpd_callback_sys_t *, httpd_client_t *,
-                    httpd_message_t *, httpd_message_t * );
-
-void RtspClientDel( sout_stream_t *, rtsp_client_t * );
+int RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url );
+int RtspSetupId( sout_stream_t *p_stream, sout_stream_id_t *id );
+void RtspUnsetup( sout_stream_t *p_stream );
 
 char *SDPGenerate( const sout_stream_t *p_stream,
                    const char *psz_destination, vlc_bool_t b_rtsp );
index 51c5c3c7e108b6c56c68877d01be3f508cdc2751..e2c9a181370f28d4afe4be71ad4aa79a2617a216 100644 (file)
@@ -52,10 +52,12 @@ struct rtsp_client_t
 static int  RtspCallback( httpd_callback_sys_t *p_args,
                           httpd_client_t *cl,
                           httpd_message_t *answer, httpd_message_t *query );
+static int  RtspCallbackId( httpd_callback_sys_t *p_args,
+                            httpd_client_t *cl,
+                            httpd_message_t *answer, httpd_message_t *query );
+static void RtspClientDel( sout_stream_t *p_stream, rtsp_client_t *rtsp );
 
-
-
-int RtspSetup( sout_stream_t *p_stream, vlc_url_t *url )
+int RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
 
@@ -73,7 +75,7 @@ int RtspSetup( sout_stream_t *p_stream, vlc_url_t *url )
              url->psz_host,  url->i_port > 0 ? url->i_port : 554, p_sys->psz_rtsp_path );
 
     p_sys->p_rtsp_url = httpd_UrlNewUnique( p_sys->p_rtsp_host, p_sys->psz_rtsp_path, NULL, NULL, NULL );
-    if( p_sys->p_rtsp_url == 0 )
+    if( p_sys->p_rtsp_url == NULL )
     {
         return VLC_EGENERIC;
     }
@@ -87,6 +89,36 @@ int RtspSetup( sout_stream_t *p_stream, vlc_url_t *url )
 }
 
 
+int RtspSetupId( sout_stream_t *p_stream, sout_stream_id_t *id )
+{
+    sout_stream_sys_t *p_sys = p_stream->p_sys;
+    char psz_urlc[strlen( p_sys->psz_rtsp_control ) + 1 + 10];
+
+    sprintf( psz_urlc, "%s/trackID=%d", p_sys->psz_rtsp_path, p_sys->i_es );
+    msg_Dbg( p_stream, "rtsp: adding %s\n", psz_urlc );
+    id->p_rtsp_url = httpd_UrlNewUnique( p_sys->p_rtsp_host, psz_urlc, NULL, NULL, NULL );
+
+    if( id->p_rtsp_url )
+    {
+        httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_DESCRIBE, RtspCallbackId, (void*)id );
+        httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_SETUP,    RtspCallbackId, (void*)id );
+        httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PLAY,     RtspCallbackId, (void*)id );
+        httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_PAUSE,    RtspCallbackId, (void*)id );
+        httpd_UrlCatch( id->p_rtsp_url, HTTPD_MSG_TEARDOWN, RtspCallbackId, (void*)id );
+    }
+
+    return VLC_SUCCESS;
+}
+
+
+void RtspUnsetup( sout_stream_t *p_stream )
+{
+    sout_stream_sys_t *p_sys = p_stream->p_sys;
+    while( p_sys->i_rtsp > 0 )
+        RtspClientDel( p_stream, p_sys->rtsp[0] );
+}
+
+
 static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, const char *psz_session )
 {
     rtsp_client_t *rtsp = malloc( sizeof( rtsp_client_t ));
@@ -122,7 +154,7 @@ static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, const char *psz_se
 }
 
 
-/*static*/ void RtspClientDel( sout_stream_t *p_stream, rtsp_client_t *rtsp )
+static void RtspClientDel( sout_stream_t *p_stream, rtsp_client_t *rtsp )
 {
     int i;
     TAB_REMOVE( p_stream->p_sys->i_rtsp, p_stream->p_sys->rtsp, rtsp );