hi,
attached set of patches extend melted functionality with PROBE command
that return information for specified file how it /supported/ by mlt
framework. it gives a chance to check if file is OK before adding one to
playlist.
--
Maksym Veremeyenko
From eeba3de17cda7f4ffc8a036cb9e3d69d9e1e2855 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Tue, 3 Jul 2012 14:05:53 +0300
Subject: [PATCH 1/3] implement PROBE command
---
src/melted/melted_commands.c | 36
src/melted/melted_commands.h |1 +
src/melted/melted_local.c|1 +
3 files changed, 38 insertions(+), 0 deletions(-)
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. },
--
1.7.7.6
From 13c65fdb52025d1fefa4c34d3cd8dd523c2bf1f2 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Tue, 3 Jul 2012 14:16:45 +0300
Subject: [PATCH 2/3] factorize mvcp_list line parsing
---
src/mvcp/mvcp.c | 37 ++---
1 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/mvcp/mvcp.c b/src/mvcp/mvcp.c
index 87b2148..99e086d 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