static int get_next_token(char* str, int* pos, char* token, int* is_keyword)
{
int token_pos = 0;
- int str_len = strlen(str);
+ int str_len = strlen( str );
if( (*pos) >= str_len || str[*pos] == '\0' )
{
char tc[12] = "";
if (fps == 0)
{
- strncat( text, "-", MAX_TEXT_LEN - strlen(text) - 1 );
+ strncat( text, "-", MAX_TEXT_LEN - strlen( text ) - 1 );
}
else
{
int hours = minutes / 60;
minutes = minutes % 60;
sprintf(tc, "%.2d:%.2d:%.2d:%.2d", hours, minutes, seconds, frames);
- strncat( text, tc, MAX_TEXT_LEN - strlen(text) - 1 );
+ strncat( text, tc, MAX_TEXT_LEN - strlen( text ) - 1 );
}
}
{
int pos = mlt_frame_get_position( frame );
char s[12];
- snprintf( s, sizeof(s) - 1, "%d", pos );
- strncat( text, s, MAX_TEXT_LEN - strlen(text) - 1 );
+ snprintf( s, sizeof( s ) - 1, "%d", pos );
+ strncat( text, s, MAX_TEXT_LEN - strlen( text ) - 1 );
}
static void get_filedate_str( mlt_filter filter, mlt_frame frame, char* text )
{
- mlt_producer producer = mlt_producer_cut_parent(mlt_frame_get_original_producer( frame ));
- mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES(producer);
+ mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
+ mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES( producer );
char* filename = mlt_properties_get( producer_properties, "resource");
struct stat file_info;
struct tm* time_info = gmtime( &(file_info.st_mtime) );
char date[11] = "";
strftime( date, 11, "%Y/%m/%d", time_info );
- strncat( text, date, MAX_TEXT_LEN - strlen(text) - 1);
+ strncat( text, date, MAX_TEXT_LEN - strlen( text ) - 1);
}
}
+static void get_localfiledate_str( mlt_filter filter, mlt_frame frame, char* text )
+{
+ mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
+ mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES( producer );
+ char* filename = mlt_properties_get( producer_properties, "resource" );
+ struct stat file_info;
+
+ if( !stat( filename, &file_info ) )
+ {
+ struct tm* time_info = localtime( &(file_info.st_mtime) );
+ char date[11] = "";
+ strftime( date, 11, "%Y/%m/%d", time_info );
+ strncat( text, date, MAX_TEXT_LEN - strlen( text ) - 1);
+ }
+}
+
+static void get_resource_str( mlt_filter filter, mlt_frame frame, char* text )
+{
+ mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
+ mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES( producer );
+ strncat( text, mlt_properties_get( producer_properties, "resource" ), MAX_TEXT_LEN - strlen( text ) - 1 );
+}
/** Perform substitution for keywords that are enclosed in "# #".
*/
{
if(!is_keyword)
{
- strncat( result, keyword, MAX_TEXT_LEN - strlen(result) - 1 );
+ strncat( result, keyword, MAX_TEXT_LEN - strlen( result ) - 1 );
}
else if ( !strcmp( keyword, "timecode" ) )
{
- get_timecode_str(filter, frame, result);
+ get_timecode_str( filter, frame, result );
}
else if ( !strcmp( keyword, "frame" ) )
{
- get_frame_str(filter, frame, result);
+ get_frame_str( filter, frame, result );
}
else if ( !strcmp( keyword, "filedate" ) )
{
- get_filedate_str(filter, frame, result);
+ get_filedate_str( filter, frame, result );
+ }
+ else if ( !strcmp( keyword, "localfiledate" ) )
+ {
+ get_localfiledate_str( filter, frame, result );
}
else if ( !strcmp( keyword, "resource" ) )
{
- // special case: replace #resource# with cut parent resource name
- mlt_producer producer = mlt_producer_cut_parent(mlt_frame_get_original_producer( frame ));
- mlt_properties producer_properties = MLT_PRODUCER_PROPERTIES(producer);
- strncat( result, mlt_properties_get( producer_properties, "resource"), MAX_TEXT_LEN - strlen(result) - 1 );
+ get_resource_str( filter, frame, result );
}
else
{
}
}
-static void apply_filter(mlt_filter filter, mlt_frame frame )
+static void apply_filter( mlt_filter filter, mlt_frame frame )
{
mlt_properties my_properties = MLT_FILTER_PROPERTIES( filter );
mlt_filter watermark = mlt_properties_get_data( my_properties, "_watermark", NULL );
mlt_properties watermark_properties = MLT_FILTER_PROPERTIES( watermark );
- char* dynamic_text = mlt_properties_get( my_properties, "argument");
+ char* dynamic_text = mlt_properties_get( my_properties, "argument" );
// Check for keywords in dynamic text
if ( dynamic_text )
mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
- apply_filter(filter, frame);
+ apply_filter( filter, frame );
mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
return mlt_frame_get_image( frame, image, format, width, height, 1 );
}
-
/** Filter processing.
*/
mlt_filter filter = mlt_filter_new( );
mlt_filter watermark = mlt_factory_filter( profile, "watermark", "pango:" );
- // Initialise it
+ // Initialize it
if ( filter && watermark )
{
// Get the properties
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
// Store the watermark filter for future use
- mlt_properties_set_data( properties, "_watermark", watermark, 0, ( mlt_destructor )mlt_filter_close, NULL );
+ mlt_properties_set_data( properties, "_watermark", watermark, 0, (mlt_destructor)mlt_filter_close, NULL );
// Assign default values
mlt_properties_set( properties, "argument", arg ? arg: "#timecode#" );
{
if( filter )
{
- mlt_filter_close(filter);
+ mlt_filter_close( filter );
}
if( watermark )
{
- mlt_filter_close(watermark);
+ mlt_filter_close( watermark );
}
filter = NULL;