[Mlt-devel] [PATCH] extend melted with file probe command

2012-07-03 Thread Maksym Veremeyenko

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 

[Mlt-devel] [PATCH] extend USTA output with current clip start time and playlist duration

2012-07-03 Thread Maksym Veremeyenko

Hi,

attached patch USTA output with current clip start time and playlist 
duration. Two more parameters helps detect global playlist playback and 
remaining time.


that breaks ABI with previous version so lib number should be incremented.

another issue is older mvcp client will not support status reading from 
newer version - they will reject to parse USTA output due to increased 
number of entries.


--

Maksym Veremeyenko
From 058653f92adbdfe9084a3d6f3fad707fdd6563cf Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Wed, 27 Jun 2012 15:19:09 +0300
Subject: [PATCH] extend USTA output with current clip start time and playlist
 duration

---
 src/melted/melted_unit.c |2 ++
 src/mvcp/mvcp_status.c   |   14 +++---
 src/mvcp/mvcp_status.h   |2 ++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/melted/melted_unit.c b/src/melted/melted_unit.c
index 66dfd9c..e4561dd 100644
--- a/src/melted/melted_unit.c
+++ b/src/melted/melted_unit.c
@@ -576,6 +576,8 @@ int melted_unit_get_status( melted_unit unit, mvcp_status status )
 			status-tail_length = mlt_producer_get_length( clip );
 			status-clip_index = mlt_playlist_current_clip( playlist );
 			status-seek_flag = 1;
+			status-dur = mlt_producer_get_length( producer );
+			status-start = info.start;
 		}
 
 		status-generation = mlt_properties_get_int( properties, generation );
diff --git a/src/mvcp/mvcp_status.c b/src/mvcp/mvcp_status.c
index 209290f..9c73151 100644
--- a/src/mvcp/mvcp_status.c
+++ b/src/mvcp/mvcp_status.c
@@ -34,7 +34,8 @@
 void mvcp_status_parse( mvcp_status status, char *text )
 {
 	mvcp_tokeniser tokeniser = mvcp_tokeniser_init( );
-	if ( mvcp_tokeniser_parse_new( tokeniser, text,   ) == 17 )
+	int r = mvcp_tokeniser_parse_new( tokeniser, text,   );
+	if ( 19 == r || 17 == r )
 	{
 		status-unit = atoi( mvcp_tokeniser_get_string( tokeniser, 0 ) );
 		strncpy( status-clip, mvcp_util_strip( mvcp_tokeniser_get_string( tokeniser, 2 ), '\' ), sizeof( status-clip ) );
@@ -53,6 +54,11 @@ void mvcp_status_parse( mvcp_status status, char *text )
 		status-seek_flag = atoi( mvcp_tokeniser_get_string( tokeniser, 14 ) );
 		status-generation = atoi( mvcp_tokeniser_get_string( tokeniser, 15 ) );
 		status-clip_index = atoi( mvcp_tokeniser_get_string( tokeniser, 16 ) );
+		if ( 19 == r )
+		{
+			status-start = atoi( mvcp_tokeniser_get_string( tokeniser, 17 ) );
+			status-dur = atoi( mvcp_tokeniser_get_string( tokeniser, 18 ) );
+		};
 
 		if ( !strcmp( mvcp_tokeniser_get_string( tokeniser, 1 ), unknown ) )
 			status-status = unit_unknown;
@@ -121,7 +127,7 @@ char *mvcp_status_serialise( mvcp_status status, char *text, int length )
 			break;
 	}
 
-	snprintf( text, length, %d %s \%s\ %d %d %.2f %d %d %d \%s\ %d %d %d %d %d %d %d\r\n,
+	snprintf( text, length, %d %s \%s\ %d %d %.2f %d %d %d \%s\ %d %d %d %d %d %d %d %d %d\r\n,
 			status-unit,
 			status_string,
 			status-clip,
@@ -138,7 +144,9 @@ char *mvcp_status_serialise( mvcp_status status, char *text, int length )
 			status-tail_length,
 			status-seek_flag,
 			status-generation,
-			status-clip_index );
+			status-clip_index,
+			status-start,
+			status-dur );
 
 	return text;
 }
diff --git a/src/mvcp/mvcp_status.h b/src/mvcp/mvcp_status.h
index c629473..c9128f7 100644
--- a/src/mvcp/mvcp_status.h
+++ b/src/mvcp/mvcp_status.h
@@ -67,6 +67,8 @@ typedef struct
 	int generation;
 	int clip_index;
 	int dummy;
+	int dur;	/** duration of playlist */
+	int start;	/** time head clip relative to the beginning of the playlist */
 }
 *mvcp_status, mvcp_status_t;
 
-- 
1.7.4.4

--
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


Re: [Mlt-devel] [PATCH] extend USTA output with current clip start time and playlist duration

2012-07-03 Thread Dan Dennedy
On Tue, Jul 3, 2012 at 5:42 AM, Maksym Veremeyenko ve...@m1stereo.tv wrote:
 Hi,

 attached patch USTA output with current clip start time and playlist
 duration. Two more parameters helps detect global playlist playback and
 remaining time.

 that breaks ABI with previous version so lib number should be incremented.

ok

 another issue is older mvcp client will not support status reading from
 newer version - they will reject to parse USTA output due to increased
 number of entries.

I think we should make a new command USTATUS that also includes a
version or new text format that affords extensibility.

-- 
+-DRD-+

--
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