Re: [Mlt-devel] mlt/src/framework mlt_properties.c,1.39,1.40 mlt_property.c,1.11,1.12 mlt_property.h
Brought to you by:
ddennedy,
lilo_booter
From: Zachary D. <dre...@tc...> - 2005-08-21 21:06:41
|
Here are some examples: mlt_properties_set_int( properties_1, mlt_properties_get_int ( properties_2, "prop_a" ), "prop_a" ); mlt_properties_set_int( properties_1, mlt_properties_get_int ( properties_2, "prop_b" ), "prop_b" ); mlt_properties_set_double( properties_1, mlt_properties_get_double( properties_2, "another_property" ), "another_property" ); is replaced by this: mlt_properties_pass_list( properties_1, properties_2, "prop_a, prop_b, another_property" ); Likewise: mlt_property_set(property_1, mlt_property_get( mlt_property_2, "name" ), "name" ); // Internally mlt_properties_set(properties_1, mlt_properties_get ( mlt_properties_2, "name" ), "name" ); // Externally can be replaced by: mlt_property_pass( property_1, property_2, "name" ); // Internally mlt_properties_pass_property( properties_1, properties_2, "name" ); // Externally skipping unneeded string conversions. Data props must be serialisable to pass. For anyone else who is interested, Charlie and I have discussed revoking the mlt_property API and merging it into mlt_properties. It appears only mlt_properties uses mlt_property so now is the time to do it. This will also allow inlining of mlt_property's functions. Comments? -Zach On Aug 21, 2005, at 3:46 PM, Zachary Drew wrote: > Update of /cvsroot/mlt/mlt/src/framework > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23824 > > Modified Files: > mlt_properties.c mlt_property.c mlt_property.h > mlt_properties.h > Log Message: > Introduce some more civilized ways to copy properties. > See code comments for usage. > > > Index: mlt_property.c > =================================================================== > RCS file: /cvsroot/mlt/mlt/src/framework/mlt_property.c,v > retrieving revision 1.11 > retrieving revision 1.12 > diff -u -d -r1.11 -r1.12 > --- mlt_property.c 15 Aug 2005 06:25:37 -0000 1.11 > +++ mlt_property.c 21 Aug 2005 20:46:01 -0000 1.12 > @@ -310,4 +310,31 @@ > free( this ); > } > > +/** Pass the property 'that' to 'this'. > +* Who to blame: Zach <zac...@gm...> > +*/ > +void mlt_property_pass( mlt_property this, mlt_property that ) > +{ > + mlt_property_clear( this ); > + > + this->types = that->types; > > + if ( this->types & mlt_prop_int64 ) > + this->prop_int64 = that->prop_int64; > + else if ( this->types & mlt_prop_int ) > + this->prop_int = that->prop_int; > + else if ( this->types & mlt_prop_double ) > + this->prop_double = that->prop_double; > + else if ( this->types & mlt_prop_position ) > + this->prop_position = that->prop_position; > + else if ( this->types & mlt_prop_string ) > + { > + if ( that->prop_string != NULL ) > + this->prop_string = strdup( that->prop_string ); > + } > + else if ( this->types & mlt_prop_data && this->serialiser != > NULL ) > + { > + this->types = mlt_prop_string; > + this->prop_string = this->serialiser( this->data, this- > >length ); > + } > +} > > Index: mlt_properties.h > =================================================================== > RCS file: /cvsroot/mlt/mlt/src/framework/mlt_properties.h,v > retrieving revision 1.14 > retrieving revision 1.15 > diff -u -d -r1.14 -r1.15 > --- mlt_properties.h 14 Jan 2005 13:02:58 -0000 1.14 > +++ mlt_properties.h 21 Aug 2005 20:46:01 -0000 1.15 > @@ -49,6 +49,8 @@ > extern void mlt_properties_mirror( mlt_properties self, > mlt_properties that ); > extern int mlt_properties_inherit( mlt_properties self, > mlt_properties that ); > extern int mlt_properties_pass( mlt_properties self, > mlt_properties that, const char *prefix ); > +extern void mlt_properties_pass_property( mlt_properties this, > mlt_properties that, const char *name ); > +extern int mlt_properties_pass_list( mlt_properties this, > mlt_properties that, const char *list ); > extern int mlt_properties_set( mlt_properties self, const char > *name, const char *value ); > extern int mlt_properties_set_or_default( mlt_properties self, > const char *name, const char *value, const char *def ); > extern int mlt_properties_parse( mlt_properties self, const char > *namevalue ); > > Index: mlt_properties.c > =================================================================== > RCS file: /cvsroot/mlt/mlt/src/framework/mlt_properties.c,v > retrieving revision 1.39 > retrieving revision 1.40 > diff -u -d -r1.39 -r1.40 > --- mlt_properties.c 14 Jan 2005 13:02:58 -0000 1.39 > +++ mlt_properties.c 21 Aug 2005 20:46:01 -0000 1.40 > @@ -215,7 +215,7 @@ > return 0; > } > > -/** Allow the specification of a mirror. > +/** Mirror properties set on 'this' to 'that'. > */ > > void mlt_properties_mirror( mlt_properties this, mlt_properties > that ) > @@ -264,6 +264,7 @@ > return 0; > } > > + > /** Locate a property by name > */ > > @@ -335,6 +336,52 @@ > return property; > } > > +/** Pass property 'name' from 'that' to 'this' > +* Who to blame: Zach <zac...@gm...> > +*/ > + > +void mlt_properties_pass_property( mlt_properties this, > mlt_properties that, const char *name ) > +{ > + // Make sure the source property isn't null. > + mlt_property that_prop = mlt_properties_find( that, name ); > + if( that_prop == NULL ) > + return; > + > + mlt_property_pass( mlt_properties_fetch( this, name ), > that_prop ); > +} > + > +/** Pass all properties from 'that' to 'this' as found in comma > seperated 'list'. > +* Who to blame: Zach <zac...@gm...> > +*/ > + > +int mlt_properties_pass_list( mlt_properties this, mlt_properties > that, const char *list ) > +{ > + char *props = strdup( list ); > + char *ptr = props; > + char *delim = " ,\t\n"; // Any combination of spaces, > commas, tabs, and newlines > + int count, done = 0; > + > + while( !done ) > + { > + count = strcspn( ptr, delim ); > + > + if( ptr[count] == '\0' ) > + done = 1; > + else > + ptr[count] = '\0'; // Make it a real string > + > + mlt_properties_pass_property( this, that, ptr ); > + > + ptr += count + 1; > + ptr += strspn( ptr, delim ); > + } > + > + free( props ); > + > + return 0; > +} > + > + > /** Set the property. > */ > > > Index: mlt_property.h > =================================================================== > RCS file: /cvsroot/mlt/mlt/src/framework/mlt_property.h,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -u -d -r1.6 -r1.7 > --- mlt_property.h 14 Jan 2005 13:02:58 -0000 1.6 > +++ mlt_property.h 21 Aug 2005 20:46:01 -0000 1.7 > @@ -81,5 +81,7 @@ > extern void *mlt_property_get_data( mlt_property self, int *length ); > extern void mlt_property_close( mlt_property self ); > > +extern void mlt_property_pass( mlt_property this, mlt_property > that ); > + > #endif > > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle > Practices > Agile & Plan-Driven Development * Managing Projects & Teams * > Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/ > bsce5sf > _______________________________________________ > Mlt-devel mailing list > Mlt...@li... > https://lists.sourceforge.net/lists/listinfo/mlt-devel > |