adopt to winsock
[melted] / src / mvcp / mvcp.c
index c9fd6ff..fd92d3e 100644 (file)
@@ -542,9 +542,15 @@ mvcp_error_code mvcp_unit_set( mvcp this, int unit, const char *name, const char
 /** Get a unit configuration property.
 */
 
-mvcp_error_code mvcp_unit_get( mvcp this, int unit, char *name )
+mvcp_error_code mvcp_unit_get( mvcp this, int unit, char *name, char *value, int length )
 {
-       return mvcp_execute( this, 1024, "UGET U%d %s", unit, name );
+       mvcp_error_code error = mvcp_execute( this, 1024, "UGET U%d %s", unit, name );
+       if ( error == mvcp_ok )
+       {
+               mvcp_response response = mvcp_get_last_response( this );
+               strncpy( value, mvcp_response_get_line( response, 1 ), length );
+       }
+       return error;
 }
 
 /** Get a units status.
@@ -700,6 +706,27 @@ mvcp_error_code mvcp_list_get_error_code( mvcp_list list )
                return mvcp_malloc_failed;
 }
 
+static mvcp_error_code mvcp_list_parse( mvcp_list_entry entry, char* line)
+{
+       mvcp_tokeniser tokeniser = mvcp_tokeniser_init( );
+       mvcp_tokeniser_parse_new( tokeniser, line, " " );
+
+       if ( mvcp_tokeniser_count( tokeniser ) > 0 )
+       {
+               entry->clip = atoi( mvcp_tokeniser_get_string( tokeniser, 0 ) );
+               mvcp_util_strip( mvcp_tokeniser_get_string( tokeniser, 1 ), '\"' );
+               strcpy( entry->full, mvcp_tokeniser_get_string( tokeniser, 1 ) );
+               entry->in = atol( mvcp_tokeniser_get_string( tokeniser, 2 ) );
+               entry->out = atol( mvcp_tokeniser_get_string( tokeniser, 3 ) );
+               entry->max = atol( mvcp_tokeniser_get_string( tokeniser, 4 ) );
+               entry->size = atol( mvcp_tokeniser_get_string( tokeniser, 5 ) );
+               entry->fps = atof( mvcp_tokeniser_get_string( tokeniser, 6 ) );
+       }
+       mvcp_tokeniser_close( tokeniser );
+
+       return mvcp_ok;
+}
+
 /** Get a particular file entry in the list.
 */
 
@@ -710,21 +737,7 @@ mvcp_error_code mvcp_list_get( mvcp_list list, int index, mvcp_list_entry entry
        if ( index < mvcp_list_count( list ) )
        {
                char *line = mvcp_response_get_line( list->response, index + 2 );
-               mvcp_tokeniser tokeniser = mvcp_tokeniser_init( );
-               mvcp_tokeniser_parse_new( tokeniser, line, " " );
-
-               if ( mvcp_tokeniser_count( tokeniser ) > 0 )
-               {
-                       entry->clip = atoi( mvcp_tokeniser_get_string( tokeniser, 0 ) );
-                       mvcp_util_strip( mvcp_tokeniser_get_string( tokeniser, 1 ), '\"' );
-                       strcpy( entry->full, mvcp_tokeniser_get_string( tokeniser, 1 ) );
-                       entry->in = atol( mvcp_tokeniser_get_string( tokeniser, 2 ) );
-                       entry->out = atol( mvcp_tokeniser_get_string( tokeniser, 3 ) );
-                       entry->max = atol( mvcp_tokeniser_get_string( tokeniser, 4 ) );
-                       entry->size = atol( mvcp_tokeniser_get_string( tokeniser, 5 ) );
-                       entry->fps = atof( mvcp_tokeniser_get_string( tokeniser, 6 ) );
-               }
-               mvcp_tokeniser_close( tokeniser );
+               mvcp_list_parse( entry, line );
        }
        return error;
 }
@@ -752,6 +765,24 @@ void mvcp_list_close( mvcp_list list )
        }
 }
 
+/** Probe clip
+*/
+mvcp_error_code mvcp_probe_clip( mvcp this, char *filename, mvcp_list_entry entry)
+{
+       mvcp_response response;
+       mvcp_error_code error = mvcp_ok;
+
+       response = mvcp_parser_executef( this->parser, "PROBE \"%s\"", filename );
+       if ( mvcp_response_count( response ) >= 2 )
+               mvcp_list_parse( entry, mvcp_response_get_line( response, 1 ) );
+       else
+               error = mvcp_get_error_code( NULL, response );
+
+       mvcp_response_close( response );
+
+       return error;
+};
+
 /** List the currently connected nodes.
 */