]> git.sesse.net Git - vlc/blobdiff - modules/access/rtmp/access.c
net_Accept: remove timeout parameter
[vlc] / modules / access / rtmp / access.c
index c0bf34706f7bb6802dbdc5feb4fbc7e16a29dae2..910ed53cbf3e132fd0c89901b9fe031000a95323 100644 (file)
     "Caching value for RTMP streams. This " \
     "value should be set in milliseconds." )
 
+#define SWFURL_TEXT N_("Default SWF Referrer URL")
+#define SWFURL_LONGTEXT N_("The SFW URL to use as referrer when connecting to "\
+                           "the server. This is the SWF file that contained "  \
+                           "the stream.")
+
+#define PAGEURL_TEXT N_("Default Page Referrer URL")
+#define PAGEURL_LONGTEXT N_("The Page URL to use as referrer when connecting to "  \
+                            "the server. This is the page housing the SWF "    \
+                            "file.")
+
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
-vlc_module_begin();
-    set_description( N_("RTMP input") );
-    set_shortname( N_("RTMP") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACCESS );
+vlc_module_begin ()
+    set_description( N_("RTMP input") )
+    set_shortname( N_("RTMP") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
 
     add_integer( "rtmp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
-                 CACHING_LONGTEXT, true );
+                 CACHING_LONGTEXT, true )
+    add_string( "rtmp-swfurl", "file:///player.swf", NULL, SWFURL_TEXT,
+                SWFURL_LONGTEXT, true )
+    add_string( "rtmp-pageurl", "file:///player.htm", NULL, PAGEURL_TEXT,
+                PAGEURL_LONGTEXT, true )
 
-    set_capability( "access", 0 );
-    set_callbacks( Open, Close );
-    add_shortcut( "rtmp" );
-vlc_module_end();
+    set_capability( "access", 0 )
+    set_callbacks( Open, Close )
+    add_shortcut( "rtmp" )
+vlc_module_end ()
 
 
 /*****************************************************************************
@@ -115,18 +129,23 @@ static int Open( vlc_object_t *p_this )
     }
 
     length_path = strlen( p_sys->p_thread->url.psz_path );
-    length_media_name = strlen( strrchr( p_sys->p_thread->url.psz_path, '/' ) ) - 1;
+    char* psz_tmp = strrchr( p_sys->p_thread->url.psz_path, '/' );
+    if( !psz_tmp )
+        goto error;
+    length_media_name = strlen( psz_tmp ) - 1;
 
     p_sys->p_thread->psz_application = strndup( p_sys->p_thread->url.psz_path + 1, length_path - length_media_name - 2 );
     p_sys->p_thread->psz_media = strdup( p_sys->p_thread->url.psz_path + ( length_path - length_media_name ) );
 
+    p_sys->p_thread->psz_swf_url = var_CreateGetString( p_access, "rtmp-swfurl" );
+    p_sys->p_thread->psz_page_url = var_CreateGetString( p_access, "rtmp-pageurl" );
+
     msg_Dbg( p_access, "rtmp: host='%s' port=%d path='%s'",
              p_sys->p_thread->url.psz_host, p_sys->p_thread->url.i_port, p_sys->p_thread->url.psz_path );
 
     if( p_sys->p_thread->url.psz_username && *p_sys->p_thread->url.psz_username )
     {
-        msg_Dbg( p_access, "      user='%s', pwd='%s'",
-                 p_sys->p_thread->url.psz_username, p_sys->p_thread->url.psz_password );
+        msg_Dbg( p_access, "      user='%s'", p_sys->p_thread->url.psz_username );
     }
 
     /* Initialize thread variables */
@@ -157,7 +176,7 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->p_thread->p_base_object = p_this;
 
-    vlc_cond_init( p_sys->p_thread, &p_sys->p_thread->wait );
+    vlc_cond_init( &p_sys->p_thread->wait );
 
     vlc_mutex_init( &p_sys->p_thread->lock );
 
@@ -183,7 +202,7 @@ static int Open( vlc_object_t *p_this )
             goto error2;
         }
 
-        p_sys->p_thread->fd = net_Accept( p_access, p_fd_listen, -1 );
+        p_sys->p_thread->fd = net_Accept( p_access, p_fd_listen );
 
         net_ListenClose( p_fd_listen );
 
@@ -209,7 +228,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     if( vlc_thread_create( p_sys->p_thread, "rtmp control thread", ThreadControl,
-                           VLC_THREAD_PRIORITY_INPUT, false ) )
+                           VLC_THREAD_PRIORITY_INPUT ) )
     {
         msg_Err( p_access, "cannot spawn rtmp control thread" );
         goto error2;
@@ -220,6 +239,10 @@ static int Open( vlc_object_t *p_this )
         if( rtmp_connect_active( p_sys->p_thread ) < 0 )
         {
             msg_Err( p_access, "connect active failed");
+            /* Kill the running thread */
+            vlc_object_kill( p_sys->p_thread );
+            block_FifoWake( p_sys->p_thread->p_fifo_input );
+            vlc_thread_join( p_sys->p_thread );
             goto error2;
         }
     }
@@ -237,8 +260,13 @@ error2:
     vlc_cond_destroy( &p_sys->p_thread->wait );
     vlc_mutex_destroy( &p_sys->p_thread->lock );
 
+    block_FifoRelease( p_sys->p_thread->p_fifo_input );
+    block_FifoRelease( p_sys->p_thread->p_empty_blocks );
+
     free( p_sys->p_thread->psz_application );
     free( p_sys->p_thread->psz_media );
+    free( p_sys->p_thread->psz_swf_url );
+    free( p_sys->p_thread->psz_page_url );
 
     net_Close( p_sys->p_thread->fd );
 error:
@@ -264,7 +292,6 @@ static void Close( vlc_object_t * p_this )
 /*    p_sys->p_thread->b_die = true;*/
     vlc_object_kill( p_sys->p_thread );
     block_FifoWake( p_sys->p_thread->p_fifo_input );
-    block_FifoWake( p_sys->p_thread->p_empty_blocks );
 
     vlc_thread_join( p_sys->p_thread );
 
@@ -290,6 +317,8 @@ static void Close( vlc_object_t * p_this )
     vlc_UrlClean( &p_sys->p_thread->url );
     free( p_sys->p_thread->psz_application );
     free( p_sys->p_thread->psz_media );
+    free( p_sys->p_thread->psz_swf_url );
+    free( p_sys->p_thread->psz_page_url );
 
     vlc_object_detach( p_sys->p_thread );
     vlc_object_release( p_sys->p_thread );
@@ -446,7 +475,6 @@ static int Seek( access_t *p_access, int64_t i_pos )
 static int Control( access_t *p_access, int i_query, va_list args )
 {
     bool    *pb_bool;
-    int     *pi_int;
     int64_t *pi_64;
 
     switch( i_query )
@@ -469,11 +497,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
             break;
 
         /* */
-        case ACCESS_GET_MTU:
-            pi_int = (int*) va_arg( args, int * );
-            *pi_int = 0;
-            break;
-
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*) va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_access, "rtmp-caching" ) * INT64_C(1000);
@@ -507,6 +530,7 @@ static void* ThreadControl( vlc_object_t *p_this )
 {
     rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this;
     rtmp_packet_t *rtmp_packet;
+    int canc = vlc_savecancel ();
 
     rtmp_init_handler( p_thread->rtmp_handler );
 
@@ -543,5 +567,6 @@ static void* ThreadControl( vlc_object_t *p_this )
             block_FifoWake( p_thread->p_fifo_input );
         }
     }
+    vlc_restorecancel (canc);
     return NULL;
 }