X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmvcp%2Fmvcp.c;h=fd92d3e72b9c4b74dcd260ef3327c9ee7ff63d7e;hb=HEAD;hp=87b21480df2ae69ae63956cc345a865ce509eafc;hpb=0bbeb1246503d876635589d7e02912c7aea5da24;p=melted diff --git a/src/mvcp/mvcp.c b/src/mvcp/mvcp.c index 87b2148..fd92d3e 100644 --- a/src/mvcp/mvcp.c +++ b/src/mvcp/mvcp.c @@ -706,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. */ @@ -716,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; } @@ -758,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. */