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 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;
 }
-- 
1.7.7.6

>From 491dc0e747a77d4a47b14e7d343a9820ab35ff8c Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1stereo.tv>
Date: Tue, 3 Jul 2012 14:45:21 +0300
Subject: [PATCH 3/3] implement probe clip mvcp support

---
 src/mvcp/mvcp.c |   18 ++++++++++++++++++
 src/mvcp/mvcp.h |    3 +++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/mvcp/mvcp.c b/src/mvcp/mvcp.c
index 99e086d..fd92d3e 100644
--- a/src/mvcp/mvcp.c
+++ b/src/mvcp/mvcp.c
@@ -765,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.
 */
 
diff --git a/src/mvcp/mvcp.h b/src/mvcp/mvcp.h
index 9490e6d..dd1a738 100644
--- a/src/mvcp/mvcp.h
+++ b/src/mvcp/mvcp.h
@@ -257,6 +257,9 @@ extern mvcp_error_code mvcp_push( mvcp, mlt_service, size_t, const char *, ... )
 /* Close function. */
 extern void mvcp_close( mvcp );
 
+/* Probe function */
+extern mvcp_error_code mvcp_probe_clip( mvcp, char *, mvcp_list_entry );
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to