Exemplo n.º 1
0
                'video_size',  # the size (in bytes) of the video so far
                'split_size',  # the size (in bytes) of the video since the last split
                'timestamp',  # the presentation timestamp (PTS) of the frame
                'header',  # the frame is an SPS/PPS header
            ))):
    @property
    def position(self):
        return self.split_size - self.frame_size


def _encoder_callback(port, buf):
    encoder = ct.cast(port[0].userdata, ct.POINTER(ct.py_object))[0]
    encoder._callback(port, buf)


_encoder_callback = mmal.MMAL_PORT_BH_CB_T(_encoder_callback)


class PiEncoder(object):
    """
    Abstract base implemetation of an MMAL encoder for use by PiCamera
    """

    encoder_type = None

    def __init__(self, parent, camera_port, input_port, format, resize,
                 **options):
        self.parent = parent
        self.format = format
        self.encoder = None
        self.resizer = None
Exemplo n.º 2
0
import ctypes as ct

import picamera.mmal as mmal
from picamera.exc import (
    PiCameraRuntimeError,
    PiCameraValueError,
    mmal_check,
)


def _overlay_callback(port, buf):
    mmal.mmal_buffer_header_release(buf)


_overlay_callback = mmal.MMAL_PORT_BH_CB_T(_overlay_callback)


class PiRenderer(object):
    """
    Base implementation of an MMAL video renderer for use by PiCamera.

    The *parent* parameter specifies the :class:`~picamera.camera.PiCamera`
    instance that has constructed this renderer. The *layer* parameter
    specifies the layer that the renderer will inhabit. Higher numbered layers
    obscure lower numbered layers (unless they are partially transparent). The
    initial opacity of the renderer is specified by the *alpha* parameter
    (which defaults to 255, meaning completely opaque). The *fullscreen*
    parameter which defaults to ``True`` indicates whether the renderer should
    occupy the entire display.  Finally, the *window* parameter (which only has
    meaning when *fullscreen* is ``False``) is a four-tuple of ``(x, y, width,