-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.h
209 lines (166 loc) · 5.84 KB
/
setup.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* rpihddevice - VDR HD output device for Raspberry Pi
* Copyright (C) 2014, 2015, 2016 Thomas Reufer
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SETUP_H
#define SETUP_H
#include "omx.h"
#include "tools.h"
#define VC_DISPLAY_DEFAULT 0
#define VC_DISPLAY_LCD 4
#define VC_DISPLAY_TV_HDMI 5
#define VC_DISPLAY_NON_DEFAULT 6
class cRpiSetup
{
public:
struct AudioParameters
{
AudioParameters() :
port(0),
format(0) { }
int port;
int format;
bool operator!=(const AudioParameters& a) {
return (a.port != port) || (a.format != format);
}
};
struct VideoParameters
{
VideoParameters() :
framing(0),
resolution(0),
frameRate(0),
advancedDeinterlacer(1){ }
int framing;
int resolution;
int frameRate;
int advancedDeinterlacer;
bool operator!=(const VideoParameters& a) {
return (a.framing != framing) || (a.resolution != resolution) ||
(a.frameRate != frameRate) ||
(a.advancedDeinterlacer != advancedDeinterlacer);
}
};
struct OsdParameters
{
OsdParameters() :
accelerated(1) { }
int accelerated;
bool operator!=(const OsdParameters& a) {
return (a.accelerated != accelerated);
}
};
struct PluginParameters
{
PluginParameters() :
hasOsd(true), display(0), videoLayer(0), osdLayer(2) { }
bool hasOsd;
int display;
int videoLayer;
int osdLayer;
};
static bool HwInit(void);
static cRpiAudioPort::ePort GetAudioPort(void) {
return (GetInstance()->m_audio.port) ?
cRpiAudioPort::eHDMI : cRpiAudioPort::eLocal; }
static cAudioFormat::eFormat GetAudioFormat(void) {
return GetInstance()->m_audio.format == 0 ? cAudioFormat::ePassThrough :
GetInstance()->m_audio.format == 1 ? cAudioFormat::eMultiChannelPCM :
cAudioFormat::eStereoPCM;
}
static cVideoFraming::eFraming GetVideoFraming(void) {
return GetInstance()->m_video.framing == 0 ? cVideoFraming::eFrame :
GetInstance()->m_video.framing == 1 ? cVideoFraming::eCut :
cVideoFraming::eStretch;
}
static cVideoResolution::eResolution GetVideoResolution(void) {
return GetInstance()->m_video.resolution == 1 ? cVideoResolution::eFollowVideo :
GetInstance()->m_video.resolution == 2 ? cVideoResolution::e480 :
GetInstance()->m_video.resolution == 3 ? cVideoResolution::e480w :
GetInstance()->m_video.resolution == 4 ? cVideoResolution::e576 :
GetInstance()->m_video.resolution == 5 ? cVideoResolution::e576w :
GetInstance()->m_video.resolution == 6 ? cVideoResolution::e720 :
GetInstance()->m_video.resolution == 7 ? cVideoResolution::e1080 :
cVideoResolution::eDontChange;
}
static cVideoFrameRate::eFrameRate GetVideoFrameRate(void) {
return GetInstance()->m_video.frameRate == 1 ? cVideoFrameRate::eFollowVideo :
GetInstance()->m_video.frameRate == 2 ? cVideoFrameRate::e24p :
GetInstance()->m_video.frameRate == 3 ? cVideoFrameRate::e25p :
GetInstance()->m_video.frameRate == 4 ? cVideoFrameRate::e30p :
GetInstance()->m_video.frameRate == 5 ? cVideoFrameRate::e50i :
GetInstance()->m_video.frameRate == 6 ? cVideoFrameRate::e50p :
GetInstance()->m_video.frameRate == 7 ? cVideoFrameRate::e60i :
GetInstance()->m_video.frameRate == 8 ? cVideoFrameRate::e60p :
cVideoFrameRate::eDontChange;
}
static bool UseAdvancedDeinterlacer(int width, int height) {
return GetInstance()->m_video.advancedDeinterlacer == 0 ? false :
GetInstance()->m_video.advancedDeinterlacer == 1 ?
(width * height <= 576 * 720 ? true : false) : true;
}
static bool IsAudioFormatSupported(cAudioCodec::eCodec codec,
int channels, int samplingRate);
static bool IsVideoCodecSupported(cVideoCodec::eCodec codec) {
return codec == cVideoCodec::eMPEG2 ? GetInstance()->m_mpeg2Enabled :
codec == cVideoCodec::eH264 ? true : false;
}
static bool IsHighLevelOsd(void) {
return GetInstance()->m_osd.accelerated != 0;
}
static bool HasOsd(void) {
return GetInstance()->m_plugin.hasOsd;
}
static int Display(void) {
return GetInstance()->m_plugin.display;
}
static int VideoLayer(void) {
return GetInstance()->m_plugin.videoLayer;
}
static int OsdLayer(void) {
return GetInstance()->m_plugin.osdLayer;
}
static void SetHDMIChannelMapping(bool passthrough, int channels);
static cRpiSetup* GetInstance(void) { return &s_instance; }
static void DropInstance(void);
class cMenuSetupPage* GetSetupPage(void);
bool Parse(const char *name, const char *value);
void Set(AudioParameters audio, VideoParameters video, OsdParameters osd);
static void SetAudioSetupChangedCallback(void (*callback)(void*), void* data = 0);
static void SetVideoSetupChangedCallback(void (*callback)(void*), void* data = 0);
bool ProcessArgs(int argc, char *argv[]);
const char *CommandLineHelp(void);
cRpiSetup() :
m_mpeg2Enabled(false),
m_onAudioSetupChanged(0),
m_onAudioSetupChangedData(0),
m_onVideoSetupChanged(0),
m_onVideoSetupChangedData(0)
{ }
static cRpiSetup s_instance;
private:
AudioParameters m_audio;
VideoParameters m_video;
OsdParameters m_osd;
PluginParameters m_plugin;
bool m_mpeg2Enabled;
void (*m_onAudioSetupChanged)(void*);
void *m_onAudioSetupChangedData;
void (*m_onVideoSetupChanged)(void*);
void *m_onVideoSetupChangedData;
};
#endif