-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathomx_utils.h
123 lines (97 loc) · 4.34 KB
/
omx_utils.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
pidvbip - tvheadend client for the Raspberry Pi
(C) Dave Chapman 2012-2013
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __OMX_UTILS_H
#define __OMX_UTILS_H
#include <IL/OMX_Broadcom.h>
#include <interface/vcos/vcos.h>
#define OMX_MIN(a,b) (((a) < (b)) ? (a) : (b))
/* Macro borrowed from omxtx */
#define OERR(cmd) do { \
OMX_ERRORTYPE oerr = cmd; \
if (oerr != OMX_ErrorNone) { \
fprintf(stderr, #cmd " failed on line %d: %x\n", __LINE__, oerr); \
exit(1); \
} \
} while (0)
/* Macro borrowed from omxplayer */
#define OMX_INIT_STRUCTURE(a) \
memset(&(a), 0, sizeof(a)); \
(a).nSize = sizeof(a); \
(a).nVersion.s.nVersionMajor = OMX_VERSION_MAJOR; \
(a).nVersion.s.nVersionMinor = OMX_VERSION_MINOR; \
(a).nVersion.s.nRevision = OMX_VERSION_REVISION; \
(a).nVersion.s.nStep = OMX_VERSION_STEP
struct omx_cmd_t
{
OMX_HANDLETYPE *hComponent;
OMX_COMMANDTYPE Cmd;
OMX_U32 nParam;
OMX_PTR pCmdData;
};
struct omx_component_t
{
OMX_HANDLETYPE h;
OMX_CALLBACKTYPE callbacks;
char* name;
/* Variables for handling asynchronous commands */
struct omx_cmd_t cmd;
pthread_mutex_t cmd_queue_mutex;
pthread_cond_t cmd_queue_count_cv;
/* Pointer to parent pipeline */
struct omx_pipeline_t* pipe;
OMX_BUFFERHEADERTYPE *buffers;
int port_settings_changed;
int config_changed;
int aspect; /* Last aspect ratio reported from video_render MarkEvent callback */
pthread_mutex_t buf_mutex;
int buf_notempty;
pthread_cond_t buf_notempty_cv;
pthread_mutex_t eos_mutex;
int eos;
pthread_cond_t eos_cv;
};
struct omx_pipeline_t
{
struct omx_component_t video_decode;
struct omx_component_t video_scheduler;
struct omx_component_t video_render;
struct omx_component_t audio_render;
struct omx_component_t clock;
struct omx_component_t image_fx; /* For deinterlacing */
struct omx_component_t camera;
int do_deinterlace;
pthread_mutex_t omx_active_mutex;
int omx_active;
pthread_cond_t omx_active_cv;
double channel_switch_starttime;
};
OMX_ERRORTYPE omx_init_component(struct omx_pipeline_t* pipe, struct omx_component_t* component, char* compname);
OMX_ERRORTYPE omx_setup_pipeline(struct omx_pipeline_t* pipe, OMX_VIDEO_CODINGTYPE video_codec, char* audio_dest, int is_hd);
void omx_teardown_pipeline(struct omx_pipeline_t* pipe);
OMX_BUFFERHEADERTYPE *get_next_buffer(struct omx_component_t* component);
OMX_ERRORTYPE omx_flush_tunnel(struct omx_component_t* source, int source_port, struct omx_component_t* sink, int sink_port);
void omx_free_buffers(struct omx_component_t *component, int port);
OMX_ERRORTYPE omx_send_command_and_wait(struct omx_component_t* component, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData);
OMX_ERRORTYPE omx_send_command_and_wait0(struct omx_component_t* component, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData);
OMX_ERRORTYPE omx_send_command_and_wait1(struct omx_component_t* component, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData);
void omx_clock_set_speed(struct omx_component_t *clock, int v);
void summarise_buffers(OMX_BUFFERHEADERTYPE *buffers);
int omx_get_free_buffer_count(struct omx_component_t* component);
void omx_alloc_buffers(struct omx_component_t *component, int port);
OMX_TICKS pts_to_omx(uint64_t pts);
void omx_set_display_region(struct omx_pipeline_t* pipe, int x, int y, int width, int height);
void omx_set_source_region(struct omx_pipeline_t* pipe, int x, int y, int width, int height);
#endif