-
Notifications
You must be signed in to change notification settings - Fork 1
/
sourceparams.c
257 lines (242 loc) · 5.06 KB
/
sourceparams.c
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#include "common.h"
#ifdef PVR_SOURCEPARAMS
const char *cPvrSourceParam::sPluginId = "";
#else
const char *cPvrSourceParam::sPluginId = "PVRINPUT|";
#endif
const char *cPvrSourceParam::sInputName[] = {
"TV",
"RADIO",
"COMPOSITE0",
"COMPOSITE1",
"COMPOSITE2",
"COMPOSITE3",
"COMPOSITE4",
"SVIDEO0",
"SVIDEO1",
"SVIDEO2",
"SVIDEO3",
"COMPONENT"
};
const eInputType cPvrSourceParam::sInputType[] = {
eTelevision,
eRadio,
eComposite0,
eComposite1,
eComposite2,
eComposite3,
eComposite4,
eSVideo0,
eSVideo1,
eSVideo2,
eSVideo3,
eComponent
};
const char *cPvrSourceParam::sCards[] = {
"",
"CARD0",
"CARD1",
"CARD2",
"CARD3",
"CARD4",
"CARD5",
"CARD6",
"CARD7"
};
const char *cPvrSourceParam::sStandardName[] = {
"",
"PAL",
"NTSC",
"SECAM",
"NTSC_M",
"NTSC_M_JP",
"NTSC_443",
"NTSC_M_KR",
"PAL_M",
"PAL_N",
"PAL_NC",
"PAL_B",
"PAL_B1",
"PAL_G",
"PAL_BG",
"PAL_D",
"PAL_D1",
"PAL_K",
"PAL_DK",
"PAL_H",
"PAL_I",
"PAL_60",
"SECAM_B",
"SECAM_D",
"SECAM_G",
"SECAM_H",
"SECAM_K",
"SECAM_K1",
"SECAM_DK",
"SECAM_L",
"SECAM_LC"
};
const uint64_t cPvrSourceParam::sStandardNorm[] = {
0,
V4L2_STD_PAL,
V4L2_STD_NTSC,
V4L2_STD_SECAM,
V4L2_STD_NTSC_M,
V4L2_STD_NTSC_M_JP,
V4L2_STD_NTSC_443,
V4L2_STD_NTSC_M_KR,
V4L2_STD_PAL_M,
V4L2_STD_PAL_N,
V4L2_STD_PAL_Nc,
V4L2_STD_PAL_B,
V4L2_STD_PAL_B1,
V4L2_STD_PAL_G,
V4L2_STD_PAL_BG,
V4L2_STD_PAL_D,
V4L2_STD_PAL_D1,
V4L2_STD_PAL_K,
V4L2_STD_PAL_DK,
V4L2_STD_PAL_H,
V4L2_STD_PAL_I,
V4L2_STD_PAL_60,
V4L2_STD_SECAM_B,
V4L2_STD_SECAM_D,
V4L2_STD_SECAM_G,
V4L2_STD_SECAM_H,
V4L2_STD_SECAM_K,
V4L2_STD_SECAM_K1,
V4L2_STD_SECAM_DK,
V4L2_STD_SECAM_L,
V4L2_STD_SECAM_LC
};
const int cPvrSourceParam::sStandardLinesPerFrame[] = {
-1,
625,
525,
625,
525,
525,
525,
525,
525,
625,
625,
625,
625,
625,
625,
625,
625,
625,
625,
625,
625,
525,
625,
625,
625,
625,
625,
625,
625,
625,
625
};
cPvrSourceParam::cPvrSourceParam()
#ifdef PVR_SOURCEPARAMS
:cSourceParam(sSourceID, "analog (pvrinput)")
#endif
{
param = 0;
input = 0;
standard = 0;
card = 0;
}
cString cPvrSourceParam::ParametersToString(void) const
{
if ((standard == 0) && (card == 0))
return cString::sprintf("%s%s", sPluginId, sInputName[input]);
if ((standard == 0) && (card != 0))
return cString::sprintf("%s%s|%s", sPluginId, sInputName[input], sCards[card]);
if ((standard != 0) && (card == 0))
return cString::sprintf("%s%s|%s", sPluginId, sInputName[input], sStandardName[standard]);
return cString::sprintf("%s%s|%s|%s", sPluginId, sInputName[input], sCards[card], sStandardName[standard]);
}
void cPvrSourceParam::SetData(cChannel *Channel)
{
#ifdef PVR_SOURCEPARAMS
ParseParameters(Channel->Parameters(), &input, &standard, &card);
#endif
param = 0;
}
void cPvrSourceParam::GetData(cChannel *Channel)
{
#ifdef PVR_SOURCEPARAMS
Channel->SetTransponderData(Channel->Source(), Channel->Frequency(), Channel->Srate(), ParametersToString(), true);
#endif
}
cOsdItem *cPvrSourceParam::GetOsdItem(void)
{
switch (param++) {
case 0: return new cMenuEditStraItem(tr("SourceParam.pvrinput$Input"), &input, sNumInputs, sInputName);
case 1: return new cMenuEditStraItem(tr("SourceParam.pvrinput$Card"), &card, sNumCards, sCards);
case 2: return new cMenuEditStraItem(tr("SourceParam.pvrinput$Standard"), &standard, sNumStandards, sStandardName);
default: return NULL;
}
return NULL;
}
bool cPvrSourceParam::IsPvr(int Code)
{
return (Code & cSource::st_Mask) == stPvr;
}
bool cPvrSourceParam::ParseParameters(const char *Parameters, int *InputIndex, int *StandardIndex, int *CardIndex)
{
char *InputArg = NULL;
char *OptArg[2] = { NULL, NULL };
#ifdef PVR_SOURCEPARAMS
sscanf(Parameters, "%m[^|]|%m[^|]|%m[^:\n]", &InputArg, &OptArg[0], &OptArg[1]);
#else
char *PluginId = NULL;
sscanf(Parameters, "%m[^|]|%m[^|]|%m[^|]|%m[^:\n]", &PluginId, &InputArg, &OptArg[0], &OptArg[1]);
if (strcasecmp(PluginId, "PVRINPUT"))
return false;
#endif
if (InputIndex) {
*InputIndex = 0;
if (InputArg != NULL) {
for (int i = 0; i < sNumInputs; i++) {
if (!strcasecmp(InputArg, sInputName[i])) {
*InputIndex = i;
break;
}
}
}
}
if (CardIndex)
*CardIndex = 0;
if (StandardIndex)
*StandardIndex = 0;
for (int opt = 0; opt < 2; opt++) {
if (OptArg[opt] != NULL) {
bool parsed = false;
for (int c = 1; c < sNumCards; c++) {
if (!strcasecmp(OptArg[opt], sCards[c])) {
if (CardIndex)
*CardIndex = c;
parsed = true;
break;
}
}
if (!parsed) {
for (int s = 1; s < sNumStandards; s++) {
if (!strcasecmp(OptArg[opt], sStandardName[s])) {
if (StandardIndex)
*StandardIndex = s;
break;
}
}
}
}
}
return true;
}