[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11079] branches/soc-2007-mosani/source/ blender: This is the second of two commits which add Peter Schlaile' s new plugin API WIP to my branch.

Aaron Moore two.a.ron at gmail.com
Tue Jun 26 20:20:05 CEST 2007


Revision: 11079
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11079
Author:   mosani
Date:     2007-06-26 20:20:05 +0200 (Tue, 26 Jun 2007)

Log Message:
-----------
This is the second of two commits which add Peter Schlaile's new plugin API WIP to my branch.
This adds the new system in the hole that was left by the deleted old system.

Added Paths:
-----------
    branches/soc-2007-mosani/source/blender/blenpluginapi/
    branches/soc-2007-mosani/source/blender/blenpluginapi/CMakeLists.txt
    branches/soc-2007-mosani/source/blender/blenpluginapi/Makefile
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_api.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_obsolete.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_private.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_register.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_types.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/SConscript
    branches/soc-2007-mosani/source/blender/blenpluginapi/documentation.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/externdef.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/floatpatch.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/iff.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/intern/
    branches/soc-2007-mosani/source/blender/blenpluginapi/intern/Makefile
    branches/soc-2007-mosani/source/blender/blenpluginapi/intern/pluginapi.c
    branches/soc-2007-mosani/source/blender/blenpluginapi/plugin.DEF
    branches/soc-2007-mosani/source/blender/blenpluginapi/plugin.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/util.h

