/
mmalcomponent.h
33 lines (26 loc) · 922 Bytes
/
mmalcomponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef MMALCOMPONENT_H
#define MMALCOMPONENT_H
#include <vector>
#include <mmal_component.h>
#include <mmal_pool.h>
class MMALListener;
class MMAL_CONNECTION_T;
class MMALComponent
{
public:
MMALComponent(const char *component_type);
virtual ~MMALComponent();
void connect(int src_port, MMALComponent *dst, int dst_port);
void add_port_listener(MMALListener *l) { port_listeners.push_back(l); }
protected:
virtual void callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
virtual void return_buffer(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
void enable_port_with_callback(MMAL_PORT_T *port);
MMAL_COMPONENT_T *component {};
// FIXME: Support multiple connections.
MMAL_CONNECTION_T *connection {};
private:
static void c_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
std::vector<MMALListener *>port_listeners;
};
#endif // MMALCOMPONENT_H