SyphonServer Class Reference

#import <SyphonServer.h>

Public Member Functions

Instantiation
(id) - initWithName:context:options:
Publishing Frames
(void) - publishFrameTexture:textureTarget:imageRegion:textureDimensions:flipped:
(BOOL) - bindToDrawFrameOfSize:
(void) - unbindAndPublish
(SyphonImage *) - newFrameImage
(void) - stop

Properties

Properties
CGLContextObj context
NSString * name
NSDictionary * serverDescription
BOOL hasClients

Related Functions

(Note that these are not member functions.)

Server Options Dictionary Key Constants
NSString *const SyphonServerOptionIsPrivate

Member Function Documentation

- (id) initWithName: (NSString *)  serverName
context: (CGLContextObj)  context
options: (NSDictionary *)  options 

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.

Parameters:
serverNameNon-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.
contextThe CGLContextObj context that textures will be valid and available on for publishing.
optionsA 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.
- (void) publishFrameTexture: (GLuint)  texID
textureTarget: (GLenum)  target
imageRegion: (NSRect)  region
textureDimensions: (NSSize)  size
flipped: (BOOL)  isFlipped 

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.

Parameters:
texIDThe name of the texture to publish, which must be a texture valid in the CGL context provided when the server was created.
targetGL_TEXTURE_RECTANGLE_EXT or GL_TEXTURE_2D.
regionThe sub-region of the texture to publish.
sizeThe full size of the texture
isFlippedIs the texture flipped?
- (BOOL) bindToDrawFrameOfSize: (NSSize)  size

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.

Parameters:
sizeThe size the frame you wish to publish.
Returns:
YES if binding succeeded, NO otherwise.
- (void) unbindAndPublish

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.

- (SyphonImage *) newFrameImage

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.
- (void) stop

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.


Friends And Related Function Documentation

- (NSString* const) SyphonServerOptionIsPrivate [related]

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.


Property Documentation

- (CGLContextObj) context [read, assign]

The CGLContext the server uses for drawing. This may or may not be the context passed in at init.

- (NSString*) name [read, write, retain]

A string representing the name of the SyphonServer.

- (NSDictionary*) serverDescription [read, assign]

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.

- (BOOL) hasClients [read, assign]

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.

 All Classes Functions Variables Properties