Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

What is MMAL?

Ian Auty edited this page Jun 29, 2017 · 4 revisions

In progress

MMAL (Multimedia Abstraction Layer) is a C library designed by Broadcom for use with the Videocore IV GPU found on the Raspberry Pi. Providing an abstraction layer upon another C library "OpenMAX", MMAL exposes an API allowing developers to take images and record video from their Raspberry Pi which is easier to understand and consume.

Components

Introduction

MMAL introduces the concept of "Components" - virtual resources which are able to produce and manipulate image data. Components are constructed manually by the user when required; below you'll find a list of components featured in MMAL.

Camera component

The camera component is a virtual representation of the camera module attached to the Raspberry Pi. This component has the ability to capture still images, video and also render textual outputs to the Pi display.

Encoders / Decoders

MMAL allows for image encoders/decoders and video encoders/decoders to be constructed within the pipeline which allow an end user to manipulate the image data.

Renderers

A renderer component has the ability to display textual data on the Pi's display output whilst recording video. If no renderer is required by the end user, a null-sink component should be constructed instead in order to measure exposure of the camera.

Resizer

A resizer component, as the name suggests, has the ability to alter the width/height of image frames. This is a useful component when mixed with the splitter component seen below.

Splitter

The splitter component exclusively connects to the video output port of the camera component. After doing so, the splitter provides a further 4 output ports which can further extend your pipeline and increase your application's use cases. When combined with the resizer component, multiple outputs can be stored using different frame sizes and encoding types.

Ports

A Port in MMAL is responsible for receiving/transmitting image data, and also for connecting components together. Components commonly feature a mixture of input/output ports but also clock and control ports too. In order to connect two Components together, a connection is constructed between an output port and the input port of a Downstream Component. An example pipeline could feature the Camera component which exposes 3 output ports: Still, Video and Preview. Following this, a user could connect an Image or Video Encoder which allows you to convert the raw image data into an encoded format such as JPEG or H.264.

Buffer headers

Buffer headers in MMAL are the entities that hold a reference to the image data being passed through your pipeline. These themselves do not hold the data in full, but instead reference a pointer to the beginning of the image data, this is so that the memory for the data can be allocated outside of MMAL.

After ports are configured by the consumer of the framework, the recommended number of buffer headers required for optimum performance is calculated, as well as the size of each buffer header. It is then the responsibility of the end user to construct the buffer pool and then send these to the output port of the component that shall be processing data.