From: Maksym Veremeyenko Date: Tue, 3 Jul 2012 11:05:53 +0000 (+0300) Subject: implement PROBE command X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=0bce140200382aca7fe8757544233158b9d2f4c7;p=melted implement PROBE command --- diff --git a/src/melted/melted_commands.c b/src/melted/melted_commands.c index c865a3d..45dc0d0 100644 --- a/src/melted/melted_commands.c +++ b/src/melted/melted_commands.c @@ -184,6 +184,42 @@ response_codes melted_list_clips( command_argument cmd_arg ) return error; } +/** Probe open clip. +*/ +response_codes melted_probe_clip( command_argument cmd_arg ) +{ + int l; + const char *file_name = (const char*) cmd_arg->argument; + char fullname[1024]; + mlt_producer producer; + mlt_profile profile; + + snprintf( fullname, sizeof(fullname), "%s%s", cmd_arg->root_dir, file_name ); + profile = mlt_profile_init(NULL); + producer = mlt_factory_producer( profile, NULL, fullname ); + if (!producer ) + { + mlt_profile_close(profile); + return RESPONSE_BAD_FILE; + }; + + l = mlt_producer_get_length( producer ); + mvcp_response_printf( cmd_arg->response, 10240, + "%d \"%s\" %d %d %d %d %.2f\n\n", + 0, /* index */ + cmd_arg->argument, /* title */ + 0, /* frame in */ + l - 1, /* frame out */ + l, /* frame count */ + l, /* length */ + mlt_producer_get_fps( producer ) ); + + mlt_producer_close( producer ); + mlt_profile_close(profile); + + return RESPONSE_SUCCESS_N; +} + /** Set a server configuration property. */ diff --git a/src/melted/melted_commands.h b/src/melted/melted_commands.h index c2424be..0b45007 100644 --- a/src/melted/melted_commands.h +++ b/src/melted/melted_commands.h @@ -41,6 +41,7 @@ extern response_codes melted_add_unit( command_argument ); extern response_codes melted_list_nodes( command_argument ); extern response_codes melted_list_units( command_argument ); extern response_codes melted_list_clips( command_argument ); +extern response_codes melted_probe_clip( command_argument ); extern response_codes melted_set_global_property( command_argument ); extern response_codes melted_get_global_property( command_argument ); diff --git a/src/melted/melted_local.c b/src/melted/melted_local.c index 580aedf..3f16543 100644 --- a/src/melted/melted_local.c +++ b/src/melted/melted_local.c @@ -174,6 +174,7 @@ static command_t vocabulary[] = {"UADD", melted_add_unit, 0, ATYPE_STRING, "Create a new playout unit (virtual VTR) to transmit to receiver specified in GUID argument."}, {"ULS", melted_list_units, 0, ATYPE_NONE, "Lists the units that have already been added to the server."}, {"CLS", melted_list_clips, 0, ATYPE_STRING, "Lists the clips at directory name argument."}, + {"PROBE", melted_probe_clip, 0, ATYPE_STRING, "Probe clip for playback. Output clip parameters."}, {"SET", melted_set_global_property, 0, ATYPE_PAIR, "Set a server configuration property."}, {"GET", melted_get_global_property, 0, ATYPE_STRING, "Get a server configuration property."}, {"RUN", melted_run, 0, ATYPE_STRING, "Run a batch file." },