nx_server_plugin_sdk 1.0 Server Plugin SDK

rpi_omx_broadcom.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #ifndef _RPI_BROADCOM_H_
4 #define _RPI_BROADCOM_H_
5
6 #include <interface/vcos/vcos_semaphore.h>
7 #include <interface/vmcs_host/vchost.h>
8
10 namespace broadcom
11 {
12 typedef enum
13 {
14 VIDEO_SCHEDULER = 10,
15 SOURCE = 20,
16 RESIZER = 60,
17 CAMERA = 70,
18 CLOCK = 80,
19 VIDEO_RENDER = 90,
20 VIDEO_DECODER = 130,
21 VIDEO_ENCODER = 200,
22 EGL_RENDER = 220,
23 NULL_SINK = 240,
24 VIDEO_SPLITTER = 250
25 } ComponentType;
26
27 static const char * componentType2name(ComponentType type)
28 {
29 switch (type)
30 {
31 case VIDEO_SCHEDULER: return "OMX.broadcom.video_scheduler";
32 case SOURCE: return "OMX.broadcom.source";
33 case RESIZER: return "OMX.broadcom.resize";
34 case CAMERA: return "OMX.broadcom.camera";
35 case CLOCK: return "OMX.broadcom.clock";
36 case VIDEO_RENDER: return "OMX.broadcom.video_render";
37 case VIDEO_DECODER: return "OMX.broadcom.video_decode";
38 case VIDEO_ENCODER: return "OMX.broadcom.video_encode";
39 case EGL_RENDER: return "OMX.broadcom.egl_render";
40 case NULL_SINK: return "OMX.broadcom.null_sink";
41 case VIDEO_SPLITTER: return "OMX.broadcom.video_splitter";
42 }
43
44 return nullptr;
45 }
46
47 static unsigned componentPortsCount(ComponentType type)
48 {
49 switch (type)
50 {
51 case VIDEO_SCHEDULER: return 3;
52 case SOURCE: return 1;
53 case RESIZER: return 2;
54 case CAMERA: return 4;
55 case CLOCK: return 6;
56 case VIDEO_RENDER: return 1;
57 case VIDEO_DECODER: return 2;
58 case VIDEO_ENCODER: return 2;
59 case EGL_RENDER: return 2;
60 case NULL_SINK: return 3;
61 case VIDEO_SPLITTER: return 5;
62 }
63
64 return 0;
65 }
66
67 struct VcosSemaphore
68 {
69 VcosSemaphore(const char * name)
70 {
71 if (vcos_semaphore_create(&sem_, name, 1) != VCOS_SUCCESS)
72 throw "Failed to create handler lock semaphore";
73 }
74
75 ~VcosSemaphore()
76 {
77 vcos_semaphore_delete(&sem_);
78 }
79
80 VCOS_STATUS_T wait() { return vcos_semaphore_wait(&sem_); }
81 VCOS_STATUS_T post() { return vcos_semaphore_post(&sem_); }
82
83 private:
84 VCOS_SEMAPHORE_T sem_;
85 };
86
87 class VcosLock
88 {
89 public:
90 VcosLock(VcosSemaphore * sem)
91 : sem_(sem)
92 {
93 sem_->wait();
94 }
95
96 ~VcosLock()
97 {
98 sem_->post();
99 }
100
101 private:
102 VcosSemaphore * sem_;
103 };
104 }
105
106 #endif
broadcom
Broadcom specific Video Core and OpenMAX IL stuff.
Definition: rpi_omx_broadcom.h:10
broadcom::VcosSemaphore
Definition: rpi_omx_broadcom.h:67
broadcom::VcosLock
Definition: rpi_omx_broadcom.h:87