syphon.server
1from abc import ABC, abstractmethod 2from typing import Tuple, Optional, Any 3 4import Cocoa 5import Metal 6import objc 7from OpenGL.GL import * 8 9from syphon.types import Texture, Region, Size 10from syphon.utils import opengl 11 12 13class BaseSyphonServer(ABC): 14 """ 15 Abstract base class for Syphon servers. 16 17 Attributes: 18 - name (str): The name of the Syphon server. 19 """ 20 21 def __init__(self, name: str): 22 """ 23 Initialize a BaseSyphonServer. 24 25 Parameters: 26 - name (str): The name of the Syphon server. 27 """ 28 self.name = name 29 30 @abstractmethod 31 def publish_frame_texture(self, 32 texture: Texture, 33 region: Optional[Region] = None, 34 size: Optional[Size] = None, 35 is_flipped: bool = False): 36 """ 37 Publish a frame with the given texture. 38 39 Parameters: 40 - texture (Texture): The texture to publish. 41 - region (Region, optional): The region of the texture to publish. Defaults to None. 42 - size (Size, optional): The size of the texture. Defaults to None. 43 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 44 """ 45 pass 46 47 @abstractmethod 48 def publish(self): 49 """ 50 Publish the frame. 51 """ 52 pass 53 54 @abstractmethod 55 def stop(self): 56 """ 57 Stop the Syphon server. 58 """ 59 pass 60 61 @property 62 @abstractmethod 63 def has_clients(self) -> bool: 64 """ 65 Check if the Syphon server has clients. 66 67 Returns: 68 - bool: True if there are clients, False otherwise. 69 """ 70 pass 71 72 @abstractmethod 73 def _get_texture_size(self, texture: Texture) -> Size: 74 """ 75 Get the size of the texture. 76 77 Parameters: 78 - texture (Texture): The texture. 79 80 Returns: 81 - Size: The size of the texture. 82 """ 83 pass 84 85 def _prepare_region_and_size(self, 86 texture: Texture, 87 region: Optional[Region] = None, 88 size: Optional[Size] = None) -> Tuple[Region, Size]: 89 """ 90 Prepare the region and size for publishing. 91 92 Parameters: 93 - texture (Texture): The texture to publish. 94 - region (Region, optional): The region of the texture to publish. Defaults to None. 95 - size (Size, optional): The size of the texture. Defaults to None. 96 97 Returns: 98 - Tuple[Region, Size]: The prepared region and size. 99 """ 100 size = self._get_texture_size(texture) if size is None else size 101 if region is None: 102 region = (0, 0, *size) 103 return region, size 104 105 106class SyphonMetalServer(BaseSyphonServer): 107 """ 108 Syphon server for Metal-based rendering. 109 110 Attributes: 111 - name (str): The name of the Syphon server. 112 - device (Any): The Metal device. 113 - command_queue (Any): The Metal command queue. 114 - context (Any): The Syphon-Metal context. 115 """ 116 117 def __init__(self, 118 name: str, 119 device: Optional[Any] = None, 120 command_queue: Optional[Any] = None): 121 """ 122 Initialize a SyphonMetalServer. 123 124 Parameters: 125 - name (str): The name of the Syphon server. 126 - device (Any, optional): The Metal device. If None, the default system device will be used. 127 - command_queue (Any, optional): The Metal command queue. If None, a new command queue will be created. 128 """ 129 super().__init__(name) 130 131 self.device = device 132 self.command_queue = command_queue 133 134 # setup device 135 if self.device is None: 136 self.device = Metal.MTLCreateSystemDefaultDevice() 137 138 # setup command queue 139 if self.command_queue is None: 140 self.command_queue = self.device.newCommandQueue() 141 142 # setup syphon-metal context 143 SyphonMetalServerObjC = objc.lookUpClass("SyphonMetalServer") 144 self.context = SyphonMetalServerObjC.alloc().initWithName_device_options_(name, self.device, None) 145 146 def publish_frame_texture(self, 147 texture: Texture, 148 region: Optional[Region] = None, 149 size: Optional[Size] = None, 150 is_flipped: bool = False, 151 command_buffer: Optional[Any] = None, 152 auto_commit: bool = True): 153 """ 154 Publish a frame with the given Metal texture. 155 156 Parameters: 157 - texture (Texture): The Metal texture to publish. 158 - region (Region, optional): The region of the texture to publish. Defaults to None. 159 - size (Size, optional): The size of the texture. Defaults to None. 160 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 161 - command_buffer (Any, optional): The Metal command buffer. If None, a new command buffer will be created. 162 - auto_commit (bool, optional): If True, the command buffer is committed automatically. Defaults to True. 163 """ 164 # create ns-region 165 region, _ = self._prepare_region_and_size(texture, region, size) 166 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 167 168 # prepare command buffer if necessary 169 if command_buffer is None: 170 command_buffer = self.command_queue.commandBuffer() 171 172 # publish actual texture 173 self.context.publishFrameTexture_onCommandBuffer_imageRegion_flipped_(texture, 174 command_buffer, 175 ns_region, 176 is_flipped) 177 # commit command buffer 178 if auto_commit: 179 command_buffer.commitAndWaitUntilSubmitted() 180 181 def publish(self): 182 """ 183 Publish the frame. 184 """ 185 self.context.publish() 186 187 def stop(self): 188 """ 189 Stop the SyphonMetalServer. 190 """ 191 self.context.stop() 192 193 @property 194 def has_clients(self) -> bool: 195 """ 196 Check if the SyphonMetalServer has clients. 197 198 Returns: 199 - bool: True if there are clients, False otherwise. 200 """ 201 return self.context.hasClients() 202 203 def _get_texture_size(self, texture: Texture) -> Tuple[int, int]: 204 """ 205 Get the size of the Metal texture. 206 207 Parameters: 208 - texture (Texture): The Metal texture. 209 210 Returns: 211 - Tuple[int, int]: The size of the texture. 212 """ 213 return texture.width(), texture.height() 214 215 216class SyphonOpenGLServer(BaseSyphonServer): 217 """ 218 Syphon server for OpenGL-based rendering. 219 220 Attributes: 221 - name (str): The name of the Syphon server. 222 - cgl_context_obj (Any): The CGL context object. 223 - context (Any): The Syphon-OpenGL context. 224 """ 225 226 def __init__(self, name: str, cgl_context_obj: Optional[Any] = None): 227 """ 228 Initialize a SyphonOpenGLServer. 229 230 Parameters: 231 - name (str): The name of the Syphon server. 232 - cgl_context_obj (Any, optional): The CGL context object. If None, the current context will be used. 233 """ 234 super().__init__(name) 235 236 # store CGL context object 237 self.cgl_context_obj = opengl.get_current_cgl_context_obj() if cgl_context_obj is None else cgl_context_obj 238 239 # create syphon gl server 240 SyphonOpenGLServerObjC = objc.lookUpClass("SyphonOpenGLServer") 241 self.context = SyphonOpenGLServerObjC.alloc().initWithName_context_options_(name, self.cgl_context_obj, None) 242 243 def publish_frame_texture(self, 244 texture: GLint, 245 region: Optional[Region] = None, 246 size: Optional[Size] = None, 247 is_flipped: bool = False, 248 target: GLenum = GL_TEXTURE_2D): 249 """ 250 Publish a frame with the given OpenGL texture. 251 252 Parameters: 253 - texture (GLint): The OpenGL texture to publish. 254 - region (Region, optional): The region of the texture to publish. Defaults to None. 255 - size (Size, optional): The size of the texture. Defaults to None. 256 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 257 - target (GLenum, optional): The OpenGL texture target. Defaults to GL_TEXTURE_2D. 258 """ 259 # create ns-region 260 region, size = self._prepare_region_and_size(texture, region, size) 261 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 262 ns_size = Cocoa.NSSize(size[0], size[1]) 263 264 self.context.publishFrameTexture_textureTarget_imageRegion_textureDimensions_flipped_(texture, target, 265 ns_region, 266 ns_size, is_flipped) 267 268 def publish(self): 269 """ 270 Publish the frame. 271 """ 272 self.context.publish() 273 274 def stop(self): 275 """ 276 Stop the SyphonOpenGLServer. 277 """ 278 self.context.stop() 279 280 @property 281 def has_clients(self) -> bool: 282 """ 283 Check if the SyphonOpenGLServer has clients. 284 285 Returns: 286 - bool: True if there are clients, False otherwise. 287 """ 288 return self.context.hasClients() 289 290 def _get_texture_size(self, texture: Texture) -> Size: 291 """ 292 Get the size of the OpenGL texture. 293 294 Parameters: 295 - texture (Texture): The OpenGL texture. 296 297 Returns: 298 - Size: The size of the texture. 299 """ 300 glBindTexture(GL_TEXTURE_2D, texture) 301 302 width = GLint() 303 height = GLint() 304 305 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, width) 306 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, height) 307 308 glBindTexture(GL_TEXTURE_2D, 0) 309 310 return int(width.value), int(height.value)
class
BaseSyphonServer(abc.ABC):
14class BaseSyphonServer(ABC): 15 """ 16 Abstract base class for Syphon servers. 17 18 Attributes: 19 - name (str): The name of the Syphon server. 20 """ 21 22 def __init__(self, name: str): 23 """ 24 Initialize a BaseSyphonServer. 25 26 Parameters: 27 - name (str): The name of the Syphon server. 28 """ 29 self.name = name 30 31 @abstractmethod 32 def publish_frame_texture(self, 33 texture: Texture, 34 region: Optional[Region] = None, 35 size: Optional[Size] = None, 36 is_flipped: bool = False): 37 """ 38 Publish a frame with the given texture. 39 40 Parameters: 41 - texture (Texture): The texture to publish. 42 - region (Region, optional): The region of the texture to publish. Defaults to None. 43 - size (Size, optional): The size of the texture. Defaults to None. 44 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 45 """ 46 pass 47 48 @abstractmethod 49 def publish(self): 50 """ 51 Publish the frame. 52 """ 53 pass 54 55 @abstractmethod 56 def stop(self): 57 """ 58 Stop the Syphon server. 59 """ 60 pass 61 62 @property 63 @abstractmethod 64 def has_clients(self) -> bool: 65 """ 66 Check if the Syphon server has clients. 67 68 Returns: 69 - bool: True if there are clients, False otherwise. 70 """ 71 pass 72 73 @abstractmethod 74 def _get_texture_size(self, texture: Texture) -> Size: 75 """ 76 Get the size of the texture. 77 78 Parameters: 79 - texture (Texture): The texture. 80 81 Returns: 82 - Size: The size of the texture. 83 """ 84 pass 85 86 def _prepare_region_and_size(self, 87 texture: Texture, 88 region: Optional[Region] = None, 89 size: Optional[Size] = None) -> Tuple[Region, Size]: 90 """ 91 Prepare the region and size for publishing. 92 93 Parameters: 94 - texture (Texture): The texture to publish. 95 - region (Region, optional): The region of the texture to publish. Defaults to None. 96 - size (Size, optional): The size of the texture. Defaults to None. 97 98 Returns: 99 - Tuple[Region, Size]: The prepared region and size. 100 """ 101 size = self._get_texture_size(texture) if size is None else size 102 if region is None: 103 region = (0, 0, *size) 104 return region, size
Abstract base class for Syphon servers.
Attributes:
- name (str): The name of the Syphon server.
BaseSyphonServer(name: str)
22 def __init__(self, name: str): 23 """ 24 Initialize a BaseSyphonServer. 25 26 Parameters: 27 - name (str): The name of the Syphon server. 28 """ 29 self.name = name
Initialize a BaseSyphonServer.
Parameters:
- name (str): The name of the Syphon server.
@abstractmethod
def
publish_frame_texture( self, texture: Any, region: Optional[Tuple[int, int, int, int]] = None, size: Optional[Tuple[int, int]] = None, is_flipped: bool = False):
31 @abstractmethod 32 def publish_frame_texture(self, 33 texture: Texture, 34 region: Optional[Region] = None, 35 size: Optional[Size] = None, 36 is_flipped: bool = False): 37 """ 38 Publish a frame with the given texture. 39 40 Parameters: 41 - texture (Texture): The texture to publish. 42 - region (Region, optional): The region of the texture to publish. Defaults to None. 43 - size (Size, optional): The size of the texture. Defaults to None. 44 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 45 """ 46 pass
Publish a frame with the given texture.
Parameters:
- texture (Texture): The texture to publish.
- region (Region, optional): The region of the texture to publish. Defaults to None.
- size (Size, optional): The size of the texture. Defaults to None.
- is_flipped (bool, optional): If True, the frame is flipped. Defaults to False.
107class SyphonMetalServer(BaseSyphonServer): 108 """ 109 Syphon server for Metal-based rendering. 110 111 Attributes: 112 - name (str): The name of the Syphon server. 113 - device (Any): The Metal device. 114 - command_queue (Any): The Metal command queue. 115 - context (Any): The Syphon-Metal context. 116 """ 117 118 def __init__(self, 119 name: str, 120 device: Optional[Any] = None, 121 command_queue: Optional[Any] = None): 122 """ 123 Initialize a SyphonMetalServer. 124 125 Parameters: 126 - name (str): The name of the Syphon server. 127 - device (Any, optional): The Metal device. If None, the default system device will be used. 128 - command_queue (Any, optional): The Metal command queue. If None, a new command queue will be created. 129 """ 130 super().__init__(name) 131 132 self.device = device 133 self.command_queue = command_queue 134 135 # setup device 136 if self.device is None: 137 self.device = Metal.MTLCreateSystemDefaultDevice() 138 139 # setup command queue 140 if self.command_queue is None: 141 self.command_queue = self.device.newCommandQueue() 142 143 # setup syphon-metal context 144 SyphonMetalServerObjC = objc.lookUpClass("SyphonMetalServer") 145 self.context = SyphonMetalServerObjC.alloc().initWithName_device_options_(name, self.device, None) 146 147 def publish_frame_texture(self, 148 texture: Texture, 149 region: Optional[Region] = None, 150 size: Optional[Size] = None, 151 is_flipped: bool = False, 152 command_buffer: Optional[Any] = None, 153 auto_commit: bool = True): 154 """ 155 Publish a frame with the given Metal texture. 156 157 Parameters: 158 - texture (Texture): The Metal texture to publish. 159 - region (Region, optional): The region of the texture to publish. Defaults to None. 160 - size (Size, optional): The size of the texture. Defaults to None. 161 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 162 - command_buffer (Any, optional): The Metal command buffer. If None, a new command buffer will be created. 163 - auto_commit (bool, optional): If True, the command buffer is committed automatically. Defaults to True. 164 """ 165 # create ns-region 166 region, _ = self._prepare_region_and_size(texture, region, size) 167 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 168 169 # prepare command buffer if necessary 170 if command_buffer is None: 171 command_buffer = self.command_queue.commandBuffer() 172 173 # publish actual texture 174 self.context.publishFrameTexture_onCommandBuffer_imageRegion_flipped_(texture, 175 command_buffer, 176 ns_region, 177 is_flipped) 178 # commit command buffer 179 if auto_commit: 180 command_buffer.commitAndWaitUntilSubmitted() 181 182 def publish(self): 183 """ 184 Publish the frame. 185 """ 186 self.context.publish() 187 188 def stop(self): 189 """ 190 Stop the SyphonMetalServer. 191 """ 192 self.context.stop() 193 194 @property 195 def has_clients(self) -> bool: 196 """ 197 Check if the SyphonMetalServer has clients. 198 199 Returns: 200 - bool: True if there are clients, False otherwise. 201 """ 202 return self.context.hasClients() 203 204 def _get_texture_size(self, texture: Texture) -> Tuple[int, int]: 205 """ 206 Get the size of the Metal texture. 207 208 Parameters: 209 - texture (Texture): The Metal texture. 210 211 Returns: 212 - Tuple[int, int]: The size of the texture. 213 """ 214 return texture.width(), texture.height()
Syphon server for Metal-based rendering.
Attributes:
- name (str): The name of the Syphon server.
- device (Any): The Metal device.
- command_queue (Any): The Metal command queue.
- context (Any): The Syphon-Metal context.
SyphonMetalServer( name: str, device: Optional[Any] = None, command_queue: Optional[Any] = None)
118 def __init__(self, 119 name: str, 120 device: Optional[Any] = None, 121 command_queue: Optional[Any] = None): 122 """ 123 Initialize a SyphonMetalServer. 124 125 Parameters: 126 - name (str): The name of the Syphon server. 127 - device (Any, optional): The Metal device. If None, the default system device will be used. 128 - command_queue (Any, optional): The Metal command queue. If None, a new command queue will be created. 129 """ 130 super().__init__(name) 131 132 self.device = device 133 self.command_queue = command_queue 134 135 # setup device 136 if self.device is None: 137 self.device = Metal.MTLCreateSystemDefaultDevice() 138 139 # setup command queue 140 if self.command_queue is None: 141 self.command_queue = self.device.newCommandQueue() 142 143 # setup syphon-metal context 144 SyphonMetalServerObjC = objc.lookUpClass("SyphonMetalServer") 145 self.context = SyphonMetalServerObjC.alloc().initWithName_device_options_(name, self.device, None)
Initialize a SyphonMetalServer.
Parameters:
- name (str): The name of the Syphon server.
- device (Any, optional): The Metal device. If None, the default system device will be used.
- command_queue (Any, optional): The Metal command queue. If None, a new command queue will be created.
def
publish_frame_texture( self, texture: Any, region: Optional[Tuple[int, int, int, int]] = None, size: Optional[Tuple[int, int]] = None, is_flipped: bool = False, command_buffer: Optional[Any] = None, auto_commit: bool = True):
147 def publish_frame_texture(self, 148 texture: Texture, 149 region: Optional[Region] = None, 150 size: Optional[Size] = None, 151 is_flipped: bool = False, 152 command_buffer: Optional[Any] = None, 153 auto_commit: bool = True): 154 """ 155 Publish a frame with the given Metal texture. 156 157 Parameters: 158 - texture (Texture): The Metal texture to publish. 159 - region (Region, optional): The region of the texture to publish. Defaults to None. 160 - size (Size, optional): The size of the texture. Defaults to None. 161 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 162 - command_buffer (Any, optional): The Metal command buffer. If None, a new command buffer will be created. 163 - auto_commit (bool, optional): If True, the command buffer is committed automatically. Defaults to True. 164 """ 165 # create ns-region 166 region, _ = self._prepare_region_and_size(texture, region, size) 167 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 168 169 # prepare command buffer if necessary 170 if command_buffer is None: 171 command_buffer = self.command_queue.commandBuffer() 172 173 # publish actual texture 174 self.context.publishFrameTexture_onCommandBuffer_imageRegion_flipped_(texture, 175 command_buffer, 176 ns_region, 177 is_flipped) 178 # commit command buffer 179 if auto_commit: 180 command_buffer.commitAndWaitUntilSubmitted()
Publish a frame with the given Metal texture.
Parameters:
- texture (Texture): The Metal texture to publish.
- region (Region, optional): The region of the texture to publish. Defaults to None.
- size (Size, optional): The size of the texture. Defaults to None.
- is_flipped (bool, optional): If True, the frame is flipped. Defaults to False.
- command_buffer (Any, optional): The Metal command buffer. If None, a new command buffer will be created.
- auto_commit (bool, optional): If True, the command buffer is committed automatically. Defaults to True.
has_clients: bool
Check if the SyphonMetalServer has clients.
Returns:
- bool: True if there are clients, False otherwise.
Inherited Members
217class SyphonOpenGLServer(BaseSyphonServer): 218 """ 219 Syphon server for OpenGL-based rendering. 220 221 Attributes: 222 - name (str): The name of the Syphon server. 223 - cgl_context_obj (Any): The CGL context object. 224 - context (Any): The Syphon-OpenGL context. 225 """ 226 227 def __init__(self, name: str, cgl_context_obj: Optional[Any] = None): 228 """ 229 Initialize a SyphonOpenGLServer. 230 231 Parameters: 232 - name (str): The name of the Syphon server. 233 - cgl_context_obj (Any, optional): The CGL context object. If None, the current context will be used. 234 """ 235 super().__init__(name) 236 237 # store CGL context object 238 self.cgl_context_obj = opengl.get_current_cgl_context_obj() if cgl_context_obj is None else cgl_context_obj 239 240 # create syphon gl server 241 SyphonOpenGLServerObjC = objc.lookUpClass("SyphonOpenGLServer") 242 self.context = SyphonOpenGLServerObjC.alloc().initWithName_context_options_(name, self.cgl_context_obj, None) 243 244 def publish_frame_texture(self, 245 texture: GLint, 246 region: Optional[Region] = None, 247 size: Optional[Size] = None, 248 is_flipped: bool = False, 249 target: GLenum = GL_TEXTURE_2D): 250 """ 251 Publish a frame with the given OpenGL texture. 252 253 Parameters: 254 - texture (GLint): The OpenGL texture to publish. 255 - region (Region, optional): The region of the texture to publish. Defaults to None. 256 - size (Size, optional): The size of the texture. Defaults to None. 257 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 258 - target (GLenum, optional): The OpenGL texture target. Defaults to GL_TEXTURE_2D. 259 """ 260 # create ns-region 261 region, size = self._prepare_region_and_size(texture, region, size) 262 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 263 ns_size = Cocoa.NSSize(size[0], size[1]) 264 265 self.context.publishFrameTexture_textureTarget_imageRegion_textureDimensions_flipped_(texture, target, 266 ns_region, 267 ns_size, is_flipped) 268 269 def publish(self): 270 """ 271 Publish the frame. 272 """ 273 self.context.publish() 274 275 def stop(self): 276 """ 277 Stop the SyphonOpenGLServer. 278 """ 279 self.context.stop() 280 281 @property 282 def has_clients(self) -> bool: 283 """ 284 Check if the SyphonOpenGLServer has clients. 285 286 Returns: 287 - bool: True if there are clients, False otherwise. 288 """ 289 return self.context.hasClients() 290 291 def _get_texture_size(self, texture: Texture) -> Size: 292 """ 293 Get the size of the OpenGL texture. 294 295 Parameters: 296 - texture (Texture): The OpenGL texture. 297 298 Returns: 299 - Size: The size of the texture. 300 """ 301 glBindTexture(GL_TEXTURE_2D, texture) 302 303 width = GLint() 304 height = GLint() 305 306 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, width) 307 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, height) 308 309 glBindTexture(GL_TEXTURE_2D, 0) 310 311 return int(width.value), int(height.value)
Syphon server for OpenGL-based rendering.
Attributes:
- name (str): The name of the Syphon server.
- cgl_context_obj (Any): The CGL context object.
- context (Any): The Syphon-OpenGL context.
SyphonOpenGLServer(name: str, cgl_context_obj: Optional[Any] = None)
227 def __init__(self, name: str, cgl_context_obj: Optional[Any] = None): 228 """ 229 Initialize a SyphonOpenGLServer. 230 231 Parameters: 232 - name (str): The name of the Syphon server. 233 - cgl_context_obj (Any, optional): The CGL context object. If None, the current context will be used. 234 """ 235 super().__init__(name) 236 237 # store CGL context object 238 self.cgl_context_obj = opengl.get_current_cgl_context_obj() if cgl_context_obj is None else cgl_context_obj 239 240 # create syphon gl server 241 SyphonOpenGLServerObjC = objc.lookUpClass("SyphonOpenGLServer") 242 self.context = SyphonOpenGLServerObjC.alloc().initWithName_context_options_(name, self.cgl_context_obj, None)
Initialize a SyphonOpenGLServer.
Parameters:
- name (str): The name of the Syphon server.
- cgl_context_obj (Any, optional): The CGL context object. If None, the current context will be used.
def
publish_frame_texture( self, texture: ctypes.c_int, region: Optional[Tuple[int, int, int, int]] = None, size: Optional[Tuple[int, int]] = None, is_flipped: bool = False, target: ctypes.c_uint = GL_TEXTURE_2D):
244 def publish_frame_texture(self, 245 texture: GLint, 246 region: Optional[Region] = None, 247 size: Optional[Size] = None, 248 is_flipped: bool = False, 249 target: GLenum = GL_TEXTURE_2D): 250 """ 251 Publish a frame with the given OpenGL texture. 252 253 Parameters: 254 - texture (GLint): The OpenGL texture to publish. 255 - region (Region, optional): The region of the texture to publish. Defaults to None. 256 - size (Size, optional): The size of the texture. Defaults to None. 257 - is_flipped (bool, optional): If True, the frame is flipped. Defaults to False. 258 - target (GLenum, optional): The OpenGL texture target. Defaults to GL_TEXTURE_2D. 259 """ 260 # create ns-region 261 region, size = self._prepare_region_and_size(texture, region, size) 262 ns_region = Cocoa.NSRect((region[0], region[1]), (region[2], region[3])) 263 ns_size = Cocoa.NSSize(size[0], size[1]) 264 265 self.context.publishFrameTexture_textureTarget_imageRegion_textureDimensions_flipped_(texture, target, 266 ns_region, 267 ns_size, is_flipped)
Publish a frame with the given OpenGL texture.
Parameters:
- texture (GLint): The OpenGL texture to publish.
- region (Region, optional): The region of the texture to publish. Defaults to None.
- size (Size, optional): The size of the texture. Defaults to None.
- is_flipped (bool, optional): If True, the frame is flipped. Defaults to False.
- target (GLenum, optional): The OpenGL texture target. Defaults to GL_TEXTURE_2D.
has_clients: bool
Check if the SyphonOpenGLServer has clients.
Returns:
- bool: True if there are clients, False otherwise.