implement PROBE command
[melted] / src / melted / melted_commands.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.
 */