2 * filter_watermark.c -- watermark filter
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "filter_watermark.h"
23 #include <framework/mlt_factory.h>
24 #include <framework/mlt_frame.h>
25 #include <framework/mlt_producer.h>
26 #include <framework/mlt_transition.h>
34 static int filter_get_image( mlt_frame
this, uint8_t **image
, mlt_image_format
*format
, int *width
, int *height
, int writable
)
37 mlt_filter filter
= mlt_frame_pop_service( this );
38 mlt_properties properties
= mlt_filter_properties( filter
);
39 mlt_producer producer
= mlt_properties_get_data( properties
, "producer", NULL
);
40 mlt_transition composite
= mlt_properties_get_data( properties
, "composite", NULL
);
41 char *name
= mlt_properties_get( properties
, "_unique_id" );
43 if ( composite
== NULL
)
45 composite
= mlt_factory_transition( "composite", NULL
);
46 if ( composite
!= NULL
)
48 mlt_properties composite_properties
= mlt_transition_properties( composite
);
49 mlt_properties_pass( composite_properties
, properties
, "composite." );
50 mlt_properties_set_data( properties
, "composite", composite
, 0, ( mlt_destructor
)mlt_transition_close
, NULL
);
54 if ( producer
== NULL
)
56 char *resource
= mlt_properties_get( properties
, "resource" );
57 char *factory
= mlt_properties_get( properties
, "factory" );
58 producer
= mlt_factory_producer( factory
, resource
);
59 if ( producer
!= NULL
)
61 mlt_properties producer_properties
= mlt_producer_properties( producer
);
62 mlt_properties_set( producer_properties
, "eof", "loop" );
63 mlt_properties_pass( producer_properties
, properties
, "producer." );
64 mlt_properties_set_data( properties
, "producer", producer
, 0, ( mlt_destructor
)mlt_producer_close
, NULL
);
68 if ( composite
!= NULL
&& producer
!= NULL
)
70 mlt_service service
= mlt_producer_service( producer
);
71 mlt_frame b_frame
= NULL
;
72 mlt_properties frame_properties
= mlt_frame_properties( this );
73 mlt_position position
= mlt_properties_get_position( frame_properties
, name
);
75 mlt_producer_seek( producer
, position
);
76 if ( mlt_service_get_frame( service
, &b_frame
, 0 ) == 0 )
77 mlt_transition_process( composite
, this, b_frame
);
79 error
= mlt_frame_get_image( this, image
, format
, width
, height
, 1 );
81 mlt_frame_close( b_frame
);
85 error
= mlt_frame_get_image( this, image
, format
, width
, height
, 1 );
91 /** Filter processing.
94 static mlt_frame
filter_process( mlt_filter
this, mlt_frame frame
)
96 // Get the properties of the frame
97 mlt_properties properties
= mlt_frame_properties( frame
);
99 // Get a unique name to store the frame position
100 char *name
= mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
102 // Assign the current position to the name
103 mlt_properties_set_position( properties
, name
, mlt_frame_get_position( frame
) );
105 // Push the filter on to the stack
106 mlt_frame_push_service( frame
, this );
108 // Push the get_image on to the stack
109 mlt_frame_push_get_image( frame
, filter_get_image
);
114 /** Constructor for the filter.
117 mlt_filter
filter_watermark_init( void *arg
)
119 mlt_filter
this = mlt_filter_new( );
122 mlt_properties properties
= mlt_filter_properties( this );
123 this->process
= filter_process
;
124 mlt_properties_set( properties
, "factory", "fezzik" );
126 mlt_properties_set( properties
, "resource", arg
);