implement PROBE command
authorMaksym Veremeyenko <verem@m1stereo.tv>
Tue, 3 Jul 2012 11:05:53 +0000 (14:05 +0300)
committerMaksym Veremeyenko <verem@m1stereo.tv>
Tue, 10 Jul 2012 06:51:35 +0000 (09:51 +0300)
src/melted/melted_commands.c
src/melted/melted_commands.h
src/melted/melted_local.c

index c865a3d..45dc0d0 100644 (file)
@@ -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.
 */
 
index c2424be..0b45007 100644 (file)
@@ -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 );
 
index 580aedf..3f16543 100644 (file)
@@ -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." },