diff options
Diffstat (limited to 'drawing/Frameworks/Syphon.framework')
24 files changed, 1986 insertions, 0 deletions
diff --git a/drawing/Frameworks/Syphon.framework/Headers/Syphon.h b/drawing/Frameworks/Syphon.framework/Headers/Syphon.h new file mode 100644 index 0000000..126cf54 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Headers/Syphon.h @@ -0,0 +1,184 @@ +/* + Syphon.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SyphonServerDirectory.h" +#import "SyphonServer.h" +#import "SyphonClient.h" +#import "SyphonImage.h" + +/*! \mainpage Syphon Framework + @section intro_sec Developing with Syphon + + <ul> + <li> <a href="#introduction" title="Developing with Syphon">Developing with Syphon</a> + </li> + <li><a href="#servers" title="Servers">Servers</a> + </li> + <li><a href="#finding-servers" title="Finding Servers">Finding Servers</a> + </li> + <li><a href="#clients" title="Clients">Clients</a> + </li> + <li><a href="#plugins" title="Syphon.framework in a Plugin">Syphon.framework in a Plugin</a> + </li> + <li><a href="#help" title="More examples and help">More examples and help</a> + </li> + <li><a href="#framework_dev" title="Framework development">Framework development</a> + </li> + </ul> + + @section introduction Developing with Syphon + + The Syphon framework provides the classes necessary to add Syphon support to your application. SyphonServer is used to make frames available to other applications. SyphonServerDirectory is used to discover available servers. SyphonClient is used to connect to and receive frames from a SyphonServer. + + The framework <em>requires</em> MacOS X 10.6 or later. Syphon makes use of IOSurface, which is a 10.6-only technology. Syphon takes advantage of other 10.6 features such as blocks, and is compatible with garbage-collection. + + To include Syphon in your application, follow these steps: + + <ol> + <li><h4>Add the framework to your Xcode project.</h4> + <p>The simplest way is to drag it to the Linked Frameworks group in the project window.</p></li> + <li><h4>Link your application with Syphon at build time.</h4> + <p>Add the framework to the Link Binary With Libraries build stage of your application's target.</p></li> + <li><h4>Copy the framework into your application's bundle.</h4> + <p>Add a new Copy Files build phase to your application's target.<br/> + Get Info on the build phase and select Frameworks as the destination.<br/> + Drag the Syphon framework into the build phase.</p></li> + <li><h4>Import the headers.</h4> + <p>#import <Syphon/Syphon.h> in any file where you want to use Syphon classes.</p></li> + </ol> + + @section servers Servers + + Class documentation: SyphonServer + + Create a server: + + @code + SyphonServer *myServer = [[SyphonServer alloc] initWithName:@"My Output" context:myContext options:nil]; + @endcode + + and then publish new frames (you can also use GL_TEXTURE_2D textures): + + @code + [myServer publishFrameTexture:myTex textureTarget:GL_TEXTURE_RECTANGLE_EXT imageRegion:NSMakeRect(0, 0, width, height) textureDimensions:NSMakeSize(width, height) flipped:NO]; + @endcode + + Alternatively there are methods to bind and unbind the server to the OpenGL context, so you can draw into it directly. + You can publish new frames as often as you like, but if you only publish when you have a frame different from the previous one, then clients can do less work. + You must stop the server when you are finished with it: + + @code + [myServer stop]; + @endcode + + @section finding-servers Finding Servers + + Class documentation: SyphonServerDirectory + + SyphonServerDirectory handles server discovery for you. You can get an array of dictionaries describing available servers: + + @code + NSArray *available = [[SyphonServerDirectory sharedDirectory] servers]; + @endcode + + The servers property can be observed for changes, or you can register to receive the notifications posted by SyphonServerDirectory. + + Server description dictionaries are used by Syphon when you create a client, and also contain information you can use to describe available servers in your UI: + + @code + [myMenuItem setTitle:[description objectForKey:SyphonServerDescriptionNameKey]]; + @endcode + + @section clients Clients + + Class documentation: SyphonClient, SyphonImage + + Usually you create a client with a server description dictionary you obtained from SyphonServerDirectory: + + @code + SyphonClient *myClient = [[SyphonClient alloc] initWithServerDescription:description options:nil newFrameHandler:^(SyphonClient *client) { + [myView setNeedsDisplay:YES]; + }]; + @endcode + + The new-frame handler is optional: you can pass in nil. Here we use it to tell a view it needs to draw whenever the client receives a frame. + + When you are ready to draw: + + @code + SyphonImage *myFrame = [myClient newFrameImageForContext:cgl_ctx]; + if (myFrame) + { + GLuint tex = myFrame.textureName; + NSSize dimensions = myFrame.textureSize; + + // YOUR OPENGL DRAWING CODE HERE + + [myFrame release]; + } + @endcode + + As with servers, you must stop the client when you are finished with it: + + @code + [myClient stop]; + @endcode + + @section plugins Syphon.framework in a Plugin + + If you are using Syphon in any sort of plugin, please download the framework source and compile a version of the framework with unique class names. This avoids class-name conflicts if another plugin or the host application also embeds the Syphon framework. The framework source is set up to make this easy for you: you just need to change one build setting. + + <ol> + <li><h4>Open the framework's Xcode project.</h4> + <p></p> + </li> + <li><h4>Define SYPHON_UNIQUE_CLASS_NAME_PREFIX using the Preprocessor Macros build setting.</h4> + <p>Select the Syphon target in the project window.<br/> + Get Info on the target, and click the Build tab to display the build settings.<br/> + Scroll down (or use the search field) to find the Preprocessor Macros (GCC_PREPROCESSOR_DEFINITIONS) setting.<br/> + Double click the setting to add SYPHON_UNIQUE_CLASS_NAME_PREFIX=MyPluginName as a macro. + </p></li> + <li><h4>Build the framework.</h4> + <p>The built framework will have custom class names. The headers alias the custom names, so you can use SyphonServer, SyphonClient, SyphonImage and SyphonServerDirectory as normal in your code.<br/> + </p></li> + </ol> + + @section help More examples and help + + Example projects implementing a server and client are included with the Syphon SDK. You can also examine the source to the provided Syphon implementations at their <a href="http://code.google.com/p/syphon-implementations/" target="_blank">Google Code project</a>. + + Use the <a href="http://forums.v002.info/forum.php?id=7" target="_blank">Syphon developer forum</a> to ask questions, and for any development related discussion. + + Good luck! + + @section framework_dev Framework development + + If you'd like to examine the framework's source code, report a bug, or get involved in development, head on over to the <a href="http://code.google.com/p/syphon-framework/" target="_blank">Syphon framework Google Code project.</a> + + */
\ No newline at end of file diff --git a/drawing/Frameworks/Syphon.framework/Headers/SyphonClient.h b/drawing/Frameworks/Syphon.framework/Headers/SyphonClient.h new file mode 100644 index 0000000..618a328 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Headers/SyphonClient.h @@ -0,0 +1,96 @@ +/* + SyphonClient.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +@class SyphonImage; + +/*! + SyphonClient makes available frames from a remote SyphonServer. A client is created from a NSDictionary which describes the server. Typically this is obtained from the shared SyphonServerDirectory, or one of Syphon's notifications. + + SyphonClient allows for lazy drawing by the use of a new-frame-handler. Using a handler you can perform drawing without using a timer or polling, achieving frame-accuracy with the minimum of overhead. Alternatively, if your application uses a traditional display link or timer, you can use the hasNewFrame property to make decisions about work you may need to do. Irrespective of the presence of new frames, you can draw with a SyphonClient at any time. + + It is safe to access instances of this class across threads. + */ + +@interface SyphonClient : NSObject +{ +@private + id _connectionManager; + uint32_t _lastFrameID; + void (^_handler)(id); + int32_t _status; + int32_t _lock; +} +/*! + Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server. + @param description Typically acquired from the shared SyphonServerDirectory, or one of Syphon's notifications. + @param options Currently ignored. May be nil. + @param handler A block which is invoked when a new frame becomes available. handler may be nil. This block may be invoked on a thread other than that on which the client was created. + @returns A newly initialized SyphonClient object, or nil if a client could not be created. +*/ + +- (id)initWithServerDescription:(NSDictionary *)description options:(NSDictionary *)options newFrameHandler:(void (^)(SyphonClient *client))handler; + +/*! + A client is valid if it has a working connection to a server. Once this returns NO, the SyphonClient will not yield any further frames. + */ + +@property (readonly) BOOL isValid; + +/*! + Returns a dictionary with a description of the server the client is attached to. See SyphonServerDirectory for the keys this dictionary contains +*/ + +@property (readonly) NSDictionary *serverDescription; + +/*! + Returns YES if the server has output a new frame since the last time newFrameImageForContext: was called for this client, NO otherwise. +*/ + +@property (readonly) BOOL hasNewFrame; + +/*! + Returns a SyphonImage representing the current output from the server. The texture associated with the image may continue to update when you draw with it, but you should not depend on that behaviour: call this method every time you wish to access the current server frame. This object may have GPU resources associated with it and you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(). + @param cgl_ctx The CGL context in which the SyphonImage will be valid. + @returns A SyphonImage representing the live output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImageForContext:(CGLContextObj)cgl_ctx; + +/*! + Stops the client from receiving any further frames from the server. In garbage-collected applications you must call this method prior to removing strong references to the client. In non-garbage-collected applications, use of this method is optional and releasing all references to the client has the same effect. + */ + +- (void)stop; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Headers/SyphonImage.h b/drawing/Frameworks/Syphon.framework/Headers/SyphonImage.h new file mode 100644 index 0000000..d43277e --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Headers/SyphonImage.h @@ -0,0 +1,50 @@ +/* + SyphonImage.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <OpenGL/OpenGL.h> + +/** + SyphonImage represents an image stored as an OpenGL texture of type GL_TEXTURE_RECTANGLE_ARB. + */ + +@interface SyphonImage : NSObject { + +} + +/** + A GLuint representing the texture name. The associated texture is of type GL_TEXTURE_RECTANGLE_ARB. + */ +@property (readonly) GLuint textureName; + +/** + A NSSize representing the dimensions of the texture. The image will fill the texture entirely. + */ +@property (readonly) NSSize textureSize; +@end diff --git a/drawing/Frameworks/Syphon.framework/Headers/SyphonServer.h b/drawing/Frameworks/Syphon.framework/Headers/SyphonServer.h new file mode 100644 index 0000000..5cc9841 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Headers/SyphonServer.h @@ -0,0 +1,166 @@ +/* + SyphonServer.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +/*! @name Server Options Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServer + If this key is matched with a NSNumber with a BOOL value YES, then the server will be invisible to other Syphon users. You are then responsible for passing the NSDictionary returned by serverDescription to processes which require it to create a SyphonClient. Default is NO. + */ +extern NSString * const SyphonServerOptionIsPrivate; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServer handles the publishing of frames from one video source to any number of clients. Frames can be published either by passing in an existing OpenGL texture, or by binding the server's FBO, drawing using OpenGL calls, then calling the unbindAndPublish method. + + A SyphonServer object represents one video output for your application. If your application produces several video outputs, then they should each have their own SyphonServer. If your application might have multiple servers running, you should name each server to aid identification by users. + + It is safe to access instances of this class across threads, except for those calls related to OpenGL: a call to bindToDrawFrameOfSize: must have returned before a call is made to unbindAndPublish, and these methods must be paired and called in order. You should not call the stop method while the FBO is bound. + */ + +@class SyphonImage; + +@interface SyphonServer : NSObject +{ +@private + NSString *_name; + NSString *_uuid; + BOOL _broadcasts; + + id _connectionManager; + + CGLContextObj cgl_ctx; + + void *_surfaceRef; + BOOL _pushPending; + SyphonImage *_surfaceTexture; + GLuint _surfaceFBO; + + GLint _previousReadFBO; + GLint _previousDrawFBO; + GLint _previousFBO; + + int32_t _mdLock; +} +/** @name Instantiation */ +/** @{ */ +/*! + Creates a new server with the specified human-readable name (which need not be unique), CGLContext and options. The server will be started immediately. Init may fail and return nil if the server could not be started. + @param serverName Non-unique human readable server name. This is not required and may be nil, but is usually used by clients in their UI to aid identification. + @param context The CGLContextObj context that textures will be valid and available on for publishing. + @param options A dictionary containing key-value pairs to specify options for the server. Currently the only option is SyphonServerOptionIsPrivate. See its description for details. + @returns A newly intialized SyphonServer. Nil on failure. +*/ + +- (id)initWithName:(NSString*)serverName context:(CGLContextObj)context options:(NSDictionary *)options; + +/** @} */ + +/** @name Properties */ +/** @{ */ +/*! + The CGLContext the server uses for drawing. This may or may not be the context passed in at init. +*/ + +@property (readonly) CGLContextObj context; + +/*! + A string representing the name of the SyphonServer. +*/ + +@property (retain) NSString* name; + +/*! + A dictionary describing the server. Normally you won't need to access this, however if you created the server as private (using SyphonServerOptionIsPrivate) then you must pass this dictionary to any process in which you wish to create a SyphonClient. You should not rely on the presence of any particular keys in this dictionary. The content will always conform to the \<NSCoding\> protocol. +*/ + +@property (readonly) NSDictionary* serverDescription; + +/*! +YES if clients are currently attached, NO otherwise. If you generate frames frequently (for instance on a display-link timer), you may choose to test this and only call publishFrameTexture:textureTarget:imageRegion:textureDimensions:flipped: when clients are attached. +*/ + +@property (readonly) BOOL hasClients; + +/** @} */ +/** @name Publishing Frames */ +/** @{ */ + +/*! + Publishes the part of the texture described in region of the named texture to clients. The texture is copied and can be safely disposed of or modified once this method has returned. You should not bracket calls to this method with calls to -bindToDrawFrameOfSize: and -unbindAndPublish - they are provided as an alternative to using this method. + + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param texID The name of the texture to publish, which must be a texture valid in the CGL context provided when the server was created. + @param target GL_TEXTURE_RECTANGLE_EXT or GL_TEXTURE_2D. + @param region The sub-region of the texture to publish. + @param size The full size of the texture + @param isFlipped Is the texture flipped? +*/ + +- (void)publishFrameTexture:(GLuint)texID textureTarget:(GLenum)target imageRegion:(NSRect)region textureDimensions:(NSSize)size flipped:(BOOL)isFlipped; + +/*! + Binds an FBO for you to publish a frame of the given dimensions by drawing into the server's context (check it using the context property). If YES is returned, you must pair this with a call to -unbindAndPublish once you have finished drawing. If NO is returned you should abandon drawing and not call -unbindAndPublish. + This method does not lock the server's CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param size The size the frame you wish to publish. + @returns YES if binding succeeded, NO otherwise. +*/ + +- (BOOL)bindToDrawFrameOfSize:(NSSize)size; + +/*! + Restores any previously bound FBO and publishes the just-drawn frame. This method will flush the GL context (so you don't have to). + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. +*/ + +- (void)unbindAndPublish; + +/*! + Returns a SyphonImage representing the current output from the server, valid in the server's CGL context. Call this method every time you wish to access the current server frame. This object has a limited useful lifetime, and may have GPU resources associated with it: you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, or while you are drawing with the returned SyphonImage, bracket access with calls to CGLLockContext() and CGLUnlockContext(). + + @returns A SyphonImage representing the current output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImage; + +/*! + Stops the server instance. In garbage-collected applications you must call this method prior to removing strong references to the server. In non-garbage-collected applications, use of this method is optional. +*/ + +- (void)stop; +/** @} */ +@end diff --git a/drawing/Frameworks/Syphon.framework/Headers/SyphonServerDirectory.h b/drawing/Frameworks/Syphon.framework/Headers/SyphonServerDirectory.h new file mode 100644 index 0000000..3cad8ce --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Headers/SyphonServerDirectory.h @@ -0,0 +1,126 @@ +/* + SyphonServerDirectory.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +/*! @name Server Description Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which uniquely identifies a SyphonServer instance. If two dictionaries contain the same string for this key, they represent the same server. This is provided solely to allow you to programmatically determine the identity of a server, and should never be displayed to users in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionUUIDKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which is the human-readable non-unique name for the SyphonServer. If this string exists and is non-empty, you should use it in interface elements to identify the server, usually in combination with the name of the server's application (see SyphonServerDescriptionAppNameKey). +*/ + +extern NSString * const SyphonServerDescriptionNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString with the localized name of the application in which the SyphonServer is running. Use this in combination with the server's name (if present) to identify the server in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionAppNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSImage representation of the icon of the application in which the SyphonServer is running. +*/ + +extern NSString * const SyphonServerDescriptionIconKey; + +/*! @} */ + +/*! @name Notifications */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + A new SyphonServer is available on the system. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerAnnounceNotification; + +/*! + @relates SyphonServerDirectory + An existing SyphonServer instance has changed its description. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerUpdateNotification; + +/*! + @relates SyphonServerDirectory + A SyphonServer instance will no longer be available. The notification object is a NSDictionary describing the retiring server. +*/ + +extern NSString * const SyphonServerRetireNotification; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServerDirectory provides information on available Syphon Servers. Servers are represented by dictionaries. Generally you can expect to find some or all of the keys listed in Constants. +*/ + +@interface SyphonServerDirectory : NSObject { +@private + NSMutableArray *_servers; + pthread_mutex_t _generalLock; + pthread_mutex_t _mutateLock; + NSMutableSet *_pings; +} + +/*! + Returns the shared server directory instance. This object is KVO complaint, and can be used to observe changes in server availability, server names and statuses. + @returns the shared server instance +*/ + ++ (SyphonServerDirectory *)sharedDirectory; + +/*! + NSArray of NSDictionaries that describe (using the keys above) currently available SyphonServer instances on the system. +*/ + +@property (readonly) NSArray *servers; + +/*! + Use this method to discover servers based soley on their name, or application host name. Both parameters are optional. If you do not specify either, all available SyphonServers will be returned. + @param name Optional (pass nil to not specify) Name of the published SyphonServer, matches the key value for SyphonServerDescriptionNameKey + @param appname Optional (pass nil to not specify) Application Name of the published SyphonServer, matches the key value for SyphonServerDescriptionAppNameKey + @returns An array of NSDictionaries matching the query you specified. +*/ + +- (NSArray *)serversMatchingName:(NSString *)name appName:(NSString *)appname; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Resources/English.lproj/InfoPlist.strings b/drawing/Frameworks/Syphon.framework/Resources/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 0000000..5e45963 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Resources/English.lproj/InfoPlist.strings diff --git a/drawing/Frameworks/Syphon.framework/Resources/Info.plist b/drawing/Frameworks/Syphon.framework/Resources/Info.plist new file mode 100644 index 0000000..fb6cbc3 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Resources/Info.plist @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildMachineOSBuild</key> + <string>10J869</string> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>Syphon</string> + <key>CFBundleIdentifier</key> + <string>info.v002.Syphon</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Syphon</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>DTCompiler</key> + <string>com.apple.compilers.llvm.clang.1_0</string> + <key>DTPlatformBuild</key> + <string>4A2002a</string> + <key>DTPlatformVersion</key> + <string>GM</string> + <key>DTSDKBuild</key> + <string>4A2002a</string> + <key>DTSDKName</key> + <string>macosx10.6</string> + <key>DTXcode</key> + <string>0402</string> + <key>DTXcodeBuild</key> + <string>4A2002a</string> +</dict> +</plist> diff --git a/drawing/Frameworks/Syphon.framework/Syphon b/drawing/Frameworks/Syphon.framework/Syphon Binary files differnew file mode 100755 index 0000000..741b4e4 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Syphon diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Headers/Syphon.h b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/Syphon.h new file mode 100644 index 0000000..126cf54 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/Syphon.h @@ -0,0 +1,184 @@ +/* + Syphon.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SyphonServerDirectory.h" +#import "SyphonServer.h" +#import "SyphonClient.h" +#import "SyphonImage.h" + +/*! \mainpage Syphon Framework + @section intro_sec Developing with Syphon + + <ul> + <li> <a href="#introduction" title="Developing with Syphon">Developing with Syphon</a> + </li> + <li><a href="#servers" title="Servers">Servers</a> + </li> + <li><a href="#finding-servers" title="Finding Servers">Finding Servers</a> + </li> + <li><a href="#clients" title="Clients">Clients</a> + </li> + <li><a href="#plugins" title="Syphon.framework in a Plugin">Syphon.framework in a Plugin</a> + </li> + <li><a href="#help" title="More examples and help">More examples and help</a> + </li> + <li><a href="#framework_dev" title="Framework development">Framework development</a> + </li> + </ul> + + @section introduction Developing with Syphon + + The Syphon framework provides the classes necessary to add Syphon support to your application. SyphonServer is used to make frames available to other applications. SyphonServerDirectory is used to discover available servers. SyphonClient is used to connect to and receive frames from a SyphonServer. + + The framework <em>requires</em> MacOS X 10.6 or later. Syphon makes use of IOSurface, which is a 10.6-only technology. Syphon takes advantage of other 10.6 features such as blocks, and is compatible with garbage-collection. + + To include Syphon in your application, follow these steps: + + <ol> + <li><h4>Add the framework to your Xcode project.</h4> + <p>The simplest way is to drag it to the Linked Frameworks group in the project window.</p></li> + <li><h4>Link your application with Syphon at build time.</h4> + <p>Add the framework to the Link Binary With Libraries build stage of your application's target.</p></li> + <li><h4>Copy the framework into your application's bundle.</h4> + <p>Add a new Copy Files build phase to your application's target.<br/> + Get Info on the build phase and select Frameworks as the destination.<br/> + Drag the Syphon framework into the build phase.</p></li> + <li><h4>Import the headers.</h4> + <p>#import <Syphon/Syphon.h> in any file where you want to use Syphon classes.</p></li> + </ol> + + @section servers Servers + + Class documentation: SyphonServer + + Create a server: + + @code + SyphonServer *myServer = [[SyphonServer alloc] initWithName:@"My Output" context:myContext options:nil]; + @endcode + + and then publish new frames (you can also use GL_TEXTURE_2D textures): + + @code + [myServer publishFrameTexture:myTex textureTarget:GL_TEXTURE_RECTANGLE_EXT imageRegion:NSMakeRect(0, 0, width, height) textureDimensions:NSMakeSize(width, height) flipped:NO]; + @endcode + + Alternatively there are methods to bind and unbind the server to the OpenGL context, so you can draw into it directly. + You can publish new frames as often as you like, but if you only publish when you have a frame different from the previous one, then clients can do less work. + You must stop the server when you are finished with it: + + @code + [myServer stop]; + @endcode + + @section finding-servers Finding Servers + + Class documentation: SyphonServerDirectory + + SyphonServerDirectory handles server discovery for you. You can get an array of dictionaries describing available servers: + + @code + NSArray *available = [[SyphonServerDirectory sharedDirectory] servers]; + @endcode + + The servers property can be observed for changes, or you can register to receive the notifications posted by SyphonServerDirectory. + + Server description dictionaries are used by Syphon when you create a client, and also contain information you can use to describe available servers in your UI: + + @code + [myMenuItem setTitle:[description objectForKey:SyphonServerDescriptionNameKey]]; + @endcode + + @section clients Clients + + Class documentation: SyphonClient, SyphonImage + + Usually you create a client with a server description dictionary you obtained from SyphonServerDirectory: + + @code + SyphonClient *myClient = [[SyphonClient alloc] initWithServerDescription:description options:nil newFrameHandler:^(SyphonClient *client) { + [myView setNeedsDisplay:YES]; + }]; + @endcode + + The new-frame handler is optional: you can pass in nil. Here we use it to tell a view it needs to draw whenever the client receives a frame. + + When you are ready to draw: + + @code + SyphonImage *myFrame = [myClient newFrameImageForContext:cgl_ctx]; + if (myFrame) + { + GLuint tex = myFrame.textureName; + NSSize dimensions = myFrame.textureSize; + + // YOUR OPENGL DRAWING CODE HERE + + [myFrame release]; + } + @endcode + + As with servers, you must stop the client when you are finished with it: + + @code + [myClient stop]; + @endcode + + @section plugins Syphon.framework in a Plugin + + If you are using Syphon in any sort of plugin, please download the framework source and compile a version of the framework with unique class names. This avoids class-name conflicts if another plugin or the host application also embeds the Syphon framework. The framework source is set up to make this easy for you: you just need to change one build setting. + + <ol> + <li><h4>Open the framework's Xcode project.</h4> + <p></p> + </li> + <li><h4>Define SYPHON_UNIQUE_CLASS_NAME_PREFIX using the Preprocessor Macros build setting.</h4> + <p>Select the Syphon target in the project window.<br/> + Get Info on the target, and click the Build tab to display the build settings.<br/> + Scroll down (or use the search field) to find the Preprocessor Macros (GCC_PREPROCESSOR_DEFINITIONS) setting.<br/> + Double click the setting to add SYPHON_UNIQUE_CLASS_NAME_PREFIX=MyPluginName as a macro. + </p></li> + <li><h4>Build the framework.</h4> + <p>The built framework will have custom class names. The headers alias the custom names, so you can use SyphonServer, SyphonClient, SyphonImage and SyphonServerDirectory as normal in your code.<br/> + </p></li> + </ol> + + @section help More examples and help + + Example projects implementing a server and client are included with the Syphon SDK. You can also examine the source to the provided Syphon implementations at their <a href="http://code.google.com/p/syphon-implementations/" target="_blank">Google Code project</a>. + + Use the <a href="http://forums.v002.info/forum.php?id=7" target="_blank">Syphon developer forum</a> to ask questions, and for any development related discussion. + + Good luck! + + @section framework_dev Framework development + + If you'd like to examine the framework's source code, report a bug, or get involved in development, head on over to the <a href="http://code.google.com/p/syphon-framework/" target="_blank">Syphon framework Google Code project.</a> + + */
\ No newline at end of file diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonClient.h b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonClient.h new file mode 100644 index 0000000..618a328 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonClient.h @@ -0,0 +1,96 @@ +/* + SyphonClient.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +@class SyphonImage; + +/*! + SyphonClient makes available frames from a remote SyphonServer. A client is created from a NSDictionary which describes the server. Typically this is obtained from the shared SyphonServerDirectory, or one of Syphon's notifications. + + SyphonClient allows for lazy drawing by the use of a new-frame-handler. Using a handler you can perform drawing without using a timer or polling, achieving frame-accuracy with the minimum of overhead. Alternatively, if your application uses a traditional display link or timer, you can use the hasNewFrame property to make decisions about work you may need to do. Irrespective of the presence of new frames, you can draw with a SyphonClient at any time. + + It is safe to access instances of this class across threads. + */ + +@interface SyphonClient : NSObject +{ +@private + id _connectionManager; + uint32_t _lastFrameID; + void (^_handler)(id); + int32_t _status; + int32_t _lock; +} +/*! + Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server. + @param description Typically acquired from the shared SyphonServerDirectory, or one of Syphon's notifications. + @param options Currently ignored. May be nil. + @param handler A block which is invoked when a new frame becomes available. handler may be nil. This block may be invoked on a thread other than that on which the client was created. + @returns A newly initialized SyphonClient object, or nil if a client could not be created. +*/ + +- (id)initWithServerDescription:(NSDictionary *)description options:(NSDictionary *)options newFrameHandler:(void (^)(SyphonClient *client))handler; + +/*! + A client is valid if it has a working connection to a server. Once this returns NO, the SyphonClient will not yield any further frames. + */ + +@property (readonly) BOOL isValid; + +/*! + Returns a dictionary with a description of the server the client is attached to. See SyphonServerDirectory for the keys this dictionary contains +*/ + +@property (readonly) NSDictionary *serverDescription; + +/*! + Returns YES if the server has output a new frame since the last time newFrameImageForContext: was called for this client, NO otherwise. +*/ + +@property (readonly) BOOL hasNewFrame; + +/*! + Returns a SyphonImage representing the current output from the server. The texture associated with the image may continue to update when you draw with it, but you should not depend on that behaviour: call this method every time you wish to access the current server frame. This object may have GPU resources associated with it and you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(). + @param cgl_ctx The CGL context in which the SyphonImage will be valid. + @returns A SyphonImage representing the live output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImageForContext:(CGLContextObj)cgl_ctx; + +/*! + Stops the client from receiving any further frames from the server. In garbage-collected applications you must call this method prior to removing strong references to the client. In non-garbage-collected applications, use of this method is optional and releasing all references to the client has the same effect. + */ + +- (void)stop; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonImage.h b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonImage.h new file mode 100644 index 0000000..d43277e --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonImage.h @@ -0,0 +1,50 @@ +/* + SyphonImage.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <OpenGL/OpenGL.h> + +/** + SyphonImage represents an image stored as an OpenGL texture of type GL_TEXTURE_RECTANGLE_ARB. + */ + +@interface SyphonImage : NSObject { + +} + +/** + A GLuint representing the texture name. The associated texture is of type GL_TEXTURE_RECTANGLE_ARB. + */ +@property (readonly) GLuint textureName; + +/** + A NSSize representing the dimensions of the texture. The image will fill the texture entirely. + */ +@property (readonly) NSSize textureSize; +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServer.h b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServer.h new file mode 100644 index 0000000..5cc9841 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServer.h @@ -0,0 +1,166 @@ +/* + SyphonServer.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +/*! @name Server Options Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServer + If this key is matched with a NSNumber with a BOOL value YES, then the server will be invisible to other Syphon users. You are then responsible for passing the NSDictionary returned by serverDescription to processes which require it to create a SyphonClient. Default is NO. + */ +extern NSString * const SyphonServerOptionIsPrivate; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServer handles the publishing of frames from one video source to any number of clients. Frames can be published either by passing in an existing OpenGL texture, or by binding the server's FBO, drawing using OpenGL calls, then calling the unbindAndPublish method. + + A SyphonServer object represents one video output for your application. If your application produces several video outputs, then they should each have their own SyphonServer. If your application might have multiple servers running, you should name each server to aid identification by users. + + It is safe to access instances of this class across threads, except for those calls related to OpenGL: a call to bindToDrawFrameOfSize: must have returned before a call is made to unbindAndPublish, and these methods must be paired and called in order. You should not call the stop method while the FBO is bound. + */ + +@class SyphonImage; + +@interface SyphonServer : NSObject +{ +@private + NSString *_name; + NSString *_uuid; + BOOL _broadcasts; + + id _connectionManager; + + CGLContextObj cgl_ctx; + + void *_surfaceRef; + BOOL _pushPending; + SyphonImage *_surfaceTexture; + GLuint _surfaceFBO; + + GLint _previousReadFBO; + GLint _previousDrawFBO; + GLint _previousFBO; + + int32_t _mdLock; +} +/** @name Instantiation */ +/** @{ */ +/*! + Creates a new server with the specified human-readable name (which need not be unique), CGLContext and options. The server will be started immediately. Init may fail and return nil if the server could not be started. + @param serverName Non-unique human readable server name. This is not required and may be nil, but is usually used by clients in their UI to aid identification. + @param context The CGLContextObj context that textures will be valid and available on for publishing. + @param options A dictionary containing key-value pairs to specify options for the server. Currently the only option is SyphonServerOptionIsPrivate. See its description for details. + @returns A newly intialized SyphonServer. Nil on failure. +*/ + +- (id)initWithName:(NSString*)serverName context:(CGLContextObj)context options:(NSDictionary *)options; + +/** @} */ + +/** @name Properties */ +/** @{ */ +/*! + The CGLContext the server uses for drawing. This may or may not be the context passed in at init. +*/ + +@property (readonly) CGLContextObj context; + +/*! + A string representing the name of the SyphonServer. +*/ + +@property (retain) NSString* name; + +/*! + A dictionary describing the server. Normally you won't need to access this, however if you created the server as private (using SyphonServerOptionIsPrivate) then you must pass this dictionary to any process in which you wish to create a SyphonClient. You should not rely on the presence of any particular keys in this dictionary. The content will always conform to the \<NSCoding\> protocol. +*/ + +@property (readonly) NSDictionary* serverDescription; + +/*! +YES if clients are currently attached, NO otherwise. If you generate frames frequently (for instance on a display-link timer), you may choose to test this and only call publishFrameTexture:textureTarget:imageRegion:textureDimensions:flipped: when clients are attached. +*/ + +@property (readonly) BOOL hasClients; + +/** @} */ +/** @name Publishing Frames */ +/** @{ */ + +/*! + Publishes the part of the texture described in region of the named texture to clients. The texture is copied and can be safely disposed of or modified once this method has returned. You should not bracket calls to this method with calls to -bindToDrawFrameOfSize: and -unbindAndPublish - they are provided as an alternative to using this method. + + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param texID The name of the texture to publish, which must be a texture valid in the CGL context provided when the server was created. + @param target GL_TEXTURE_RECTANGLE_EXT or GL_TEXTURE_2D. + @param region The sub-region of the texture to publish. + @param size The full size of the texture + @param isFlipped Is the texture flipped? +*/ + +- (void)publishFrameTexture:(GLuint)texID textureTarget:(GLenum)target imageRegion:(NSRect)region textureDimensions:(NSSize)size flipped:(BOOL)isFlipped; + +/*! + Binds an FBO for you to publish a frame of the given dimensions by drawing into the server's context (check it using the context property). If YES is returned, you must pair this with a call to -unbindAndPublish once you have finished drawing. If NO is returned you should abandon drawing and not call -unbindAndPublish. + This method does not lock the server's CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param size The size the frame you wish to publish. + @returns YES if binding succeeded, NO otherwise. +*/ + +- (BOOL)bindToDrawFrameOfSize:(NSSize)size; + +/*! + Restores any previously bound FBO and publishes the just-drawn frame. This method will flush the GL context (so you don't have to). + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. +*/ + +- (void)unbindAndPublish; + +/*! + Returns a SyphonImage representing the current output from the server, valid in the server's CGL context. Call this method every time you wish to access the current server frame. This object has a limited useful lifetime, and may have GPU resources associated with it: you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, or while you are drawing with the returned SyphonImage, bracket access with calls to CGLLockContext() and CGLUnlockContext(). + + @returns A SyphonImage representing the current output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImage; + +/*! + Stops the server instance. In garbage-collected applications you must call this method prior to removing strong references to the server. In non-garbage-collected applications, use of this method is optional. +*/ + +- (void)stop; +/** @} */ +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServerDirectory.h b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServerDirectory.h new file mode 100644 index 0000000..3cad8ce --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Headers/SyphonServerDirectory.h @@ -0,0 +1,126 @@ +/* + SyphonServerDirectory.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +/*! @name Server Description Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which uniquely identifies a SyphonServer instance. If two dictionaries contain the same string for this key, they represent the same server. This is provided solely to allow you to programmatically determine the identity of a server, and should never be displayed to users in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionUUIDKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which is the human-readable non-unique name for the SyphonServer. If this string exists and is non-empty, you should use it in interface elements to identify the server, usually in combination with the name of the server's application (see SyphonServerDescriptionAppNameKey). +*/ + +extern NSString * const SyphonServerDescriptionNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString with the localized name of the application in which the SyphonServer is running. Use this in combination with the server's name (if present) to identify the server in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionAppNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSImage representation of the icon of the application in which the SyphonServer is running. +*/ + +extern NSString * const SyphonServerDescriptionIconKey; + +/*! @} */ + +/*! @name Notifications */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + A new SyphonServer is available on the system. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerAnnounceNotification; + +/*! + @relates SyphonServerDirectory + An existing SyphonServer instance has changed its description. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerUpdateNotification; + +/*! + @relates SyphonServerDirectory + A SyphonServer instance will no longer be available. The notification object is a NSDictionary describing the retiring server. +*/ + +extern NSString * const SyphonServerRetireNotification; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServerDirectory provides information on available Syphon Servers. Servers are represented by dictionaries. Generally you can expect to find some or all of the keys listed in Constants. +*/ + +@interface SyphonServerDirectory : NSObject { +@private + NSMutableArray *_servers; + pthread_mutex_t _generalLock; + pthread_mutex_t _mutateLock; + NSMutableSet *_pings; +} + +/*! + Returns the shared server directory instance. This object is KVO complaint, and can be used to observe changes in server availability, server names and statuses. + @returns the shared server instance +*/ + ++ (SyphonServerDirectory *)sharedDirectory; + +/*! + NSArray of NSDictionaries that describe (using the keys above) currently available SyphonServer instances on the system. +*/ + +@property (readonly) NSArray *servers; + +/*! + Use this method to discover servers based soley on their name, or application host name. Both parameters are optional. If you do not specify either, all available SyphonServers will be returned. + @param name Optional (pass nil to not specify) Name of the published SyphonServer, matches the key value for SyphonServerDescriptionNameKey + @param appname Optional (pass nil to not specify) Application Name of the published SyphonServer, matches the key value for SyphonServerDescriptionAppNameKey + @returns An array of NSDictionaries matching the query you specified. +*/ + +- (NSArray *)serversMatchingName:(NSString *)name appName:(NSString *)appname; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Resources/English.lproj/InfoPlist.strings b/drawing/Frameworks/Syphon.framework/Versions/A/Resources/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 0000000..5e45963 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Resources/English.lproj/InfoPlist.strings diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Resources/Info.plist b/drawing/Frameworks/Syphon.framework/Versions/A/Resources/Info.plist new file mode 100644 index 0000000..fb6cbc3 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildMachineOSBuild</key> + <string>10J869</string> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>Syphon</string> + <key>CFBundleIdentifier</key> + <string>info.v002.Syphon</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Syphon</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>DTCompiler</key> + <string>com.apple.compilers.llvm.clang.1_0</string> + <key>DTPlatformBuild</key> + <string>4A2002a</string> + <key>DTPlatformVersion</key> + <string>GM</string> + <key>DTSDKBuild</key> + <string>4A2002a</string> + <key>DTSDKName</key> + <string>macosx10.6</string> + <key>DTXcode</key> + <string>0402</string> + <key>DTXcodeBuild</key> + <string>4A2002a</string> +</dict> +</plist> diff --git a/drawing/Frameworks/Syphon.framework/Versions/A/Syphon b/drawing/Frameworks/Syphon.framework/Versions/A/Syphon Binary files differnew file mode 100755 index 0000000..741b4e4 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/A/Syphon diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/Syphon.h b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/Syphon.h new file mode 100644 index 0000000..126cf54 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/Syphon.h @@ -0,0 +1,184 @@ +/* + Syphon.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SyphonServerDirectory.h" +#import "SyphonServer.h" +#import "SyphonClient.h" +#import "SyphonImage.h" + +/*! \mainpage Syphon Framework + @section intro_sec Developing with Syphon + + <ul> + <li> <a href="#introduction" title="Developing with Syphon">Developing with Syphon</a> + </li> + <li><a href="#servers" title="Servers">Servers</a> + </li> + <li><a href="#finding-servers" title="Finding Servers">Finding Servers</a> + </li> + <li><a href="#clients" title="Clients">Clients</a> + </li> + <li><a href="#plugins" title="Syphon.framework in a Plugin">Syphon.framework in a Plugin</a> + </li> + <li><a href="#help" title="More examples and help">More examples and help</a> + </li> + <li><a href="#framework_dev" title="Framework development">Framework development</a> + </li> + </ul> + + @section introduction Developing with Syphon + + The Syphon framework provides the classes necessary to add Syphon support to your application. SyphonServer is used to make frames available to other applications. SyphonServerDirectory is used to discover available servers. SyphonClient is used to connect to and receive frames from a SyphonServer. + + The framework <em>requires</em> MacOS X 10.6 or later. Syphon makes use of IOSurface, which is a 10.6-only technology. Syphon takes advantage of other 10.6 features such as blocks, and is compatible with garbage-collection. + + To include Syphon in your application, follow these steps: + + <ol> + <li><h4>Add the framework to your Xcode project.</h4> + <p>The simplest way is to drag it to the Linked Frameworks group in the project window.</p></li> + <li><h4>Link your application with Syphon at build time.</h4> + <p>Add the framework to the Link Binary With Libraries build stage of your application's target.</p></li> + <li><h4>Copy the framework into your application's bundle.</h4> + <p>Add a new Copy Files build phase to your application's target.<br/> + Get Info on the build phase and select Frameworks as the destination.<br/> + Drag the Syphon framework into the build phase.</p></li> + <li><h4>Import the headers.</h4> + <p>#import <Syphon/Syphon.h> in any file where you want to use Syphon classes.</p></li> + </ol> + + @section servers Servers + + Class documentation: SyphonServer + + Create a server: + + @code + SyphonServer *myServer = [[SyphonServer alloc] initWithName:@"My Output" context:myContext options:nil]; + @endcode + + and then publish new frames (you can also use GL_TEXTURE_2D textures): + + @code + [myServer publishFrameTexture:myTex textureTarget:GL_TEXTURE_RECTANGLE_EXT imageRegion:NSMakeRect(0, 0, width, height) textureDimensions:NSMakeSize(width, height) flipped:NO]; + @endcode + + Alternatively there are methods to bind and unbind the server to the OpenGL context, so you can draw into it directly. + You can publish new frames as often as you like, but if you only publish when you have a frame different from the previous one, then clients can do less work. + You must stop the server when you are finished with it: + + @code + [myServer stop]; + @endcode + + @section finding-servers Finding Servers + + Class documentation: SyphonServerDirectory + + SyphonServerDirectory handles server discovery for you. You can get an array of dictionaries describing available servers: + + @code + NSArray *available = [[SyphonServerDirectory sharedDirectory] servers]; + @endcode + + The servers property can be observed for changes, or you can register to receive the notifications posted by SyphonServerDirectory. + + Server description dictionaries are used by Syphon when you create a client, and also contain information you can use to describe available servers in your UI: + + @code + [myMenuItem setTitle:[description objectForKey:SyphonServerDescriptionNameKey]]; + @endcode + + @section clients Clients + + Class documentation: SyphonClient, SyphonImage + + Usually you create a client with a server description dictionary you obtained from SyphonServerDirectory: + + @code + SyphonClient *myClient = [[SyphonClient alloc] initWithServerDescription:description options:nil newFrameHandler:^(SyphonClient *client) { + [myView setNeedsDisplay:YES]; + }]; + @endcode + + The new-frame handler is optional: you can pass in nil. Here we use it to tell a view it needs to draw whenever the client receives a frame. + + When you are ready to draw: + + @code + SyphonImage *myFrame = [myClient newFrameImageForContext:cgl_ctx]; + if (myFrame) + { + GLuint tex = myFrame.textureName; + NSSize dimensions = myFrame.textureSize; + + // YOUR OPENGL DRAWING CODE HERE + + [myFrame release]; + } + @endcode + + As with servers, you must stop the client when you are finished with it: + + @code + [myClient stop]; + @endcode + + @section plugins Syphon.framework in a Plugin + + If you are using Syphon in any sort of plugin, please download the framework source and compile a version of the framework with unique class names. This avoids class-name conflicts if another plugin or the host application also embeds the Syphon framework. The framework source is set up to make this easy for you: you just need to change one build setting. + + <ol> + <li><h4>Open the framework's Xcode project.</h4> + <p></p> + </li> + <li><h4>Define SYPHON_UNIQUE_CLASS_NAME_PREFIX using the Preprocessor Macros build setting.</h4> + <p>Select the Syphon target in the project window.<br/> + Get Info on the target, and click the Build tab to display the build settings.<br/> + Scroll down (or use the search field) to find the Preprocessor Macros (GCC_PREPROCESSOR_DEFINITIONS) setting.<br/> + Double click the setting to add SYPHON_UNIQUE_CLASS_NAME_PREFIX=MyPluginName as a macro. + </p></li> + <li><h4>Build the framework.</h4> + <p>The built framework will have custom class names. The headers alias the custom names, so you can use SyphonServer, SyphonClient, SyphonImage and SyphonServerDirectory as normal in your code.<br/> + </p></li> + </ol> + + @section help More examples and help + + Example projects implementing a server and client are included with the Syphon SDK. You can also examine the source to the provided Syphon implementations at their <a href="http://code.google.com/p/syphon-implementations/" target="_blank">Google Code project</a>. + + Use the <a href="http://forums.v002.info/forum.php?id=7" target="_blank">Syphon developer forum</a> to ask questions, and for any development related discussion. + + Good luck! + + @section framework_dev Framework development + + If you'd like to examine the framework's source code, report a bug, or get involved in development, head on over to the <a href="http://code.google.com/p/syphon-framework/" target="_blank">Syphon framework Google Code project.</a> + + */
\ No newline at end of file diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonClient.h b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonClient.h new file mode 100644 index 0000000..618a328 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonClient.h @@ -0,0 +1,96 @@ +/* + SyphonClient.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +@class SyphonImage; + +/*! + SyphonClient makes available frames from a remote SyphonServer. A client is created from a NSDictionary which describes the server. Typically this is obtained from the shared SyphonServerDirectory, or one of Syphon's notifications. + + SyphonClient allows for lazy drawing by the use of a new-frame-handler. Using a handler you can perform drawing without using a timer or polling, achieving frame-accuracy with the minimum of overhead. Alternatively, if your application uses a traditional display link or timer, you can use the hasNewFrame property to make decisions about work you may need to do. Irrespective of the presence of new frames, you can draw with a SyphonClient at any time. + + It is safe to access instances of this class across threads. + */ + +@interface SyphonClient : NSObject +{ +@private + id _connectionManager; + uint32_t _lastFrameID; + void (^_handler)(id); + int32_t _status; + int32_t _lock; +} +/*! + Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server. + @param description Typically acquired from the shared SyphonServerDirectory, or one of Syphon's notifications. + @param options Currently ignored. May be nil. + @param handler A block which is invoked when a new frame becomes available. handler may be nil. This block may be invoked on a thread other than that on which the client was created. + @returns A newly initialized SyphonClient object, or nil if a client could not be created. +*/ + +- (id)initWithServerDescription:(NSDictionary *)description options:(NSDictionary *)options newFrameHandler:(void (^)(SyphonClient *client))handler; + +/*! + A client is valid if it has a working connection to a server. Once this returns NO, the SyphonClient will not yield any further frames. + */ + +@property (readonly) BOOL isValid; + +/*! + Returns a dictionary with a description of the server the client is attached to. See SyphonServerDirectory for the keys this dictionary contains +*/ + +@property (readonly) NSDictionary *serverDescription; + +/*! + Returns YES if the server has output a new frame since the last time newFrameImageForContext: was called for this client, NO otherwise. +*/ + +@property (readonly) BOOL hasNewFrame; + +/*! + Returns a SyphonImage representing the current output from the server. The texture associated with the image may continue to update when you draw with it, but you should not depend on that behaviour: call this method every time you wish to access the current server frame. This object may have GPU resources associated with it and you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(). + @param cgl_ctx The CGL context in which the SyphonImage will be valid. + @returns A SyphonImage representing the live output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImageForContext:(CGLContextObj)cgl_ctx; + +/*! + Stops the client from receiving any further frames from the server. In garbage-collected applications you must call this method prior to removing strong references to the client. In non-garbage-collected applications, use of this method is optional and releasing all references to the client has the same effect. + */ + +- (void)stop; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonImage.h b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonImage.h new file mode 100644 index 0000000..d43277e --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonImage.h @@ -0,0 +1,50 @@ +/* + SyphonImage.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <OpenGL/OpenGL.h> + +/** + SyphonImage represents an image stored as an OpenGL texture of type GL_TEXTURE_RECTANGLE_ARB. + */ + +@interface SyphonImage : NSObject { + +} + +/** + A GLuint representing the texture name. The associated texture is of type GL_TEXTURE_RECTANGLE_ARB. + */ +@property (readonly) GLuint textureName; + +/** + A NSSize representing the dimensions of the texture. The image will fill the texture entirely. + */ +@property (readonly) NSSize textureSize; +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServer.h b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServer.h new file mode 100644 index 0000000..5cc9841 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServer.h @@ -0,0 +1,166 @@ +/* + SyphonServer.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> +#import <Quartz/Quartz.h> +#import <OpenGL/OpenGL.h> + +/*! @name Server Options Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServer + If this key is matched with a NSNumber with a BOOL value YES, then the server will be invisible to other Syphon users. You are then responsible for passing the NSDictionary returned by serverDescription to processes which require it to create a SyphonClient. Default is NO. + */ +extern NSString * const SyphonServerOptionIsPrivate; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServer handles the publishing of frames from one video source to any number of clients. Frames can be published either by passing in an existing OpenGL texture, or by binding the server's FBO, drawing using OpenGL calls, then calling the unbindAndPublish method. + + A SyphonServer object represents one video output for your application. If your application produces several video outputs, then they should each have their own SyphonServer. If your application might have multiple servers running, you should name each server to aid identification by users. + + It is safe to access instances of this class across threads, except for those calls related to OpenGL: a call to bindToDrawFrameOfSize: must have returned before a call is made to unbindAndPublish, and these methods must be paired and called in order. You should not call the stop method while the FBO is bound. + */ + +@class SyphonImage; + +@interface SyphonServer : NSObject +{ +@private + NSString *_name; + NSString *_uuid; + BOOL _broadcasts; + + id _connectionManager; + + CGLContextObj cgl_ctx; + + void *_surfaceRef; + BOOL _pushPending; + SyphonImage *_surfaceTexture; + GLuint _surfaceFBO; + + GLint _previousReadFBO; + GLint _previousDrawFBO; + GLint _previousFBO; + + int32_t _mdLock; +} +/** @name Instantiation */ +/** @{ */ +/*! + Creates a new server with the specified human-readable name (which need not be unique), CGLContext and options. The server will be started immediately. Init may fail and return nil if the server could not be started. + @param serverName Non-unique human readable server name. This is not required and may be nil, but is usually used by clients in their UI to aid identification. + @param context The CGLContextObj context that textures will be valid and available on for publishing. + @param options A dictionary containing key-value pairs to specify options for the server. Currently the only option is SyphonServerOptionIsPrivate. See its description for details. + @returns A newly intialized SyphonServer. Nil on failure. +*/ + +- (id)initWithName:(NSString*)serverName context:(CGLContextObj)context options:(NSDictionary *)options; + +/** @} */ + +/** @name Properties */ +/** @{ */ +/*! + The CGLContext the server uses for drawing. This may or may not be the context passed in at init. +*/ + +@property (readonly) CGLContextObj context; + +/*! + A string representing the name of the SyphonServer. +*/ + +@property (retain) NSString* name; + +/*! + A dictionary describing the server. Normally you won't need to access this, however if you created the server as private (using SyphonServerOptionIsPrivate) then you must pass this dictionary to any process in which you wish to create a SyphonClient. You should not rely on the presence of any particular keys in this dictionary. The content will always conform to the \<NSCoding\> protocol. +*/ + +@property (readonly) NSDictionary* serverDescription; + +/*! +YES if clients are currently attached, NO otherwise. If you generate frames frequently (for instance on a display-link timer), you may choose to test this and only call publishFrameTexture:textureTarget:imageRegion:textureDimensions:flipped: when clients are attached. +*/ + +@property (readonly) BOOL hasClients; + +/** @} */ +/** @name Publishing Frames */ +/** @{ */ + +/*! + Publishes the part of the texture described in region of the named texture to clients. The texture is copied and can be safely disposed of or modified once this method has returned. You should not bracket calls to this method with calls to -bindToDrawFrameOfSize: and -unbindAndPublish - they are provided as an alternative to using this method. + + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param texID The name of the texture to publish, which must be a texture valid in the CGL context provided when the server was created. + @param target GL_TEXTURE_RECTANGLE_EXT or GL_TEXTURE_2D. + @param region The sub-region of the texture to publish. + @param size The full size of the texture + @param isFlipped Is the texture flipped? +*/ + +- (void)publishFrameTexture:(GLuint)texID textureTarget:(GLenum)target imageRegion:(NSRect)region textureDimensions:(NSSize)size flipped:(BOOL)isFlipped; + +/*! + Binds an FBO for you to publish a frame of the given dimensions by drawing into the server's context (check it using the context property). If YES is returned, you must pair this with a call to -unbindAndPublish once you have finished drawing. If NO is returned you should abandon drawing and not call -unbindAndPublish. + This method does not lock the server's CGL context. If there is a chance other threads may use the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. + @param size The size the frame you wish to publish. + @returns YES if binding succeeded, NO otherwise. +*/ + +- (BOOL)bindToDrawFrameOfSize:(NSSize)size; + +/*! + Restores any previously bound FBO and publishes the just-drawn frame. This method will flush the GL context (so you don't have to). + This method does not lock the server's CGL context. If there is a chance of other threads using the context during calls to this method, bracket it with calls to CGLLockContext() and CGLUnlockContext(), passing in the value of the server's context property as the argument. +*/ + +- (void)unbindAndPublish; + +/*! + Returns a SyphonImage representing the current output from the server, valid in the server's CGL context. Call this method every time you wish to access the current server frame. This object has a limited useful lifetime, and may have GPU resources associated with it: you should release it as soon as you are finished drawing with it. + + This method does not lock the CGL context. If there is a chance other threads may use the context during calls to this method, or while you are drawing with the returned SyphonImage, bracket access with calls to CGLLockContext() and CGLUnlockContext(). + + @returns A SyphonImage representing the current output from the server. YOU ARE RESPONSIBLE FOR RELEASING THIS OBJECT when you are finished with it. + */ +- (SyphonImage *)newFrameImage; + +/*! + Stops the server instance. In garbage-collected applications you must call this method prior to removing strong references to the server. In non-garbage-collected applications, use of this method is optional. +*/ + +- (void)stop; +/** @} */ +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServerDirectory.h b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServerDirectory.h new file mode 100644 index 0000000..3cad8ce --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Headers/SyphonServerDirectory.h @@ -0,0 +1,126 @@ +/* + SyphonServerDirectory.h + Syphon + + Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +/*! @name Server Description Dictionary Key Constants */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which uniquely identifies a SyphonServer instance. If two dictionaries contain the same string for this key, they represent the same server. This is provided solely to allow you to programmatically determine the identity of a server, and should never be displayed to users in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionUUIDKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString which is the human-readable non-unique name for the SyphonServer. If this string exists and is non-empty, you should use it in interface elements to identify the server, usually in combination with the name of the server's application (see SyphonServerDescriptionAppNameKey). +*/ + +extern NSString * const SyphonServerDescriptionNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSString with the localized name of the application in which the SyphonServer is running. Use this in combination with the server's name (if present) to identify the server in interface elements. +*/ + +extern NSString * const SyphonServerDescriptionAppNameKey; + +/*! + @relates SyphonServerDirectory + The object for this key is a NSImage representation of the icon of the application in which the SyphonServer is running. +*/ + +extern NSString * const SyphonServerDescriptionIconKey; + +/*! @} */ + +/*! @name Notifications */ +/*! @{ */ + +/*! + @relates SyphonServerDirectory + A new SyphonServer is available on the system. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerAnnounceNotification; + +/*! + @relates SyphonServerDirectory + An existing SyphonServer instance has changed its description. The notification object is a NSDictionary describing the server. +*/ + +extern NSString * const SyphonServerUpdateNotification; + +/*! + @relates SyphonServerDirectory + A SyphonServer instance will no longer be available. The notification object is a NSDictionary describing the retiring server. +*/ + +extern NSString * const SyphonServerRetireNotification; + +/*! @} */ + +/*! + @nosubgrouping + SyphonServerDirectory provides information on available Syphon Servers. Servers are represented by dictionaries. Generally you can expect to find some or all of the keys listed in Constants. +*/ + +@interface SyphonServerDirectory : NSObject { +@private + NSMutableArray *_servers; + pthread_mutex_t _generalLock; + pthread_mutex_t _mutateLock; + NSMutableSet *_pings; +} + +/*! + Returns the shared server directory instance. This object is KVO complaint, and can be used to observe changes in server availability, server names and statuses. + @returns the shared server instance +*/ + ++ (SyphonServerDirectory *)sharedDirectory; + +/*! + NSArray of NSDictionaries that describe (using the keys above) currently available SyphonServer instances on the system. +*/ + +@property (readonly) NSArray *servers; + +/*! + Use this method to discover servers based soley on their name, or application host name. Both parameters are optional. If you do not specify either, all available SyphonServers will be returned. + @param name Optional (pass nil to not specify) Name of the published SyphonServer, matches the key value for SyphonServerDescriptionNameKey + @param appname Optional (pass nil to not specify) Application Name of the published SyphonServer, matches the key value for SyphonServerDescriptionAppNameKey + @returns An array of NSDictionaries matching the query you specified. +*/ + +- (NSArray *)serversMatchingName:(NSString *)name appName:(NSString *)appname; + +@end diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings b/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 0000000..5e45963 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/English.lproj/InfoPlist.strings diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/Info.plist b/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/Info.plist new file mode 100644 index 0000000..fb6cbc3 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Resources/Info.plist @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildMachineOSBuild</key> + <string>10J869</string> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>Syphon</string> + <key>CFBundleIdentifier</key> + <string>info.v002.Syphon</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Syphon</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>DTCompiler</key> + <string>com.apple.compilers.llvm.clang.1_0</string> + <key>DTPlatformBuild</key> + <string>4A2002a</string> + <key>DTPlatformVersion</key> + <string>GM</string> + <key>DTSDKBuild</key> + <string>4A2002a</string> + <key>DTSDKName</key> + <string>macosx10.6</string> + <key>DTXcode</key> + <string>0402</string> + <key>DTXcodeBuild</key> + <string>4A2002a</string> +</dict> +</plist> diff --git a/drawing/Frameworks/Syphon.framework/Versions/Current/Syphon b/drawing/Frameworks/Syphon.framework/Versions/Current/Syphon Binary files differnew file mode 100755 index 0000000..741b4e4 --- /dev/null +++ b/drawing/Frameworks/Syphon.framework/Versions/Current/Syphon |
