]> git.sesse.net Git - vlc/blobdiff - modules/access/ftp.c
implemented the display device selector.
[vlc] / modules / access / ftp.c
index 070cf4099ed2cd0d2f4f48e2e84b75012b0f4808..8138995d4685180db8ab1106c5787b633b11cee6 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <assert.h>
@@ -92,10 +96,10 @@ vlc_module_end();
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int Read( access_t *, uint8_t *, int );
-static int Write( sout_access_out_t *, block_t * );
+static ssize_t Read( access_t *, uint8_t *, size_t );
+static ssize_t Write( sout_access_out_t *, block_t * );
 static int Seek( access_t *, int64_t );
-static int OutSeek( sout_access_out_t *, int64_t );
+static int OutSeek( sout_access_out_t *, off_t );
 static int Control( access_t *, int, va_list );
 
 struct access_sys_t
@@ -461,7 +465,7 @@ static int OutSeek( sout_access_out_t *p_access, off_t i_pos )
 /*****************************************************************************
  * Read:
  *****************************************************************************/
-static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
+static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
 {
     access_sys_t *p_sys = p_access->p_sys;
     int i_read;
@@ -485,7 +489,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
 /*****************************************************************************
  * Write:
  *****************************************************************************/
-static int Write( sout_access_out_t *p_access, block_t *p_buffer )
+static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 {
     access_sys_t *p_sys = GET_OUT_SYS(p_access);
     size_t i_write = 0;
@@ -550,17 +554,21 @@ static int Control( access_t *p_access, int i_query, va_list args )
 
         /* */
         case ACCESS_SET_PAUSE_STATE:
-            /* Nothing to do */
+            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
+            if ( !pb_bool )
+              return Seek( p_access, p_access->info.i_pos );
             break;
 
         case ACCESS_GET_TITLE_INFO:
         case ACCESS_SET_TITLE:
         case ACCESS_SET_SEEKPOINT:
         case ACCESS_SET_PRIVATE_ID_STATE:
+        case ACCESS_GET_CONTENT_TYPE:
+        case ACCESS_GET_META:
             return VLC_EGENERIC;
 
         default:
-            msg_Warn( p_access, "unimplemented query in control);
+            msg_Warn( p_access, "unimplemented query in control: %d", i_query);
             return VLC_EGENERIC;
 
     }
@@ -615,7 +623,7 @@ static int ftp_ReadCommand( vlc_object_t *p_access, access_sys_t *p_sys,
     if( psz_line == NULL || strlen( psz_line ) < 3 )
     {
         msg_Err( p_access, "cannot get answer" );
-        if( psz_line ) free( psz_line );
+        free( psz_line );
         if( pi_answer ) *pi_answer    = 500;
         if( ppsz_answer ) *ppsz_answer  = NULL;
         return -1;
@@ -660,7 +668,7 @@ static int ftp_ReadCommand( vlc_object_t *p_access, access_sys_t *p_sys,
 }
 
 static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
-                            off_t i_start )
+                            int64_t i_start )
 {
     char psz_ipv4[16], *psz_ip = p_sys->sz_epsv_ip;
     int  i_answer;
@@ -774,11 +782,16 @@ static int ftp_StopStream ( vlc_object_t *p_access, access_sys_t *p_sys )
 
     if( p_sys->fd_data != -1 )
     {
+        int i_answer;
+        ftp_ReadCommand( p_access, p_sys, &i_answer, NULL );
+        if ( i_answer != 227 )
+            /* If answer is from the previous command,
+             * rathen that succesful ABOR - read next command */
+            ftp_ReadCommand( p_access, p_sys, NULL, NULL );
+
         net_Close( p_sys->fd_data );
         p_sys->fd_data = -1;
-        ftp_ReadCommand( p_access, p_sys, NULL, NULL );
     }
-    ftp_ReadCommand( p_access, p_sys, NULL, NULL );
 
     return VLC_SUCCESS;
 }