Added: branches/soc-2007-mosani/source/blender/blenpluginapi/CMakeLists.txt
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/CMakeLists.txt	2007-06-26 18:20:05 UTC (rev 11079)
@@ -0,0 +1,42 @@
+# $Id: CMakeLists.txt,v 1.2 2006/11/17 13:07:44 jbinto Exp $
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License.  See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2006, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+
+FILE(GLOB SRC intern/*.c)
+
+SET(INC 
+  . .. ../../../intern/guardedalloc ../blenlib ../imbuf ../makesdna ../blenkernel ../blenloader
+)
+
+IF(WITH_QUICKTIME)
+  SET(INC ${INC} ${QUICKTIME_INC})
+  ADD_DEFINITIONS(-DWITH_QUICKTIME)
+ENDIF(WITH_QUICKTIME)
+
+BLENDERLIB(bf_blenpluginapi "${SRC}" "${INC}")
+#env.BlenderLib ( libname = 'bf_blenpluginapi', sources = sources, includes = Split(incs), defines = defs, libtype=['core', 'player'], priority = [75, 35] )

Added: branches/soc-2007-mosani/source/blender/blenpluginapi/Makefile
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/Makefile	                        (rev 0)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/Makefile	2007-06-26 18:20:05 UTC (rev 11079)
@@ -0,0 +1,37 @@
+#
+# $Id: Makefile 1823 2004-01-05 00:06:11Z larstiq $
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License.  See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+# Bounces make to subdirectories.
+
+SOURCEDIR = source/blender/blenpluginapi
+DIRS = intern
+
+include nan_subdirs.mk

Added: branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_api.h
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_api.h	                        (rev 0)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_api.h	2007-06-26 18:20:05 UTC (rev 11079)
@@ -0,0 +1,349 @@
+#ifndef plugin_api_h
+#define plugin_api_h
+
+#include "externdef.h"
+#include "PLU_types.h"
+
+/* 
+   interface for the plugin side:
+
+*/
+
+/* Helper functions for the plugin (accessible from plugin side)
+   These are the functions gui_draw is allowed to call!
+   (well, right now it is only one function, so that we can
+    make old plugins work, but why not add some more? ;-)
+ */
+
+LIBEXPORT void plugin_gui_draw_slider(plugin_control_t * control,
+				      int type, const char* name,
+				      float def, float min, float max,
+				      const char* tip, 
+				      float * data, int xpos, int ypos);
+
+LIBEXPORT void plugin_gui_bind_ipo(plugin_control_t * control, 
+				   const char * icuname,
+				   float * data);
+LIBEXPORT void plugin_gui_icu_set_range(plugin_control_t * control, 
+					const char * icuname,
+					float ymin, float ymax);
+
+LIBEXPORT float plugin_gui_get_ipo_value(plugin_control_t * control, 
+					 const char * icuname,
+					 float frame);
+
+/* functions to bind instance data to properties 
+   these instance elements will be exposed to the core and are stored
+   persistently in blend file.
+
+   plugin_bind_properties_varstruct is a convenience function
+   for usage with varstructs
+
+   plugin_get / set_property: use this to get / set properties without 
+   binding.
+
+*/
+
+typedef struct VarStruct {
+	int type;
+	char name[16];
+	float def, min, max;
+	char tip[80];
+} VarStruct;
+
+typedef enum {
+	PLP_END = -1,
+	PLP_STRING,
+	PLP_INT,
+	PLP_FLOAT
+} plp_type_t;
+
+LIBEXPORT int plugin_bind_property(
+	plugin_control_t * control,
+	plp_type_t prop_type, const char * name, void * data);
+
+LIBEXPORT int plugin_bind_properties(
+	plugin_control_t * control,
+	plp_type_t prop_type, const char * name, void * data, ...);
+
+LIBEXPORT int plugin_bind_properties_varstruct(
+	plugin_control_t * control,
+	VarStruct * vstruct,
+	unsigned int num_elems, 
+	void * begin_of_data);
+
+/* returns false if property not available or type doesn't match! */
+LIBEXPORT int plugin_get_property(plugin_control_t * control,
+				  plp_type_t prop_type, const char * name, 
+				  void * data);
+LIBEXPORT int plugin_set_property(plugin_control_t * control,
+				  plp_type_t prop_type, const char * name, 
+				  void * data);
+
+/* sequencer inputs are able to seek on input, so here we go: 
+   (will return null, if no such imbuf exists) 
+
+   IMPORTANT! If you want to return an ImBuf fetched with get_imbuf
+   without change, you have to call refImBuf() to increment it's reference
+   count!
+*/
+
+LIBEXPORT struct ImBuf * plugin_sequencer_get_imbuf(
+	plugin_control_t * control, int num_input, float frame);
+
+LIBEXPORT void plugin_sequencer_get_audio(
+	plugin_control_t * control, int num_input, 
+	float * output, int num_samples);
+
+LIBEXPORT void plugin_audio_to_char(float * in, char * out, int num_samples);
+LIBEXPORT void plugin_audio_to_short(float * in, short * out, int num_samples);
+LIBEXPORT void plugin_audio_to_int(float * in, int * out, int num_samples);
+LIBEXPORT void plugin_audio_to_24bit(float * in, void * out, int num_samples);
+
+/* convenience function to create a new output imbuf from properties */
+LIBEXPORT struct ImBuf * plugin_new_imbuf(plugin_control_t * control);
+
+
+
+/* 
+   interface for the blender core:
+
+   plugin_enumerate: get all descriptors for a certain type by doing
+           a refresh of the plugin paths if not done. On first run, we scan
+	   all available plugins for there interface and store this in
+	   a cache file. (In case you wonder, install gimp and 
+           watch startup...)
+
+   plugin_get_by_name: find descriptor by name and type.
+
+   plugin_init_control: load plugin into memory if not done 
+           and setup control structures for first use thereby creating 
+           a plugin_control structure.
+
+   plugin_load_control: load plugin into memory if not done,
+           but reuses plugin_control
+           structure, that is already present from file restore. 
+	   Does it only on first call, so call as often you like.
+	   Check return value! 1 = OK, 0 = load failed! (plugin not available)
+      
+*/
+
+LIBEXPORT plugin_descriptor_t * plugin_enumerate(
+	plugin_type_t type, int force_refresh);
+LIBEXPORT plugin_descriptor_t * plugin_get_by_name(
+	plugin_type_t type, const char* name);
+
+LIBEXPORT plugin_control_t * plugin_init_control(
+	plugin_descriptor_t * d, 
+	plugin_uplink_handler_t * uplink_handler,
+	void * uplink, 
+	int prop_type, const char * name, void * data, ...);
+
+LIBEXPORT int plugin_load_control(plugin_control_t * c, 
+				  plugin_uplink_handler_t * uplink_handler,
+				  void * uplink);
+LIBEXPORT void plugin_free_control(plugin_control_t * c);
+
+/*
+  File open using this interface might look like this:
+
+  --------------
+  plugin_control_t * open_video_file(const char * filename) {
+        plugin_control_t * rv;
+
+	plugin_descriptor_t * p = plugin_enumerate(PLUGIN_TYPE_VIDEO_INPUT);
+  
+	while (p) {
+	     if (file_matches_pattern(filename, p->file_pattern)) {
+	           rv = plugin_init_control(p, NULL, NULL,
+	                                    PLP_STRING, "filename", filename,
+					    PLP_END);
+		   if (rv) {
+	                return rv;
+		   }
+             }
+
+             p = p->next;
+        }
+
+        return 0;
+  }
+
+  --------------
+  video plugin looks like this:
+  --------------
+
+  #include "plugin.h"
+
+  struct plugin_instance {
+        int xoffset;
+	int yoffset;
+
+	int crop_width;
+	int crop_height;
+	
+	jpeghandle_t handle;
+  };
+  
+  plugin_instance_t* my_init(plugin_control_t * c) {
+        plugin_instance_t * rv = 0;
+	char* filename;
+	jpeg_handle_t handle = 0;
+
+	if (!plugin_get_property(c, PLP_STRING, "filename", &filename)) {
+	      plugin_set_property(c, PLP_STRING, "error", "core went nuts");
+     	      return 0;
+	}
+
+	... try jpeg open, that returns handle ...
+
+	if (!handle) {
+	      plugin_set_property(c, PLP_STRING, "error", failure_notice);
+	      return 0;
+	}
+
+	rv = mallocN(sizeof(struct plugin_instance), "jpeg-instance");
+
+	plugin_bind_properties(c, 
+	                       PLP_INT, "xoffset", &rv->xoffset,
+			       PLP_INT, "yoffset", &rv->yoffset,
+			       PLP_INT, "width", &rv->crop_width,
+			       PLP_INT, "height", &rv->crop_height,
+			       PLP_END);
+	
+	rv->handle = handle;
+
+	return rv;
+  }
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list