libretro.api.camera

Interface and types for providing video input to a Core.

See also

CameraDriver

The protocol that uses these types to implement camera support in libretro.py.

libretro.drivers.camera

libretro.py’s included CameraDriver implementations.

Module Attributes

retro_camera_start_t

Start the camera.

retro_camera_stop_t

Stop the running camera.

retro_camera_lifetime_status_t

Notify the core that the camera driver has been initialized or deinitialized.

retro_camera_frame_raw_framebuffer_t

Deliver a new camera frame as a raw pixel buffer.

retro_camera_frame_opengl_texture_t

Deliver a new camera frame as an OpenGL texture.

Classes

CameraCapabilities

Denotes camera features requested by the Core and/or supported by the CameraDriver.

CameraCapabilityFlags

Bitmask of supported camera driver features.

retro_camera_callback

Interface between the core and the CameraDriver.

retro_camera_start_t

Start the camera.

Called by the core to begin receiving camera frames from the frontend. Cameras are disabled by default and must be explicitly started.

Returns:

True if the camera was successfully started, False if no camera is available or the frontend lacks permission to access it.

Corresponds to retro_camera_start_t in libretro.h.

retro_camera_stop_t

Stop the running camera.

Called by the core to halt the delivery of camera frames.

Corresponds to retro_camera_stop_t in libretro.h.

retro_camera_lifetime_status_t

Notify the core that the camera driver has been initialized or deinitialized.

Registered by the core and called by the frontend right after the camera driver is initialized, or right before it is deinitialized.

Corresponds to retro_camera_lifetime_status_t in libretro.h.

retro_camera_frame_raw_framebuffer_t

Deliver a new camera frame as a raw pixel buffer.

Registered by the core and called by the frontend when a new camera frame is available in system memory, with the top-left corner of the image as the first pixel.

Parameters:
  • buffer – Pointer to the camera’s most recent video frame, with one XRGB8888 pixel per uint32_t.

  • width – Width of the frame, in pixels.

  • height – Height of the frame, in pixels.

  • pitch – Length of one row in buffer, in bytes.

Warning

buffer may be invalidated when this function returns, so the core should make its own copy if it needs to retain the data.

Corresponds to retro_camera_frame_raw_framebuffer_t in libretro.h.

retro_camera_frame_opengl_texture_t

Deliver a new camera frame as an OpenGL texture.

Registered by the core and called by the frontend when a new camera frame is available as a frontend-owned OpenGL texture.

Parameters:
  • texture_id – ID of the OpenGL texture that holds the frame. Owned by the frontend; the core must not modify it.

  • texture_target – OpenGL texture target type (e.g. GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).

  • affine – Pointer to a 3x3 column-major affine matrix that maps pixel coordinates to texture coordinates.

Warning

texture_id and affine may be invalidated when this function returns, so the core should make its own copy if it needs to retain them.

Corresponds to retro_camera_frame_opengl_texture_t in libretro.h.

class retro_camera_callback[source]

Bases: Structure

Interface between the core and the CameraDriver.

Corresponds to retro_camera_callback in libretro.h.

caps

Bitmask of requested CameraCapabilities.

Assigned values will be bitwise-masked to fit into a uint64_t.

width

The core’s requested width of the camera frame in pixels. 0 means that the CameraDriver should choose the width.

Assigned values will be bitwise-masked to fit into an unsigned int.

height

The core’s requested height of the camera frame in pixels. 0 means that the CameraDriver should choose the height.

Assigned values will be bitwise-masked to fit into an unsigned int.

start

Called by the core to start the camera.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
stop

Called by the core to stop the camera.

frame_raw_framebuffer

Called by the CameraDriver when it produces a frame backed by a raw framebuffer. Set by the Core.

frame_opengl_texture

Called by the CameraDriver when it produces a frame backed by an OpenGL texture. Set by the Core.

initialized

Called by the CameraDriver after it’s initialized. Set by the Core. Optional.

deinitialized

Called by the CameraDriver before it’s deinitialized. Set by the Core. Optional.

__deepcopy__(_)[source]

Return a deep copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_camera_callback
>>> cb = retro_camera_callback(caps=1, width=640, height=480)
>>> cb2 = copy.deepcopy(cb)
>>> cb == cb2
True
>>> cb is cb2
False
class CameraCapabilities[source]

Bases: IntEnum

Denotes camera features requested by the Core and/or supported by the CameraDriver.

Corresponds to retro_camera_buffer.

OPENGL_TEXTURE = 0
RAW_FRAMEBUFFER = 1
flag()[source]

Return this capability as a bitmask flag.

Equivalent to 1 << self.value.

Return type:

int

>>> from libretro.api import CameraCapabilities
>>> CameraCapabilities.OPENGL_TEXTURE.flag()
1
__new__(value)
classmethod value in self

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod self[name]

Return the member matching name.

__init__()
classmethod iter(self)

Return members in definition order.

classmethod len(self)

Return the number of members (no aliases)

class CameraCapabilityFlags[source]

Bases: IntFlag

Bitmask of supported camera driver features.

>>> from libretro.api import CameraCapabilityFlags
>>> CameraCapabilityFlags.RAW_FRAMEBUFFER | CameraCapabilityFlags.OPENGL_TEXTURE
<CameraCapabilityFlags.RAW_FRAMEBUFFER|OPENGL_TEXTURE: 3>
OPENGL_TEXTURE = 1
RAW_FRAMEBUFFER = 2
__new__(value)
other in self

Returns True if self has at least the same flags set as other.

iter(self)

Returns flags in definition order.

len(self)

Return the number of members (no aliases)

classmethod self[name]

Return the member matching name.

__init__()
retro_camera_buffer

alias of c_int